[ECOS] Re: Limit region of flash used by RedBoot for FIS?

Grant Edwards grante@visi.com
Tue Nov 7 16:00:00 GMT 2006

In gmane.os.ecos.general, you wrote:

>>>> In fact a quick examination of fis_init() suggests it does
>>>> erase after the end of the cfg/fis blocks.
>>> Sure looks like it always erases all the way to the end in
>>> the following snippet from fis_init()
>>> 482             // Lastly, anything at the end, if there is any
>>> 483             if ( erase_start < (((CYG_ADDRESS)flash_end)+1) ) {
>>> 484                 erase_size = ((CYG_ADDRESS)flash_end - erase_start) + 1;
>>> 485                 if ((stat = flash_erase((void *)erase_start, erase_size,
>>> 486                                         (void **)&err_addr)) != 0) {
>>> 487                     diag_printf("   initialization failed at %p: %s\n",
>>> 488                                 err_addr, flash_errmsg(stat));
>>> 489                 }
>> I need to look more closely at it, but I _think_ that simply
>> deleting the above code will prevent fis_init() from erasing
>> the area above the direcotry block, but that still won't
>> prevent other code such as fis_free() from using blocks above
>> the directory block, will it?
>> AFAICT, all of the fis code uses flash_end as the end of usable
>> effect on flash_end -- all it does is determine the location of
>> the directory block.
>> value that is subtracted from flash_end they way
>> CYGNUM_REDBOOT_FLASH_RESERVED_BASE is added to flash_start.
> As I said, that's how it was expected to work.  I don't think
> we've ever needed to have a reserved area at the end as you do,
> so it may not work in practice.

I haven't actually tested it yet. I may be mis-reading the code
,and it may in fact work.  

First I'm going to disable the top half of flash in the flash
device driver, so that should it not work I won't kill my
board again. :)

> Patches more than welcome, as always :-)

If it doesn't work as-is, I'll come up with one.

Is there any reason that somebody might want the FIS directory
block somewhere other than at the top of usable flash? If not,
is there a reason why the reserved region in the bottom of
flash is specified in bytes, but at the top it's specified in

If I got to choose, I would get rid of the
CYGNUM_REDBOOT_FIS_DIRECTORY_BLOCK option, and replace it with
CYGNUM_REDBOOT_FLASH_RESERVED_TOP value that is just subtracted
from flash_end. But, removing an option will probably break
somebody's code.

So I'll probably just add CYGNUM_REDBOOT_FLASH_RESERVED_TOP and
leave the FIS directory position specified (in blocks) by
Grant Edwards                   grante             Yow!  I'm having an
                                  at               emotional outburst!!

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list