Search code examples
u-boot

U-Boot. Where does it all begin?


Newbie question here.

I'm looking at a u-boot boardfile, and it has many functions in it.
For example; board_mmc_init(), enet_board_init(), setup_splash_img(), etc.

Most of these functions don't get called from within the boardfile. They get called from somewhere else. But I can't figure out where.

In Linux kernel boardfiles there's a machine structure. In there we might have .init_machine = myboard_init. Then myboard_init(void) will call other functions which will in turn call other functions. I find this style easy to read.

My question is; does u-boot have an equivalent of .init_machine? Where do I look to see where everything 'starts'? Who calls all those loose functions thrown together inside a u-boot boardfile?


Solution

  • First of first, uboot will start at start.S of the specify CPU, like this: http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/start.S;h=ef62fc83270a327bc7df970f598540f1d7ce0fe2;hb=HEAD

    It will do some stuff like "exception vector" setup, cache setup, etc.

    Then it will jump to http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/lib/crt0.S do some c runtime setup,

    Then it will back to start.S, after some misc stuff, you can refer the comments, it will jump into lowlevel_init.S http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/lowlevel_init.S;h=82b2b86520eb2b2d63c2478145b625a49f931542;hb=HEAD

    Then.. it will going to soc(very common in ARM) init, like this: http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/soc.c

    After soc init finish , it will going to some board relate init, in the board init, it will call some periphery device/driver init.

    Hope that will give your some hit on uboot process.