From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Sun, 14 Nov 2010 11:25:47 +1100 Subject: [U-Boot] RFC: Aligning arch initialisation sequences In-Reply-To: <20101114000758.51B6ED302CB@gemini.denx.de> References: <4CD67A22.9040802@gmail.com> <201011091835.38581.vapier@gentoo.org> <4CDE1107.80108@gmail.com> <4CDE30CF.9010509@emk-elektronik.de> <20101113081712.C5D85150ADD@gemini.denx.de> <4CDF04A8.4050802@emk-elektronik.de> <20101113215302.6BEA3CEA55B@gemini.denx.de> <4CDF137E.2000902@emk-elektronik.de> <20101113224554.64D72CEA55B@gemini.denx.de> <4CDF15BB.1090107@emk-elektronik.de> <20101114000758.51B6ED302CB@gemini.denx.de> Message-ID: <4CDF2C8B.3060401@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 14/11/10 11:07, Wolfgang Denk wrote: > Dear Reinhard Meyer, > > In message <4CDF15BB.1090107@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": > > 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! > See: arch/powerpc/lib/board.c arch/m68k/lib/board.c arch/arm/lib/board.c They all malloc the final global data structure, memcpy the temporary global data to the malloc'd global data, and call relocate_code passing a pointer to the new global data all at the very end board_init_f() and therefore after SDRAM has been initialised Regards, Graeme