upstream u-boot with additional patches for our devices/boards:
https://lists.denx.de/pipermail/u-boot/2017-March/282789.html (AXP crashes) ;
Gbit ethernet patch for some LIME2 revisions ;
with SPI flash support
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.2 KiB
111 lines
2.2 KiB
12 years ago
|
/*
|
||
|
* (c) Copyright 2011 by Tigris Elektronik GmbH
|
||
|
*
|
||
|
* Author:
|
||
|
* Maximilian Schwerin <mvs@tigris.de>
|
||
|
*
|
||
11 years ago
|
* SPDX-License-Identifier: GPL-2.0+
|
||
12 years ago
|
*/
|
||
|
|
||
|
#include <common.h>
|
||
|
|
||
|
#include <command.h>
|
||
|
#include <environment.h>
|
||
|
#include <linux/stddef.h>
|
||
|
#include <malloc.h>
|
||
9 years ago
|
#include <memalign.h>
|
||
12 years ago
|
#include <search.h>
|
||
|
#include <errno.h>
|
||
|
#include <fat.h>
|
||
|
#include <mmc.h>
|
||
|
|
||
|
char *env_name_spec = "FAT";
|
||
|
|
||
|
env_t *env_ptr;
|
||
|
|
||
|
DECLARE_GLOBAL_DATA_PTR;
|
||
|
|
||
|
int env_init(void)
|
||
|
{
|
||
|
/* use default */
|
||
|
gd->env_addr = (ulong)&default_environment[0];
|
||
|
gd->env_valid = 1;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
#ifdef CONFIG_CMD_SAVEENV
|
||
|
int saveenv(void)
|
||
|
{
|
||
11 years ago
|
env_t env_new;
|
||
8 years ago
|
struct blk_desc *dev_desc = NULL;
|
||
10 years ago
|
disk_partition_t info;
|
||
|
int dev, part;
|
||
12 years ago
|
int err;
|
||
10 years ago
|
loff_t size;
|
||
12 years ago
|
|
||
10 years ago
|
err = env_export(&env_new);
|
||
|
if (err)
|
||
|
return err;
|
||
12 years ago
|
|
||
7 years ago
|
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
||
|
CONFIG_ENV_FAT_DEVICE_AND_PART,
|
||
10 years ago
|
&dev_desc, &info, 1);
|
||
|
if (part < 0)
|
||
12 years ago
|
return 1;
|
||
12 years ago
|
|
||
8 years ago
|
dev = dev_desc->devnum;
|
||
10 years ago
|
if (fat_set_blk_dev(dev_desc, &info) != 0) {
|
||
|
printf("\n** Unable to use %s %d:%d for saveenv **\n",
|
||
7 years ago
|
CONFIG_ENV_FAT_INTERFACE, dev, part);
|
||
12 years ago
|
return 1;
|
||
|
}
|
||
|
|
||
7 years ago
|
err = file_fat_write(CONFIG_ENV_FAT_FILE, (void *)&env_new, 0, sizeof(env_t),
|
||
10 years ago
|
&size);
|
||
12 years ago
|
if (err == -1) {
|
||
12 years ago
|
printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
|
||
7 years ago
|
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part);
|
||
12 years ago
|
return 1;
|
||
|
}
|
||
|
|
||
|
puts("done\n");
|
||
|
return 0;
|
||
|
}
|
||
|
#endif /* CONFIG_CMD_SAVEENV */
|
||
|
|
||
|
void env_relocate_spec(void)
|
||
|
{
|
||
10 years ago
|
ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
|
||
8 years ago
|
struct blk_desc *dev_desc = NULL;
|
||
10 years ago
|
disk_partition_t info;
|
||
|
int dev, part;
|
||
12 years ago
|
int err;
|
||
12 years ago
|
|
||
7 years ago
|
part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
|
||
|
CONFIG_ENV_FAT_DEVICE_AND_PART,
|
||
10 years ago
|
&dev_desc, &info, 1);
|
||
|
if (part < 0)
|
||
|
goto err_env_relocate;
|
||
|
|
||
8 years ago
|
dev = dev_desc->devnum;
|
||
10 years ago
|
if (fat_set_blk_dev(dev_desc, &info) != 0) {
|
||
|
printf("\n** Unable to use %s %d:%d for loading the env **\n",
|
||
7 years ago
|
CONFIG_ENV_FAT_INTERFACE, dev, part);
|
||
10 years ago
|
goto err_env_relocate;
|
||
12 years ago
|
}
|
||
|
|
||
7 years ago
|
err = file_fat_read(CONFIG_ENV_FAT_FILE, buf, CONFIG_ENV_SIZE);
|
||
12 years ago
|
if (err == -1) {
|
||
12 years ago
|
printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
|
||
7 years ago
|
CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part);
|
||
10 years ago
|
goto err_env_relocate;
|
||
12 years ago
|
}
|
||
|
|
||
|
env_import(buf, 1);
|
||
10 years ago
|
return;
|
||
|
|
||
|
err_env_relocate:
|
||
|
set_default_env(NULL);
|
||
12 years ago
|
}
|