What is the point of Uboot?

Discussions about all user software around SAM Series.

Moderator: nferre

bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

What is the point of Uboot?

Fri Nov 15, 2013 4:24 pm

I'm confused why I would use Uboot instead of AT91Bootstrap. AT91Bootstrap appears to be much lighter and it boots the kernel with no issues. Could someone please explain why people use Uboot?

I've read this: http://www.denx.de/wiki/U-Boot/DesignPrinciples, but I still can't figure out why it's advantageous. Any information would be greatly appreciated.
CptTitanic
Posts: 877
Joined: Sat Oct 30, 2010 6:04 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 12:20 am

In earlier SAM9 chips with only 4 KB or 16 KB of SRAM available, AT91BootStrap had to be rather small, it's primary job being to set up board unique things like SDRAM and peripheral pins, that wouldn't be known to RomBOOT or the ATMEL designers.

Still, if you are booting from NAND you might still be limited to 128 KB or the size of page/block zero.

uBoot offers some useful features like SD Card loading of code, TFTP network downloading, things that are useful for getting 32 MB file system images onto a blank board, or debricking a system, and configuring or selecting kernels and parameters.

It does a lot of useful things a boot loader might need to do, but with all things there are other ways of doing that, and there might be more appropriate ways to solve the problems you have, or features you desire.
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 12:33 am

CptTitanic wrote:In earlier SAM9 chips with only 4 KB or 16 KB of SRAM available, AT91BootStrap had to be rather small, it's primary job being to set up board unique things like SDRAM and peripheral pins, that wouldn't be known to RomBOOT or the ATMEL designers.

Still, if you are booting from NAND you might still be limited to 128 KB or the size of page/block zero.
Why?
uBoot offers some useful features like SD Card loading of code, TFTP network downloading, things that are useful for getting 32 MB file system images onto a blank board, or debricking a system, and configuring or selecting kernels and parameters.
AT91Bootstrap could do all of this as well, right? Is the only reason Uboot is 'better' for these things is because the code already exists to make it happen? I guess I'm asking if there's a hardware based reason to use Uboot instead of AT91Bootstrap. It seems like there isn't.
It does a lot of useful things a boot loader might need to do, but with all things there are other ways of doing that, and there might be more appropriate ways to solve the problems you have, or features you desire.
So if all I need to do is boot from an SD card straight into Linux, there's no real purpose for me to use Uboot, right? I can setup all of pins and peripherals with AT91Bootstrap and then load the kernel.
blue_z
Location: USA
Posts: 1560
Joined: Thu Apr 19, 2007 10:15 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 1:52 am

bandtank wrote:So if all I need to do is boot from an SD card straight into Linux, there's no real purpose for me to use Uboot, right? I can setup all of pins and peripherals with AT91Bootstrap and then load the kernel.
I have worked on an embedded Linux system that did not use U-Boot. But it wasn't ARM, and boot failure/recovery and changing the kernel command line were difficult.

The early versions of AT91SAM SoCs mandated more than a two-stage bootloader scheme because of the limited size of internal SRAM.
If you can accomplish all of the ARM booting requirements for Linux in a 2nd-stage bootloader (you shouldn't call it "AT91Bootstrap" anymore if you're going to drastically change its functionality) for your latest-generation AT91SAM SoC and you can forgo the added features that U-Boot provides, then "yes" you can dispense with a third-stage bootloader and consolidate/collapse 2nd & 3rd stages into one.

Although there are pitfalls. The last time someone got rid of U-Boot about a year ago, they didn't replicate enough U-Boot functionality and so they ran into Ethernet issues.

Regards
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 2:19 am

blue_z wrote:
bandtank wrote:So if all I need to do is boot from an SD card straight into Linux, there's no real purpose for me to use Uboot, right? I can setup all of pins and peripherals with AT91Bootstrap and then load the kernel.
I have worked on an embedded Linux system that did not use U-Boot. But it wasn't ARM, and boot failure/recovery and changing the kernel command line were difficult.

The early versions of AT91SAM SoCs mandated more than a two-stage bootloader scheme because of the limited size of internal SRAM.
If you can accomplish all of the ARM booting requirements for Linux in a 2nd-stage bootloader (you shouldn't call it "AT91Bootstrap" anymore if you're going to drastically change its functionality) for your latest-generation AT91SAM SoC and you can forgo the added features that U-Boot provides, then "yes" you can dispense with a third-stage bootloader and consolidate/collapse 2nd & 3rd stages into one.

Although there are pitfalls. The last time someone got rid of U-Boot about a year ago, they didn't replicate enough U-Boot functionality and so they ran into Ethernet issues.

Regards
I think you may be saying the right things to expose my lack of understanding. Here's what I'm doing:

1) AT91SAM9G25 powers up and checks that BMS = 1, so it tries to read various NVMs
2) Serial/Data flash aren't present, so it lands on the SD card, which is present
3) The ROM bootloader reads AT91Bootstrap (I'm not modifying its capabilities. The only thing I change is the device tree file.)
4) AT91Bootstrap (the second level bootloader, right?) configures pins and peripherals, then boots Linux from another SD card partition

I'm using a first and second level bootloader, right? My confusion is how Uboot would help me in any way because Linux boots just fine using the steps shown above. Once I get into Linux, I should be able to do pretty much everything I need to do with the hardware unless I'm mistaken.
blue_z
Location: USA
Posts: 1560
Joined: Thu Apr 19, 2007 10:15 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 2:33 am

bandtank wrote:3) The ROM bootloader reads AT91Bootstrap (I'm not modifying its capabilities. The only thing I change is the device tree file.)
4) AT91Bootstrap (the second level bootloader, right?) configures pins and peripherals, then boots Linux from another SD card partition
If you want this program to load Linux instead of the next bootloader, then that's a change in functionality.

You seem to be using the phrase "boot Linux" without comprehending what that actually entails.
The older requirements for ARM Linux boot are described here:
http://www.simtec.co.uk/products/SWLINU ... ticle.html
The most up-to-date requirements seem to be in Documentation/arm/Booting.txt.
bandtank wrote:I'm using a first and second level bootloader, right? My confusion is how Uboot would help me in any way because Linux boots just fine using the steps shown above. Once I get into Linux, I should be able to do pretty much everything I need to do with the hardware unless I'm mistaken.
I'm pretty sure I already responded to that concept.

Regards
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 3:10 am

blue_z wrote:If you want this program to load Linux instead of the next bootloader, then that's a change in functionality.

You seem to be using the phrase "boot Linux" without comprehending what that actually entails.
I built AT91Bootstrap, put it on a partition on an SD card, and then built a kernel on another partition. I have nothing else on the SD card, so I don't know how I'm changing the functionality because I didn't modify anything except the device tree. From at91.com: "AT91Bootstrap can be configured and built to download a 3rd level bootloader (U-Boot or barebox for instance) or directly boot the Linux kernel with a Device Tree Binary." That's what I mean when I say booting Linux. I don't know what else it means if the above statement is implying more than starting the kernel.
I'm pretty sure I already responded to that concept.
Ok... I didn't understand, so I asked a follow up question. I just started working with these tools and devices, so subtle inferences are beyond me.
CptTitanic
Posts: 877
Joined: Sat Oct 30, 2010 6:04 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 3:26 am

The utility of uBoot is somewhat mitigated by your use of a removable SD Card. With Blank NAND flash soldered to the board your abilities to inject data are significantly more limited. On the other hand the SD Card is significantly less mechanically robust, so high vibration environments will be problematic.
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 3:40 am

CptTitanic wrote:The utility of uBoot is somewhat mitigated by your use of a removable SD Card. With Blank NAND flash soldered to the board your abilities to inject data are significantly more limited. On the other hand the SD Card is significantly less mechanically robust, so high vibration environments will be problematic.
I see what you mean. So what would you do with blank NAND flash? Can you explain to me how the system would work starting at the ROM bootloader (first level?).
CptTitanic
Posts: 877
Joined: Sat Oct 30, 2010 6:04 pm

Re: What is the point of Uboot?

Sat Nov 16, 2013 6:04 am

You'd push in enough code via JTAG or SAM-BA to get a loader written to block zero of the NAND (guaranteed to work, and RomBOOT can be agnostic to make/model). In the parts I've used this will buy you 128 KB, or whatever the SRAM limits you to. A low rent version of uBoot runs just shy of 256 KB (two blocks), one with SD/FAT support, and diagnostics might run 400 KB. These will need to go in NAND blocks with ECC and bad block skipping.

With uBoot running, and Ethernet support you can TFTP kernel and file system images from a server, and write them out to NAND.

Similar interaction for data-flash
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Tue Nov 19, 2013 5:35 pm

Are you saying AT91Bootstrap isn't present in the scenario you described? Does the ROMBoot first level bootloader find Uboot in NAND after you program it via JTAG/SAM-BA?

I don't understand where you put Uboot if the SRAM can't hold it. Are you saying you write Uboot into NAND flash? Does that mean the NAND flash contains AT91Bootstrap, Uboot, and the kernel?

Man, this is confusing. I've been reading for weeks and I just can't get a handle on how this works.
CptTitanic
Posts: 877
Joined: Sat Oct 30, 2010 6:04 pm

Re: What is the point of Uboot?

Tue Nov 19, 2013 6:27 pm

I'm not sure multi-stage booting is that confusing or complex, I suspect you've just got an addled perspective, or very little experience bringing up systems.

I'm talking about code that the ROM can load and run. The ROM is not good with external RAM, as it has no control over the configuration or geometry. uBoot doesn't set up the memory either, at least not in the model used here, and has historically been too big to fit in internal SRAM.

The ROM is limited to the available internal SRAM, and the size of the first block (zero) in the NAND Flash. Anything the ROM loads must meet the system constraints. These may not be ideal, but you have to work within them.

This is too small to hold any usable semblance of uBoot, but is sufficiently large to write a loader which can use SD cards, NAND, and load a kernel, configuration and file system image into memory.

uBoot solves a lot of things you'd likely spend a lot of time implementing yourself.
bandtank
Posts: 21
Joined: Tue Oct 29, 2013 10:35 pm

Re: What is the point of Uboot?

Tue Nov 19, 2013 7:11 pm

CptTitanic wrote:I'm not sure multi-stage booting is that confusing or complex, I suspect you've just got an addled perspective, or very little experience bringing up systems.
Change that to zero and then we'll be on the same page. I'm not saying the system is broken, but there's extremely little documentation about how this works from a high level. I've been in communication with other people on various forums who have little to no experience with similar confusion, so I know it's not just me. There's a lot of context not present in the explanations on at91.com about how this stuff works. I'm trying my hardest to understand, but missing context takes time and effort to gather.
I'm talking about code that the ROM can load and run. The ROM is not good with external RAM, as it has no control over the configuration or geometry. uBoot doesn't set up the memory either, at least not in the model used here, and has historically been too big to fit in internal SRAM.

The ROM is limited to the available internal SRAM, and the size of the first block (zero) in the NAND Flash. Anything the ROM loads must meet the system constrains. These may not be ideal, but you have to work within them.

This is too small to hold any usable semblance of uBoot, but is sufficiently large to write a loader which can use SD cards, NAND, and load a kernel, configuration and file system image into memory.
Ok, I'm going to try to put some more low level words in here to see if I have it. I understand the relationship between ROMBoot and BMS, so with BMS = 1, ROMBoot will start looking at multiple interfaces to see if it can find a valid bootloader. AT91Bootstrap would need to be used since Uboot won't fit in internal SRAM or NAND page zero. Assuming I've already used SAM-BA to put AT91Bootstrap in NAND page zero, ROMBoot will find it and load it into internal SRAM. Once loaded, it will execute and setup external RAM, peripherals, clocks, etc. that either the kernel or a third stage bootloader can use.

I think a big part of my confusion is that I don't understand where these things live once they're 'loaded' by the bootloaders. I found a diagram of an example NAND memory map that shows AT91Bootstrap, Uboot, the device tree binary, a kernel, and a rootfs on the same NAND flash. That's where I stumble.

I definitely don't understand what happens next, so I'm going to just have to continue reading and using my example board. It's not clear to me how I should construct my board with the various pieces of available hardware: serial flash, NAND flash, SD cards, etc. Basically, I want to put a bootloader somewhere permanent and be able to remotely update everything else. I picked an SD card because I can put everything on it: kernel, dtb, rootfs, and swap. I don't necessarily want to use an SD card, though, for various reasons. My lack of understanding for how to put all of those things in other places and how they can be booted leaves me puzzled and unsure of how to proceed.

Thanks for the help. I'll eventually figure this out.
CptTitanic
Posts: 877
Joined: Sat Oct 30, 2010 6:04 pm

Re: What is the point of Uboot?

Tue Nov 19, 2013 7:44 pm

Yes, I think you're on the right track.

I'd suggest the job of the ROM is to bring in "A Loader", not specifically AT91BootStrap which is one possible implementation.

The data on NAND doesn't physically exist in the memory space of the processor, think of it as a hard drive, content must be loaded into RAM to be executed.

After each of the loaders runs it transfers control to the next and is discarded. They don't live anywhere, you have storage locations carved out for them in your non-volatile storage device. ie NAND, SDCARD, Hard Disk, etc

The ROM loads code into SRAM, the loader in SRAM brings up the SDRAM/DDR and loads code there, then the loader in SDRAM brings in the kernel, etc.

There placement in memory is controlled by the AT91SAM's memory map. Within SDRAM you get to choose where you want to place things, you typically know how large it is, that it's all free to use, and if you need to make any accommodations for any next or prior stages. ie you pick a location to put code, and any parameters you might want to furnish to other stages. You have a plan/contract.

Think of it like stages of a rocket (Saturn V), once each stage has burned it falls away, and the rest of the craft moves on.

BMS controls whether the internal ROM is used, or an external ROM/EPROM/NOR is used. These devices would permit direct execution of code, but tend to have high pin counts, are small, and expensive. If you were a huge customer you could create your own loader ROM, and have ATMEL fabricate devices with that. You'd have to do a similar thing if you created your own SoC.

Return to “Software”

Who is online

Users browsing this forum: No registered users and 1 guest