[U-Boot-Users] How to support multiple flash sizes ?

Wolfgang Denk wd at denx.de
Tue May 9 12:02:06 CEST 2006


In message <200605091107.33195.laurent.pinchart at tbox.biz> you wrote:
> 
> I'm trying to find a way for U-Boot to automatically detect the flash base 
> address.

That's trivial - it's a constant: CFG_FLASH_BASE

> Our custom board can be mounted with different flash options, from 16MB to 
> 128MB. I would like to avoid programming the board with a different boot 
> loader for each flash size, so I was trying a way to create a 
> "one-fits-them-all" U-Boot version.

Yes, that's the standard approach which is used on all sane ports  of
U-Boot. U-Boot auto-detects the size of flash and maps it as needed.

> I thought defining CFG_FLASH_BASE to 0xF8000000 would be enough, as the flash 
> would repeat over the 128MB memory range. This indeed works fine for reading, 

What do mean with "repeat"? U-Boot will map only  the  correct  size,
and nothing will "repeat".

> but U-Boot is clever enough to detect the flash size, which leads to problems 
> when erasing sectors. The environment, for instance, is stored at TEXT_BASE + 
> 256kB (0xFFF40000). Saving the environment fails, as U-Boot is unable to 
> erase sector 0xFFF40000 which is outside the 16MB flash memory range 
> (0xF8000000 - 0xF8FFFFFF).

Why do you define a TEXT_BASE+256kB location for your environment then?

> CFG_FLASH_BASE is used throughout the U-Boot code, so it would not be an easy 
> task to replacing it by a variable. Does someone know of a way to either 
> detect the flash base address, or read it from a fixed location in flash 
> (let's say in the first sector for instance, after the hard reset 
> configuration word) ? A possible approach would be to use the hardcoded 
> CFG_FLASH_BASE value at startup, and remap the flash at 0xFFFFFFFF - 
> flash_size later when the flash size is known. CFG_FLASH_BASE would have to 
> be replaced by a variable in several places.

I don't understand  a  single  word.  Why  would  you  want  to  make
CFG_FLASH_BASE  a variable? Just define a memory map for your system,
and use it. Put CFG_FLASH_BASE low enough to allow for  all  possible
configurations, and that's it.

See how it's done on any of the other 200+ boards.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When a child is taught ... its programmed with simple instructions --
and at some point, if its mind develops properly, it exceeds the  sum
of what it was taught, thinks independently.
	-- Dr. Richard Daystrom, "The Ultimate Computer",
	   stardate 4731.3.




More information about the U-Boot mailing list