Info about boot sequence

Discussion about U-Boot and the kernel.

Info about boot sequence

Postby pabloski » Mon Jun 23, 2014 3:55 pm

Hi, I'm trying to understand how the boot sequence works on ARM-based systems. Searching on the net I have found some infos, but they are all too vague.

From what I have found, the typical ARM boot sequence is as follows:

1. on power-on the BootROM ( it is hardcoded into the ASIC ) is executed
2. the BootROM searches for the boot1 stage and try to boot it
3. the boot1 searches for the boot2 stage and try to boot it
4. the boot2 boots the linux/android/whatever kernel

It is a good explanation ( in theory at least ), but what are the implementative details?

For example, on x86 we know the BIOS executes from ROM and it loads and executes the code on the MBR of the HDD.

We can safely assume the BootROM is something like the BIOS ( but it does much less setup work ). Then, where the BootROM goes to find for the boot1 code? Is the boot1 always located on a NAND flash chip? On a NOR SPI chip? On the sdcard? Is there some magic value ( like 55 AA in the case of x86/MBR )? At what location the boot1 must be localized on the boot media?

Then, the boot1 searches for the boot2 code, but where? And the same goes for the boot2/kernel. I have read the boot2 is often U-Boot. So, how does U-Boot knows where to load the kernel from?

Also, I have been playing with some ARM sticks, and I see there is a strange ASCII text file at the head of the NAND flash, a file full of variables and values!!

I understand that the NAND has no partitions ( in the MBR/GPT sense ). The partitions exist only at a logical level in the kernel.

Can someone help me understand how this thing works?

Thanks in advance for the reply.
pabloski
 
Posts: 3
Joined: Mon Jun 23, 2014 3:42 pm

Re: Info about boot sequence

Postby WarheadsSE » Mon Jun 23, 2014 5:04 pm

I can't reply extensively at the time, but roughly:

* Each stage0 (BOM) is highly sepcific to the SoC, and so it the behavior there of
* Most stage1 (SPL) spins up just enough of the chip, in just such a way as to let stage2 be loaded from some form of storage
* Stage2 (U-Boot/fastboot/barebox) then initialize the needed subsystems for accessing whatever the boot media is.

That stuff you have been seeing is a mix of spl/uboot/uboot environment
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Info about boot sequence

Postby pepedog » Mon Jun 23, 2014 5:25 pm

The cubox-I has SPL and uboot on the sd card, so you can experiment safely.
Uboot also runs scripts in zsh environment.
You can see example here https://github.com/SolidRun/u-boot-imx6/blob/imx6/include/configs/mx6_cubox-i.h
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Info about boot sequence

Postby WarheadsSE » Mon Jun 23, 2014 5:32 pm

I thought uboot was using hush, not zsh
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Info about boot sequence

Postby pabloski » Mon Jun 23, 2014 6:19 pm

Thanks for the replies. So the boot sequence follows no standard and it is vendor-specific.

But, what about Android oriented SoCs? Does Google imposes some kind of standard? I see that a lot of ARM sticks, smartphones, tablets, etc... have at least 1 recovery partition, 1 kernel partition, 1 system partition and some other standard partition.
pabloski
 
Posts: 3
Joined: Mon Jun 23, 2014 3:42 pm

Re: Info about boot sequence

Postby pepedog » Mon Jun 23, 2014 6:42 pm

$this->bbcode_second_pass_quote('WarheadsSE', 'I') thought uboot was using hush, not zsh

You might be right, whatever I read was over 2 years ago.

You would have to ask in an android place about android
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Info about boot sequence

Postby WarheadsSE » Mon Jun 23, 2014 7:15 pm

The only "enforcement" is in userland.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Info about boot sequence

Postby pabloski » Mon Jun 23, 2014 8:03 pm

Ok, thanks for the replies. I'm starting to grasp the subtilities of the ARM booting world. I have dumped the partitions on a Rikomagic MK802 IV, a Tronsmart and a Zenithink tablet.

From what I see the number, types and contents of the various partitions are arbitrary. I suppose the informations are hardcoded in the bootloaders stored into the SoC and/or NOR flash ( the Zenithink has the boot1 stage in a flash, the Rk3188 based sticks have it on the ASIC I suppose ).

But now I know that I can play with the content of the NAND flash. For example, the two sticks executes everything I put in the boot partition on the NAND flash. From there it is up to me to decide what to load/execute. The only thing that seems to be somewhat of a standard is the uboot environment variables stored at address 0x00000000 of the NAND. So it seems uboot reads this area to figure out how the NAND is organized. And ( I suppose ) it knows that the last stage bootloader is stored in the boot partition.

It is a very interesting arrangement, but it is a shame there's no standard. Now I understand why Torvalds said "I hope that ARM SoC hardware designers all die in some incredibly painful accident" :lol:
pabloski
 
Posts: 3
Joined: Mon Jun 23, 2014 3:42 pm

Re: Info about boot sequence

Postby WarheadsSE » Mon Jun 23, 2014 11:44 pm

That and the fact that there we > 60 trees of forks.
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm


Return to U-Boot/Kernel

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests