Hi Sam, On Sat, Apr 15, 2017 at 11:50:42PM +0200, Sam Ravnborg wrote: > Hi Andrey. > > While trying to port my proprietary at91sam9263 based board > I have stumbled over how the early init works. > And so far I have used at91sam9x5ek as reference. > > If I follow the code paths for sam9x5 it looks like this: > > barebox_arm_head (arch/arm/include/asm/barebox-arm-head.h) > _barebox_arm_head > b barebox_arm_reset_vector --> > > barebox_arm_reset_vector (arch/arm/mach-at91/at91sam9x5_lowlevel_init.c) > arm_cpu_lowlevel_init > arm_setup_stack(AT91SAM9X5_SRAM_BASE + AT91SAM9X5_SRAM_SIZE - 16); > barebox_arm_entry --> barebox_arm_reset_vector is unused for multi image support. > > barebox_arm_entry (arch/arm/cpu/entry.c) > arm_setup_stack(arm_mem_stack_top(membase, membase + memsize) - 16); > arm_early_mmu_cache_invalidate > barebox_{multi,single,non}_pbl_start > > And then we have: > ENTRY_FUNCTION(start_at91sam9x5ek, r0, r1, r2) (arch/arm/boards/at91sam9x5ek/lowlevel.c) > arm_cpu_lowlevel_init > arm_setup_stack(AT91SAM9X5_SRAM_BASE + AT91SAM9X5_SRAM_SIZE - 16); > barebox_arm_entry > > > And something in this confuses me... > I know at91sam9x5 is built for multi image support. > Which is why start_at91sam9x5ek() is referenced in images/Makefile.at91 > > But why do we need to call arm_setup_stack() in three different places. > And with different parameters. > And arm_cpu_lowlevel_init is called from two places. > > Can someone shed some light on this. Ultimately we want to have the stack somehwere at the end of the SDRAM. However, during early init there might be no SDRAM available, so the stack is configured into internal SRAM. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox