
On 19:22 Sat 19 Apr , Matthias Fuchs wrote:
Hi,
I tried this in cfi_flash.c:
struct apl_s { ulong start; ulong size; }
struct apl_s apl[] __attribute__((weak)) = {};
The problem with weak var is that the first declaration define the sizeof the var. and the other define the data;
As sugest Wolfgang we could do it like this
in cfi_flash.c
--- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -1873,6 +1873,12 @@ unsigned long flash_init (void) { unsigned long size = 0; int i; +if define(CONFIG_FLASH_AUTOPROTECT) +struct apl_s apl[] = init_flash_autoprotect(); +#endif
#ifdef CFG_FLASH_PROTECTION char *s = getenv("unlock"); @@ -1966,6 +1972,17 @@ unsigned long flash_init (void) CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1, flash_get_info(CFG_ENV_ADDR_REDUND)); #endif + +#if defined(CONFIG_FLASH_AUTOPROTECT) + for (i = 0; i < (sizeof(apl) / sizeof(struct apl_s)); i++) { + debug("autoprotecting from %08x to %08x\n", + apl[i].start, apl[i].start + apl[i].size - 1); + flash_protect (FLAG_PROTECT_SET, + apl[i].start, + apl[i].start + apl[i].size - 1, + flash_get_info(apl[i].start)); + } +#endif
in config header
struct apl_s apl* inline init_flash_autoprotect() { struct apl_s a[] = { {1, 3}, {4, 5}, };
return a; } Best Regards, J.