This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: flash size calculation
- To: Jonathan Larmour <jlarmour at redhat dot com>
- Subject: Re: [ECOS] flash size calculation
- From: Gary Thomas <gthomas at redhat dot com>
- Date: 12 Sep 2001 12:06:32 +0900
- Cc: Christoph Csebits <christoph dot csebits at frequentis dot com>,eCos mailing list <ecos-discuss at sources dot redhat dot com>
- References: <20010911105818.A5497@frequentis.com> <3B9EB30A.F5260F48@redhat.com>
On Wed, 2001-09-12 at 09:57, Jonathan Larmour wrote:
> Christoph Csebits wrote:
> >
> > hi
> >
> > in the most platforms start-address and end-address
> > of the flash devices are calculated like the following:
> >
> > flash_info.start = (void *)CYGNUM_FLASH_BASE;
> > flash_info.end = (void *)(CYGNUM_FLASH_BASE+ (FLASH_NUM_REGIONS
> > * FLASH_BLOCK_SIZE * CYGNUM_FLASH_INTERLEAVE * CYGNUM_FLASH_SERIES));
> >
> > Supposed i have an 8MB flash starting at 0xFF800000:
> > flash_info.start = 0xFF800000
> > flash_info.end = 0x00000000 (overflow).
> >
> > Is it sufficient to decrement the end address by one?
>
> Probably not good: looking at redboot's load_flash_config() function, it
> uses the flash_end (set from flash_info.end) to calculate the base for the
> flash config. But that should be aligned to a flash block.
>
> This is an oversight in the flash code. Patches welcome :-). Probably the
> thing to do is make the flash end address be an unsigned long long, and
> change all the types that use it accordingly (like flash_end).
>
Actually, I've improved this so that the FLASH end address is kept as
the last valid address, not the first invalid one. This avoids the
wrap around problem.
Look for this in the next anonCVS update. Note: the patch is a bit
messy as there have been other recent changes in the redboot/flash.c
as well, otherwise, I'd just post it here.