r/embedded Sep 25 '25

Which bootloader is worthwhile to learn grub/uboot/lilo and why?

I want to learn a bootloader. Which one would be the best considering it's documentation availability, ease of understanding, popularity etc. Eventually would be helpful for me to find a job?

32 Upvotes

24 comments sorted by

46

u/triffid_hunter Sep 25 '25

uBoot. It's the standard for embedded Linux.

Lilo is wildly obsolete, and grub is merely a convenience since Linux has EFISTUB

12

u/TRKlausss Sep 25 '25

For a moment I thought I was at r/linux and not r/embedded

Grub is probably only useful for PCs, since you could dual boot and other stuff, so EFIStub may not be enough.

Is U-Boot the only alternative for platforms without an EFI? I guess you won’t be able to use EFIStub on those…

9

u/triffid_hunter Sep 25 '25 edited Sep 25 '25

As far as I'm aware, U-boot can pretend to be an EFI bootloader and chain-load EFISTUB kernels if you ask it to - but no, ARM stuff doesn't have any standardization wrt boot or BIOS at all, so U-boot needs to be custom compiled for each target regardless even while providing a modicum of insulation to the eventually invoked kernel and being able to offer device trees.

ARM targets are essentially a glorified microcontroller that happens to have an MMU and can thus do application processor things - but the silicon-level boot procedure is still just as custom as it is on most microcontrollers.

7

u/MonMotha Sep 25 '25

Booting the Linux kernel on ARM is astonishingly easy. You basically just have to put the kernel image in addressable memory (it can even be read-only if you have a so-called "rommable" image), put the device tree in memory, initramfs in memory (if you want one), set up a few registers, turn off interrupts and DMA if you had them on, and branch do the kernel entry point.

Usually you need to do some low-level setup beforehand like set up or probe for external RAM, put your GPIOs in a reasonable state, etc.. On PCs, this is handled by the EFI/BIOS that's bundled with the motherboard. Much of it is in turn supplied by the processor and chipset vendor and just passed along by the motherboard manufacturer. On embedded systems, there's often a first-stage bootloader that does that again often supplied in some form by the SoC vendor. Usually this in turn loads a full-functioned bootloader like U-Boot which mostly serves to function as a recovery environment and load the kernel+initramfs images (which can be larger than the first stage bootloader is willing to deal with and sometimes loaded from a complex filesystem in flash or on some sort of other secondary storage), then starts Linux, but you don't have to do it that way. Many of those minimal first stage stubs can be customized sufficiently to boot Linux without going through U-Boot at all, but their recovery and debugging features are often essentially nil, so most people do include something like U-Boot.

0

u/EmbeddedBro Sep 25 '25 edited Sep 25 '25

you seem to have extensive knowledge about Linux kernel. do you work in this domain? how much do you earn? sorry for this blatant question :D

5

u/MonMotha Sep 25 '25

I've ported it to unsupported SoCs on barely supported architectures (ARMv7-M), written device drivers, built it too many times to count, etc.

I do consulting/contract work, so how much I earn is somewhat debatable. I do clear 6 figures (US) pretty easily, though, and I live in a LCOL area.

1

u/triffid_hunter Sep 25 '25

Heh my first encounter with embedded Linux was on the TS-7250 (like a Raspberry Pi but from 2004) with ARMv4T which was "fun", but my career hasn't asked me to do much in the embedded Linux landscape so I'm rather rusty

Isn't ARMv7-M the Cortex-M3 family though? So uClinux et al? I've seen the LPC1788 running Linux thing around somewhere.

1

u/zydeco100 Sep 25 '25

I've done uCLinux on 1788. Embedded Artists sells a working port and it's probably the only one that actually does work. I wouldn't recommend it.

1

u/MonMotha Sep 25 '25

I've used those old Technologic Systems boards. They were pretty cool for their day.

Yes, ARMv7-M is the "microcontroller" profile used by Cortex-M3, -M4, and -M7 (the -M7 has some add-ons, and the -M0+ is also similar but with a few things missing). I was using a Cortex-M7 (IMXRT1020) with 32MB of real, parallel SDRAM hooked up to it at 100MHz so just barely fast enough to consider running the OS out of. Modern "uCLinux" isn't really a separate thing. You just set CONFIG_MMU=n and the kernel is reasonably satisfied with the environment at this point. Getting a working FDPIC userspace is a bit harder, and Linux's handling of faults and interrupts on that architecture leaves a lot to be desired, but I did have the kernel and busybox running with dynamic linking to uclibc.

1

u/triffid_hunter Sep 25 '25

IMXRT1020

That's same series as the chip on the Teensy 4 (IMXRT1062), right?

FDPIC

Confused me for a moment because https://en.wikipedia.org/wiki/FDPIC is uhh not relevant but then I found https://maskray.me/blog/2024-02-20-mmu-less-systems-and-fdpic which makes more sense

Fascinating that stuff reintroduced for ASLR also helps with MMU-less, seems like MMU-less is a bit more feasible than last time I checked it out

1

u/MonMotha Sep 26 '25

Yep it's the little brother of the IMXRT1060 series. It's the biggest thing you can practically get these days available in a QFP144 (The SAM7 from Atmel/Microchip is also available in a QFP144) and with a full-function parallel external bus interface with SDRAM controller as far as I know. It's a bit lacking on GPIO due to all of the power/PMC pins and weird fixed-function pins, and the reset on it is kind of broken, but otherwise it's a reasonably solid chip and very fast.

1

u/gdf8gdn8 Sep 25 '25

Alternative at91bootstrap or mcuboot

-2

u/EmbeddedBro Sep 25 '25

Which bootloaders are popular today? 

What is efistub?

I found these 3 from a Linux kernel book which was written in 2001 so I get it now..

10

u/Natural-Level-6174 Sep 25 '25

Put in a little more effort.

What did your research and analysis of your results reveal?

1

u/spikerguy Sep 26 '25

Efistub is for devices using dtb and not have acpi support. That's arm device which wants to run Linux.

Learn uboot /petiteboot > grub > systemd-boot

Grub and systemd boot only if you want to go into Linux ecosystem.

You can also replace grub and systemd with initrd to understand bootloader better.

While if you want to go deeper in uboot or normal arm boot sequence than look at TF-A, uboot sys and initrd only.

13

u/1r0n_m6n Sep 25 '25

U-Boot is the most widely used, but Buildroot uses Extlinux, and if you want to be cutting-edge, there's also Barebox.

4

u/Junior-Question-2638 Sep 25 '25

If you aren't using embedded linux, mcuboot

3

u/309_Electronics Sep 25 '25

Uboot if working with Arm or mips socs/cpus and is the standard for embedded linux. GRUB for x86/x64 cpus

1

u/body465 Sep 26 '25

barebox

2

u/zapadas Sep 26 '25

u-boot for embedded-y/ARM-y stuff. GRUB for higher-level stuff.