env_t *env_ptr;
char *env_name_spec = "dataflash";
-static char env_buf[CONFIG_ENV_SIZE];
uchar env_get_char_spec(int index)
{
void env_relocate_spec(void)
{
- read_dataflash(CONFIG_ENV_ADDR, CONFIG_ENV_SIZE, env_buf);
+ char buf[CONFIG_ENV_SIZE];
- env_import(env_buf, 1);
+ read_dataflash(CONFIG_ENV_ADDR, CONFIG_ENV_SIZE, buf);
+
+ env_import(buf, 1);
}
#ifdef CONFIG_ENV_OFFSET_REDUND
int saveenv(void)
{
- env_t *env_new = (env_t *)env_buf;
+ env_t env_new;
ssize_t len;
char *res;
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
return write_dataflash(CONFIG_ENV_ADDR,
- (unsigned long)env_new,
+ (unsigned long)&env_new,
CONFIG_ENV_SIZE);
}
DECLARE_GLOBAL_DATA_PTR;
env_t *env_ptr;
-static char env_buf[CONFIG_ENV_SIZE];
char *env_name_spec = "EEPROM";
int env_eeprom_bus = -1;
void env_relocate_spec(void)
{
- char *buf = env_buf;
+ char buf[CONFIG_ENV_SIZE];
unsigned int off = CONFIG_ENV_OFFSET;
#ifdef CONFIG_ENV_OFFSET_REDUND
int saveenv(void)
{
- env_t *env_new = (env_t *)env_buf;
+ env_t env_new;
ssize_t len;
char *res;
int rc;
BUG_ON(env_ptr != NULL);
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
#ifdef CONFIG_ENV_OFFSET_REDUND
if (gd->env_valid == 1) {
off_red = CONFIG_ENV_OFFSET;
}
- env_new->flags = ACTIVE_FLAG;
+ env_new.flags = ACTIVE_FLAG;
#endif
rc = eeprom_bus_write(CONFIG_SYS_DEF_EEPROM_ADDR,
- off, (uchar *)env_new, CONFIG_ENV_SIZE);
+ off, (uchar *)&env_new, CONFIG_ENV_SIZE);
#ifdef CONFIG_ENV_OFFSET_REDUND
if (rc == 0) {
char *env_name_spec = "FAT";
env_t *env_ptr;
-static char env_buf[CONFIG_ENV_SIZE];
DECLARE_GLOBAL_DATA_PTR;
#ifdef CONFIG_CMD_SAVEENV
int saveenv(void)
{
- env_t *env_new = env_buf;
+ env_t env_new;
ssize_t len;
char *res;
block_dev_desc_t *dev_desc = NULL;
int part = FAT_ENV_PART;
int err;
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
- err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t));
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
+ err = file_fat_write(FAT_ENV_FILE, (void *)&env_new, sizeof(env_t));
if (err == -1) {
printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part);
void env_relocate_spec(void)
{
- char *buf = env_buf;
+ char buf[CONFIG_ENV_SIZE];
block_dev_desc_t *dev_desc = NULL;
int dev = FAT_ENV_DEVICE;
int part = FAT_ENV_PART;
env_t *env_ptr;
#endif /* ENV_IS_EMBEDDED */
-DEFINE_CACHE_ALIGN_BUFFER(char, env_buf, CONFIG_ENV_SIZE);
-
DECLARE_GLOBAL_DATA_PTR;
#if !defined(CONFIG_ENV_OFFSET)
int saveenv(void)
{
- env_t *env_new = (env_t *)env_buf;
+ ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
ssize_t len;
char *res;
struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
goto fini;
}
- res = (char *)env_new->data;
+ res = (char *)&env_new->data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto fini;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new->crc = crc32(0, &env_new->data[0], ENV_SIZE);
printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV);
if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
puts("failed\n");
void env_relocate_spec(void)
{
#if !defined(ENV_IS_EMBEDDED)
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
u32 offset;
int ret;
goto fini;
}
- if (read_env(mmc, CONFIG_ENV_SIZE, offset, env_buf)) {
+ if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
ret = 1;
goto fini;
}
- env_import(env_buf, 1);
+ env_import(buf, 1);
ret = 0;
fini:
env_t *env_ptr;
#endif /* ENV_IS_EMBEDDED */
-DEFINE_CACHE_ALIGN_BUFFER(char, env_buf, CONFIG_ENV_SIZE);
-
DECLARE_GLOBAL_DATA_PTR;
/*
int saveenv(void)
{
- env_t *env_new = (env_t *)env_buf;
+ env_t env_new;
ssize_t len;
char *res;
int ret = 0;
if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
return 1;
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
- env_new->flags = ++env_flags; /* increase the serial */
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
+ env_new.flags = ++env_flags; /* increase the serial */
if (gd->env_valid == 1) {
puts("Erasing redundant NAND...\n");
return 1;
puts("Writing to redundant NAND... ");
- ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *)env_new);
+ ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *)&env_new);
} else {
puts("Erasing NAND...\n");
nand_erase_options.offset = CONFIG_ENV_OFFSET;
return 1;
puts("Writing to NAND... ");
- ret = writeenv(CONFIG_ENV_OFFSET, (u_char *)env_new);
+ ret = writeenv(CONFIG_ENV_OFFSET, (u_char *)&env_new);
}
if (ret) {
puts("FAILED!\n");
int saveenv(void)
{
int ret = 0;
- env_t *env_new = (env_t *)env_buf;
+ ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
ssize_t len;
char *res;
nand_erase_options_t nand_erase_options;
if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
return 1;
- res = (char *)env_new->data;
+ res = (char *)&env_new->data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
{
#if !defined(ENV_IS_EMBEDDED)
int ret;
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
#if defined(CONFIG_ENV_OFFSET_OOB)
ret = get_nand_env_oob(&nand_info[0], &nand_env_oob_offset);
}
#endif
- ret = readenv(CONFIG_ENV_OFFSET, (u_char *)env_buf);
+ ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
if (ret) {
set_default_env("!readenv() failed");
return;
}
- env_import(env_buf, 1);
+ env_import(buf, 1);
#endif /* ! ENV_IS_EMBEDDED */
}
#endif /* CONFIG_ENV_OFFSET_REDUND */
char *env_name_spec = "NVRAM";
-#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-static char env_buf[CONFIG_ENV_SIZE];
-#endif
-
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
uchar env_get_char_spec(int index)
{
void env_relocate_spec(void)
{
- char *buf;
+ char buf[CONFIG_ENV_SIZE];
#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
- buf = env_buf;
nvram_read(buf, CONFIG_ENV_ADDR, CONFIG_ENV_SIZE);
#else
- buf = (void *)CONFIG_ENV_ADDR;
+ memcpy(buf, (void *)CONFIG_ENV_ADDR, CONFIG_ENV_SIZE);
#endif
env_import(buf, 1);
}
int saveenv(void)
{
-#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
- env_t *env_new = (env_t *)env_buf;
-#else
- env_t *env_new = (env_t *)CONFIG_ENV_ADDR;
-#endif
+ env_t env_new;
ssize_t len;
char *res;
int rcode = 0;
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
- nvram_write(CONFIG_ENV_ADDR, env_new, CONFIG_ENV_SIZE);
+ nvram_write(CONFIG_ENV_ADDR, &env_new, CONFIG_ENV_SIZE);
+#else
+ if (memcpy((char *)CONFIG_ENV_ADDR, &env_new, CONFIG_ENV_SIZE) == NULL)
+ rcode = 1;
#endif
return rcode;
}
{
#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
ulong crc;
- uchar *data = env_buf;
+ uchar data[ENV_SIZE];
nvram_read(&crc, CONFIG_ENV_ADDR, sizeof(ulong));
nvram_read(data, CONFIG_ENV_ADDR + sizeof(ulong), ENV_SIZE);
#define ONENAND_MAX_ENV_SIZE CONFIG_ENV_SIZE
#define ONENAND_ENV_SIZE(mtd) (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
-static char env_buf[CONFIG_ENV_SIZE];
-
DECLARE_GLOBAL_DATA_PTR;
void env_relocate_spec(void)
char *buf = (char *)&environment;
#else
loff_t env_addr = CONFIG_ENV_ADDR;
- char *buf = env_buf;
+ char onenand_env[ONENAND_MAX_ENV_SIZE];
+ char *buf = (char *)&onenand_env[0];
#endif /* ENV_IS_EMBEDDED */
#ifndef ENV_IS_EMBEDDED
int saveenv(void)
{
- env_t *env_new = env_buf;
+ env_t env_new;
ssize_t len;
char *res;
struct mtd_info *mtd = &onenand_mtd;
.callback = NULL,
};
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
instr.len = CONFIG_ENV_SIZE;
#ifdef CONFIG_ENV_ADDR_FLEX
}
if (mtd->write(mtd, env_addr, ONENAND_MAX_ENV_SIZE, &retlen,
- (u_char *)env_new)) {
+ (u_char *)&env_new)) {
printf("OneNAND: write failed at 0x%llx\n", instr.addr);
return 2;
}
char *env_name_spec = "SPI Flash";
static struct spi_flash *env_flash;
-static char env_buf[CONFIG_ENV_SIZE];
#if defined(CONFIG_ENV_OFFSET_REDUND)
int saveenv(void)
{
- env_t *env_new = (env_t *)env_buf;
+ env_t env_new;
ssize_t len;
char *res, *saved_buffer = NULL, flag = OBSOLETE_FLAG;
u32 saved_size, saved_offset, sector = 1;
}
}
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
return 1;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
- env_new->flags = ACTIVE_FLAG;
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
+ env_new.flags = ACTIVE_FLAG;
if (gd->env_valid == 1) {
env_new_offset = CONFIG_ENV_OFFSET_REDUND;
puts("Writing to SPI flash...");
ret = spi_flash_write(env_flash, env_new_offset,
- CONFIG_ENV_SIZE, env_new);
+ CONFIG_ENV_SIZE, &env_new);
if (ret)
goto done;
}
ret = spi_flash_write(env_flash, env_offset + offsetof(env_t, flags),
- sizeof(env_new->flags), &flag);
+ sizeof(env_new.flags), &flag);
if (ret)
goto done;
u32 saved_size, saved_offset, sector = 1;
char *res, *saved_buffer = NULL;
int ret = 1;
- env_t *env_new = (env_t *)env_buf;
+ env_t env_new;
ssize_t len;
if (!env_flash) {
sector++;
}
- res = (char *)env_new->data;
+ res = (char *)&env_new.data;
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
if (len < 0) {
error("Cannot export environment: errno = %d\n", errno);
goto done;
}
- env_new->crc = crc32(0, env_new->data, ENV_SIZE);
+ env_new.crc = crc32(0, env_new.data, ENV_SIZE);
puts("Erasing SPI flash...");
ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET,
puts("Writing to SPI flash...");
ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET,
- CONFIG_ENV_SIZE, env_new);
+ CONFIG_ENV_SIZE, &env_new);
if (ret)
goto done;
void env_relocate_spec(void)
{
- char *buf = env_buf;
+ char buf[CONFIG_ENV_SIZE];
int ret;
env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,