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>
22 char *env_name_spec = "FAT";
26 DECLARE_GLOBAL_DATA_PTR;
31 gd->env_addr = (ulong)&default_environment[0];
37 #ifdef CONFIG_CMD_SAVEENV
41 struct blk_desc *dev_desc = NULL;
42 disk_partition_t info;
47 err = env_export(&env_new);
51 part = blk_get_device_part_str(FAT_ENV_INTERFACE,
52 FAT_ENV_DEVICE_AND_PART,
57 dev = dev_desc->devnum;
58 if (fat_set_blk_dev(dev_desc, &info) != 0) {
59 printf("\n** Unable to use %s %d:%d for saveenv **\n",
60 FAT_ENV_INTERFACE, dev, part);
64 err = file_fat_write(FAT_ENV_FILE, (void *)&env_new, 0, sizeof(env_t),
67 printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
68 FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part);
75 #endif /* CONFIG_CMD_SAVEENV */
77 void env_relocate_spec(void)
79 ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
80 struct blk_desc *dev_desc = NULL;
81 disk_partition_t info;
85 part = blk_get_device_part_str(FAT_ENV_INTERFACE,
86 FAT_ENV_DEVICE_AND_PART,
89 goto err_env_relocate;
91 dev = dev_desc->devnum;
92 if (fat_set_blk_dev(dev_desc, &info) != 0) {
93 printf("\n** Unable to use %s %d:%d for loading the env **\n",
94 FAT_ENV_INTERFACE, dev, part);
95 goto err_env_relocate;
98 err = file_fat_read(FAT_ENV_FILE, buf, CONFIG_ENV_SIZE);
100 printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
101 FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part);
102 goto err_env_relocate;
109 set_default_env(NULL);