[U-Boot-Users] flash hardware protection with CFI driver does not autoprotect monitor completely
Wolfgang Denk
wd at denx.de
Sun Nov 18 22:52:00 CET 2007
Dear Matthias,
in message <200711182214.06137.matthias.fuchs at esd-electronics.com> you wrote:
>
> > I think as a short term fix we might define an additional area that
> > needs to be protected (the reset vector). Mid/long term we should
> > change the code so you can pass a list of areas (start/end or
> > start/length pairs) that will be protected. This would, for example,
> > also allow to keep certain other areas (FDT, kernel image, etc.)
> > auto-protected as well - configurable by the user ona per-board base.
>
> Sometinhg like this?
>
> Add this to board's config file:
> #define CONFIG_FLASH_AUTOPROTECT_LIST {{0xfffe0000, 0xffffffff}, {0xfe000000, 0xfe0fffff}}
Yes, that's what I meant, although I have to admit that my personal
preference would be to use { start, size } instead.
What do you (and others) think?
> And handle this list from the cfi driver:
>
> diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c
> index 5579a1e..0777349 100644
> --- a/drivers/cfi_flash.c
> +++ b/drivers/cfi_flash.c
> @@ -333,11 +333,17 @@ ulong flash_read_long (flash_info_t * info, flash_sect_t sect, uint offset)
>
> /*-----------------------------------------------------------------------
> */
> +struct apl_s {ulong start; ulong end;};
> +
> unsigned long flash_init (void)
> {
> unsigned long size = 0;
> int i;
>
> +#if defined(CONFIG_FLASH_AUTOPROTECT_LIST)
> + struct apl_s apl[] = CONFIG_FLASH_AUTOPROTECT_LIST;
> +#endif
> +
> #ifdef CFG_FLASH_PROTECTION
> char *s = getenv("unlock");
> #endif
> @@ -419,6 +425,16 @@ 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_LIST)
> + for (i = 0; i < sizeof(apl)/sizeof(struct apl_s); i++) {
> + printf("autoprotecting from %08x to %08x\n", apl[i].start, apl[i].end);
> + flash_protect (FLAG_PROTECT_SET,
> + apl[i].start,
> + apl[i].end,
> + flash_get_info(apl[i].start));
> + }
> +#endif
> return (size);
> }
Right. That's what I had in mind. Except that I recommend to
s/printf/debug/ ...
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Doubt isn't the opposite of faith; it is an element of faith.
- Paul Tillich, German theologian and historian
More information about the U-Boot
mailing list