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

Angelos Manousarides amanous at inaccessnetworks.com
Wed Jun 21 12:48:21 CEST 2006

On Wed, Jun 14, 2006 at 04:31:04PM +0200, Wolfgang Denk wrote:
> > 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.

Indeed it does not. The problem however, just for the record is code
like the following segment:

#  define ENV_IS_EMBEDDED       1
# endif

The preprocessor cannot obviously perform checks and do arithmetic with
C variables and constructs:

include/environment.h:64:20: token "[" is not validin preprocessor expressions

> > 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.

This is the solution I will follow, although I was trying to avoid it.
The second block, right after the u-boot will hold the environment. I
have an issue though with the environment sector size. I have three
configurations, two of which have a sector size 0x40000 and one has
0x20000. The problem I mentioned above with the static declarations
appears here. If I declare the env size to be the smaller sector, An
error occurs during the environment saving : "flash sector size is not
equal to the environment size" or something like that.

Another note not related to the ones above. A couple of days ago I sent
some patches for the arm architecture, but I did not received any
replies. Have you seen them (it was on the 6th of June)?


Angelos Manousaridis

More information about the U-Boot mailing list