Skip to contentSkip to conversation

how does board_init_f() -> board_init_r?

U-Boot quantumlight 3 participants 4 messages Feb 14, 2016 – Feb 17, 2016

lore
Share & tools
lore
#0 lore raw

I am trying to modify the bootloader code for NVIDIA's jetson board.

So I am looking at crt0.S. It seems that two builds happen, one with CONFIG_SPL_BUILD and one without. So you end up with two file, u-boot.bin and spl/u-boot-spl.bin.

However, I am unable to find the code path that calls board_init_r() after board_init_f() finishes, although there are several candidates:

1) crt0.S - if CONFIG_SPL_BUILD was not defined, then it would fall straight through to board_init_r() - HOWEVER, for u-boot.bin, isn't CONFIG_SPL_BUILD defined in autoconf.h? Or is this some clever magic between how u-boot.bin and spl/u-boot-spl.bin are stitched together?
2) _weak board_init_f in arch/arm/lib/spl.c - HOWEVER, shouldn't this be overloaded by board_init_f in common/board_f.c?
3) board_init_f_r in common/board_f.c - HOWEVER, nothing calls board_init_f_r().

Can someone illuminate me on how this happens?

--
View this message in context: http://u-boot.10912.n7.nabble.com/how-does-board-init-f-board-init-r-tp245816.html
Sent from the U-Boot mailing list archive at Nabble.com.

#1 lore raw

+Stephen who will know more

Hi,

Quoted 5 lines · quantumlight

I am trying to modify the bootloader code for NVIDIA's jetson board.

So I am looking at crt0.S. It seems that two builds happen, one with CONFIG_SPL_BUILD and one without. So you end up with two file, u-boot.bin and spl/u-boot-spl.bin.

SPL is built with ARMv4t
U-Boot proper is built with ARMv7

That's why SPL is used on Tegra. The SPL does not actually load U-Boot. In fact both are bundle together and loaded at the same time. SPL simply jumps to U-Boot when needed.

Quoted 8 lines

However, I am unable to find the code path that calls board_init_r() after board_init_f() finishes, although there are several candidates:

1) crt0.S - if CONFIG_SPL_BUILD was not defined, then it would fall straight through to board_init_r() - HOWEVER, for u-boot.bin, isn't CONFIG_SPL_BUILD defined in autoconf.h? Or is this some clever magic between how u-boot.bin and spl/u-boot-spl.bin are stitched together?

For U-Boot, CONFIG_SPL_BUILD is not defined. That define means you are building SPL.

The clever magic is mostly 'cat'. SPL is padded a little and then U-Boot is added on the end.

Quoted 2 lines

2) _weak board_init_f in arch/arm/lib/spl.c - HOWEVER, shouldn't this be overloaded by board_init_f in common/board_f.c?

The latter is only used in U-Boot proper. SPL has its own board_init_f().

Quoted 2 lines

3) board_init_f_r in common/board_f.c - HOWEVER, nothing calls board_init_f_r().

No, that is not used on ARM.

Quoted 3 lines

Can someone illuminate me on how this happens?

See the README under Board Initialisation Flow. In brief, the link between board_init_f() and board_init_r() is generally the crt0.S that you found. The catch is that some boards don't implement board_init_f() in SPL, and so use the weak one, which in fact calls board_init_r() directly.

See also arch/arm/mach-tegra/board.c which I think contains the code to jump to SPL.

Regards,
Simon

#2 lore raw
Quoted 11 lines · Simon Glass

+Stephen who will know more

Hi,

Quoted 5 lines · quantumlight

I am trying to modify the bootloader code for NVIDIA's jetson board.

So I am looking at crt0.S. It seems that two builds happen, one with CONFIG_SPL_BUILD and one without. So you end up with two file, u-boot.bin and spl/u-boot-spl.bin.

Quoted 6 lines

SPL is built with ARMv4t
U-Boot proper is built with ARMv7

That's why SPL is used on Tegra. The SPL does not actually load U-Boot. In fact both are bundle together and loaded at the same time. SPL simply jumps to U-Boot when needed.

There's some more background on this topic at:

ftp://download.nvidia.com/tegra-public-appnotes/index.html

In particular, see the "Tegra Boot Flow" link/document.

author
#3 lore raw

Oh I see. Thanks.

Quoted 30 lines · Stephen Warren
Quoted 14 lines · Simon Glass

+Stephen who will know more

Hi,

Quoted 6 lines · quantumlight

I am trying to modify the bootloader code for NVIDIA's jetson board.

So I am looking at crt0.S. It seems that two builds happen, one with CONFIG_SPL_BUILD and one without. So you end up with two file, u-boot.bin and spl/u-boot-spl.bin.

Quoted 7 lines

SPL is built with ARMv4t
U-Boot proper is built with ARMv7

That's why SPL is used on Tegra. The SPL does not actually load U-Boot. In fact both are bundle together and loaded at the same time. SPL simply jumps to U-Boot when needed.

There's some more background on this topic at:

ftp://download.nvidia.com/tegra-public-appnotes/index.html

In particular, see the "Tegra Boot Flow" link/document.