]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/env_fat.c
2 * (c) Copyright 2011 by Tigris Elektronik GmbH
5 * Maximilian Schwerin <mvs@tigris.de>
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <environment.h>
14 #include <linux/stddef.h>
21 char *env_name_spec
= "FAT";
25 DECLARE_GLOBAL_DATA_PTR
;
30 gd
->env_addr
= (ulong
)&default_environment
[0];
36 #ifdef CONFIG_CMD_SAVEENV
40 block_dev_desc_t
*dev_desc
= NULL
;
41 disk_partition_t info
;
45 err
= env_export(&env_new
);
49 part
= get_device_and_partition(FAT_ENV_INTERFACE
,
50 FAT_ENV_DEVICE_AND_PART
,
56 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
57 printf("\n** Unable to use %s %d:%d for saveenv **\n",
58 FAT_ENV_INTERFACE
, dev
, part
);
62 err
= file_fat_write(FAT_ENV_FILE
, (void *)&env_new
, sizeof(env_t
));
64 printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
65 FAT_ENV_FILE
, FAT_ENV_INTERFACE
, dev
, part
);
72 #endif /* CONFIG_CMD_SAVEENV */
74 void env_relocate_spec(void)
76 ALLOC_CACHE_ALIGN_BUFFER(char, buf
, CONFIG_ENV_SIZE
);
77 block_dev_desc_t
*dev_desc
= NULL
;
78 disk_partition_t info
;
82 part
= get_device_and_partition(FAT_ENV_INTERFACE
,
83 FAT_ENV_DEVICE_AND_PART
,
86 goto err_env_relocate
;
89 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
90 printf("\n** Unable to use %s %d:%d for loading the env **\n",
91 FAT_ENV_INTERFACE
, dev
, part
);
92 goto err_env_relocate
;
95 err
= file_fat_read(FAT_ENV_FILE
, buf
, CONFIG_ENV_SIZE
);
97 printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
98 FAT_ENV_FILE
, FAT_ENV_INTERFACE
, dev
, part
);
99 goto err_env_relocate
;
106 set_default_env(NULL
);