[U-Boot-Users] Dynamic location of the environment sector

Wolfgang Denk wd at denx.de
Wed Jun 14 16:31:04 CEST 2006


In message <448FF915.5060306 at inaccessnetworks.com> you wrote:
> I have a board that comes in three flash confirurations:
...
> the last sector (a small sector) to contain the environment. The last 
> sector though is in a different address (and has a different size) 
> depending on the flash configuration.

OK.

> Currently the defines for the environment expect raw numerical values. 

What makes you think so?

I didn't try it, but I see no reason why something like

	#define CFG_ENV_ADDR		my_env_params(1)
	#define CFG_ENV_SIZE		my_env_params(2)
	#define CFG_ENV_SECT_SIZE	my_env_params(3)

would be impossible. But this probably does not solve your problem  -
see below.

> Is there an infrastructure somewhere to define the flash size at 
> runtime? I tried to print the flash sizes in the board specific codes, 
> for instance:

You have all the powers of the C preprocessor and  compiler  at  your
hands. Just use them.

> And all sizes are detected correctly. I want to use these values to 
> calculate the location of the environment dynamically at runtime. This 
> way I can have a single u-boot image for all flash configurations!

There is one problem which you probably did not realize  yet:  U-Boot
will  access  the  environment  (for  example,  to  read  the console
baudrate) *long* before the flash detection code  is  running  (which
actually  happens very late in the init sequence, after relocation to
RAM). So you cannot rely on values filled in the flash_info[]  array,
as  such data does not exist yet when you need it. You will need some
other way (like configuration registers of jumpers on the  board)  to
figure out which configuration to use.

Or you simply chose a definition that works on all  boards,  even  if
this  means  that  you  will waste some flashmemory on 2 of the board
configurations.

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
Our business is run on trust.  We trust you will pay in advance.




More information about the U-Boot mailing list