
On 03/08/2011 09:36, Hong Xu wrote:
Hi Reinhard,
On 08/03/2011 03:20 PM, Reinhard Meyer wrote:
Dear Hong Xu,
When env_init is called, the SPI is not actually initialized in U-Boot. So that we can not read Dataflash for its content. We simply mark it OK for now, and defer the real work to `env_relocate_spec'. (Idealy from env_nand.c)
Signed-off-by: Hong Xuhong.xu@atmel.com
common/env_dataflash.c | 83
++++++++++++++++++++++++++----------------------
1 files changed, 45 insertions(+), 38 deletions(-)
I cannot really decide if that is a good approach. Where would be the issue if SPI/dataflash were initialized at this point (before relocation)?
Currently the SPI is initialized in board_init which is called in board_init_r, but env_init is called in board_init_f. So actually the original code needs the SPI to be initialized before env_init, not before relocation.
An alternative way is to put SPI initialization code in board_early_init_f. But I'm not sure if it's the correct way.
I guess this is a general issue: if some driver is needed to get access to environment, then it must be initialized before relocation. But not all boards need initialization this early, and conversively, for each board-specific case where environment reading requires driver X, this adds a *general* constraint of initializing X before relocation -- and we'll end up initializing just about anything before reloc on boards that do not actually need initializations this early.
Now this may not be feasible, but I think the idea is more "initialize what is needed for relocation, then relocate, then initialize the rest.
Does anyone else here see this problem as I see it, or am I just being over-nit-picking?
If it *is* a problem, then the only way I see to solve this is, for each driver that *might* be initialized before reloc, to provide a configuration option to select between initializing before or after relocation (possibly with variations in the driver initialization code based on this config option).
Or am I also over-engineering here?
Amicalement,