2 * (c) Copyright 2012 by National Instruments,
3 * Joe Hershberger <joe.hershberger@ni.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <environment.h>
31 #include <ubi_uboot.h>
34 char *env_name_spec = "UBI";
38 DECLARE_GLOBAL_DATA_PTR;
43 gd->env_addr = (ulong)&default_environment[0];
49 #ifdef CONFIG_CMD_SAVEENV
52 ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
56 res = (char *)&env_new->data;
57 len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
59 error("Cannot export environment: errno = %d\n", errno);
63 if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) {
64 printf("\n** Cannot find mtd partition \"%s\"\n",
69 env_new->crc = crc32(0, env_new->data, ENV_SIZE);
71 if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME, (void *)env_new,
73 printf("\n** Unable to write env to %s:%s **\n",
74 CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
81 #endif /* CONFIG_CMD_SAVEENV */
83 void env_relocate_spec(void)
85 ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
87 if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) {
88 printf("\n** Cannot find mtd partition \"%s\"\n",
90 set_default_env(NULL);
94 if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)&buf,
96 printf("\n** Unable to read env from %s:%s **\n",
97 CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
98 set_default_env(NULL);