[U-Boot] RFC: Aligning arch initialisation sequences

Wolfgang Denk wd at denx.de
Sun Nov 14 01:07:58 CET 2010


Dear Reinhard Meyer,

In message <4CDF15BB.1090107 at emk-elektronik.de> you wrote:
> 
> >> Correct, that's why its even now copied over to storage in SDRAM...
> >> (at least on ARM:
> >> 	debug ("relocation Offset is: %08lx\n", gd->reloc_off);
> >> 	memcpy (id, (void *)gd, sizeof (gd_t));
> >>
> >> 	relocate_code (addr_sp, id, addr);
> >> )
> >
> > At this time board_early_init_f() has terminated long ago, i. e. the
> > data is not available any more.
> 
> Above code is *IN* board_early_init_f !

That's totally broken, then.

See init_sequence[] in "arch/arm/lib/board.c":

239 init_fnc_t *init_sequence[] = {
240 #if defined(CONFIG_ARCH_CPU_INIT)
241         arch_cpu_init,          /* basic arch cpu dependent setup */
242 #endif
243 #if defined(CONFIG_BOARD_EARLY_INIT_F)
244         board_early_init_f,
245 #endif
246         timer_init,             /* initialize timer */
247 #ifdef CONFIG_FSL_ESDHC
248         get_clocks,
249 #endif
250         env_init,               /* initialize environment */
251         init_baudrate,          /* initialze baudrate settings */
252         serial_init,            /* serial communications setup */
253         console_init_f,         /* stage 1 init of console */
254         display_banner,         /* say that we are here */
255 #if defined(CONFIG_DISPLAY_CPUINFO)
256         print_cpuinfo,          /* display cpu info (and speed) */
257 #endif
258 #if defined(CONFIG_DISPLAY_BOARDINFO)
259         checkboard,             /* display board info */
260 #endif
261 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
262         init_func_i2c,
263 #endif
264         dram_init,              /* configure available RAM banks */
265 #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
266         arm_pci_init,
267 #endif
268         NULL,
269 };

board_early_init_f() [in line 244] runs a long, long time before the
SDRAM has been tested and initialized, which happens in dram_init()
[in line 264].

You cannot and must not touch SDRAM in board_early_init_f(). And even
more, you must not at all run relocate_code() there!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Fools ignore complexity. Pragmatists suffer it. Some  can  avoid  it.
Geniuses remove it.
     - Perlis's Programming Proverb #58, SIGPLAN Notices, Sept.  1982


More information about the U-Boot mailing list