
Wolfgang Denk wrote:
The problem is that I don't want to see any such hard-coded sizes. What I want is documented in the (very old!) "System Initialization" section in the README: we may have to configure for a maximum size, but except from that, U-Boot should auto-adjust to different seizes of RAM and flash memory.
If I knew how to auto-adjust, I would have coded it that way. To my knowledge, there is no generic way to query to amount of flash on the system when the code in start.S is being run. The flash configuration code (e.g. flash_init()) is executed much later in the boot process.
What exactly is the meaning of CFG_FLASH_SIZE in your code?
It is the size of flash, in megabytes.
Is this a _maximum_ size which is supported by this board configuration, or the exact size that must be presen on the board?
The maximum size. The value is used to program LBLAWAR1, so it determines the size of the memory window. I'm not expert on these things, but I presume that the window determines what memory can be accessed. That is, if you have 16MB of flash, but you program the window to be 8MB, then you will not be able to access the upper half of flash.
This issue becomes interesting when it's the other way around - 8MB of flash, and the window is 16MB. In most cases, I believe this is mostly harmless.
So one suggested to me a while back that I should just program LBLAWAR1 to 16MB for everyone. But then what do I do if a new system comes out with 32MB of flash? Or more? LBLAWAR1 supports up to 2GB of flash.
So I decided to make it board configurable. If your board has multiple variations, such as some boards with 8MB and some with 16MB, and it's okay to program LBLAWAR1 to 16MB for all these boards, then by all means, set CFG_FLASH_SIZE to 16 and you're finished.
If the board comes with a different flash size, what will the U-Boot start messages report, and what size will be actually mapped once U-Boot enters interactive mode?
U-Boot will report whatever flash_init() says, which is typically calculated by querying the hardware.