I'm reading a book (Mastering Embedded Linux Programming, 2nd ed). In the chapter on bootloaders it explains the booting process with U-Boot and with UEFI firmware.
It looks like the booting steps are exactly the same, with exception that at the last step either U-Boot or UEFI firmware takes over and loads a Linux image in RAM.
So what is the exact difference? Why would one choose U-Boot over UEFI or vica versa?
32 Answers
The UEFI specification describes an API that a firmware may expose. This API can be used by applications and drivers loaded by the firmware.
The open source firmware Das U-Boot contains a partial implementation of the UEFI specification. A complete open source implementation is offered by TianoCore EDK II. Companies like Phoenix offer closed source UEFI firmware.
On the 64-bit ARM architecture the Linux distributions Suse and Fedora use U-Boot to load GRUB as a UEFI application from U-Boot which in turn loads and starts the Linux kernel via UEFI API calls. Linux itself has an UEFI stub so it can be started as a UEFI application.
The UEFI specification defines a runtime that stays in memory until the system is rebooted. The UEFI runtime offers services including changing UEFI variables, uploading new firmware, and rebooting the system. Compliant to the UEFI specification U-Boot also contains a UEFI runtime. But as of today the functionality is limited to rebooting the system.
The biggest difference is that UEFI is essentially an operating system, while U-Boot is just a bootloader. U-Boot does just enough to make the system bootable and provides a bit extra to simplify debugging of the boot problems. UEFI on the other hand provides a large set of runtime API's that make MS-DOS seem simple by comparison, and unlike U-Boot, which largely gets out of your way once it's handed off execution, UEFI sticks around.
Beyond that, there are licensing differences (U-Boot is a bit more open than UEFI), file format differences (U-Boot uses a custom, minimalistic image file format, UEFI uses PE32+ executables), and differences in the actual state of the system at the execution handoff, and the means of configuration (UEFI often has integrated firmware configuration options, while U-Boot typically requires rebuilding the firmware and re-flashing it).
3