mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2026-03-14 21:10:27 +01:00
ARM: env: Added support for variable env sizes
Kernel fw_env config has statically defined env size to 256KB on NAND and eMMC and 64KB on NOR flash which requires u-boot also to be configutred the same way. This change configures env to support differnt env sizes and preserves the APPSBLENV and avoids CRC mismatch. Change-Id: I55f33c17953beb8e97ebe89f215549b6eefc1a48 Signed-off-by: Gokul Sriram Palanisamy <gokulsri@codeaurora.org>
This commit is contained in:
parent
86f7fe94c9
commit
0255772918
4 changed files with 15 additions and 13 deletions
|
|
@ -169,7 +169,7 @@ int mmc_saveenv(void)
|
|||
|
||||
printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "",
|
||||
CONFIG_SYS_MMC_ENV_DEV);
|
||||
if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
|
||||
if (write_env(mmc, CONFIG_ENV_RANGE, offset, (u_char *)env_new)) {
|
||||
puts("failed\n");
|
||||
ret = 1;
|
||||
goto fini;
|
||||
|
|
@ -322,7 +322,7 @@ void mmc_env_relocate_spec(void)
|
|||
goto fini;
|
||||
}
|
||||
|
||||
if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
|
||||
if (read_env(mmc, CONFIG_ENV_RANGE, offset, buf)) {
|
||||
errmsg = "!read failed";
|
||||
ret = 1;
|
||||
goto fini;
|
||||
|
|
|
|||
|
|
@ -134,9 +134,9 @@ static int writeenv(size_t offset, u_char *buf)
|
|||
u_char *char_ptr;
|
||||
|
||||
blocksize = nand_info[nand_env_device].erasesize;
|
||||
len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
|
||||
len = min(blocksize, (size_t)CONFIG_ENV_RANGE);
|
||||
|
||||
while (amount_saved < CONFIG_ENV_SIZE && offset < end) {
|
||||
while (amount_saved < CONFIG_ENV_RANGE && offset < end) {
|
||||
if (nand_block_isbad(&nand_info[nand_env_device], offset)) {
|
||||
offset += blocksize;
|
||||
} else {
|
||||
|
|
@ -149,7 +149,7 @@ static int writeenv(size_t offset, u_char *buf)
|
|||
amount_saved += len;
|
||||
}
|
||||
}
|
||||
if (amount_saved != CONFIG_ENV_SIZE)
|
||||
if (amount_saved != CONFIG_ENV_RANGE)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
@ -205,7 +205,7 @@ int nand_saveenv(void)
|
|||
};
|
||||
|
||||
|
||||
if (CONFIG_ENV_RANGE < CONFIG_ENV_SIZE)
|
||||
if (CONFIG_ENV_RANGE > board_env_size)
|
||||
return 1;
|
||||
|
||||
ret = env_export(env_new);
|
||||
|
|
@ -216,7 +216,6 @@ int nand_saveenv(void)
|
|||
env_new->flags = ++env_flags; /* increase the serial */
|
||||
env_idx = (gd->env_valid == 1);
|
||||
#endif
|
||||
|
||||
ret = erase_and_write_env(&location[env_idx], (u_char *)env_new);
|
||||
#ifdef CONFIG_ENV_OFFSET_REDUND
|
||||
if (!ret) {
|
||||
|
|
@ -253,9 +252,9 @@ static int readenv(size_t offset, u_char *buf)
|
|||
if (!blocksize)
|
||||
return 1;
|
||||
|
||||
len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
|
||||
len = min(blocksize, (size_t)CONFIG_ENV_RANGE);
|
||||
|
||||
while (amount_loaded < CONFIG_ENV_SIZE && offset < end) {
|
||||
while (amount_loaded < CONFIG_ENV_RANGE && offset < end) {
|
||||
if (nand_block_isbad(&nand_info[nand_env_device], offset)) {
|
||||
offset += blocksize;
|
||||
} else {
|
||||
|
|
@ -270,7 +269,7 @@ static int readenv(size_t offset, u_char *buf)
|
|||
}
|
||||
}
|
||||
|
||||
if (amount_loaded != CONFIG_ENV_SIZE)
|
||||
if (amount_loaded != CONFIG_ENV_RANGE)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -107,11 +107,14 @@
|
|||
#ifndef __ASSEMBLY__
|
||||
#include <compiler.h>
|
||||
extern loff_t board_env_offset;
|
||||
extern loff_t board_env_range;
|
||||
extern loff_t board_env_size;
|
||||
#endif
|
||||
|
||||
#define CONFIG_IPQ807X_ENV 1
|
||||
#define CONFIG_ENV_OFFSET board_env_offset
|
||||
#define CONFIG_ENV_SIZE 0x2000
|
||||
#define CONFIG_ENV_SIZE CONFIG_ENV_SIZE_MAX
|
||||
#define CONFIG_ENV_RANGE board_env_range
|
||||
#define CONFIG_ENV_SIZE_MAX (256 << 10) /* 256 KB */
|
||||
#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE_MAX + (512 << 10))
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ extern char *env_name_spec;
|
|||
/* Make sure the payload is multiple of AES block size */
|
||||
#define ENV_SIZE ((CONFIG_ENV_SIZE - ENV_HEADER_SIZE) & ~(16 - 1))
|
||||
#else
|
||||
#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE)
|
||||
#define ENV_SIZE (CONFIG_ENV_RANGE - ENV_HEADER_SIZE)
|
||||
#endif
|
||||
|
||||
typedef struct environment_s {
|
||||
|
|
@ -158,7 +158,7 @@ typedef struct environment_s {
|
|||
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
|
||||
unsigned char flags; /* active/obsolete flags */
|
||||
#endif
|
||||
unsigned char data[ENV_SIZE]; /* Environment data */
|
||||
unsigned char data[CONFIG_ENV_SIZE_MAX - ENV_HEADER_SIZE]; /* Environment data */
|
||||
} env_t
|
||||
#ifdef CONFIG_ENV_AES
|
||||
/* Make sure the env is aligned to block size. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue