[U-Boot] U-Boot and The Boot Loader Specification

Alexander Dahl ada at thorsis.com
Fri Oct 19 08:17:27 UTC 2018


Hello,

Am Freitag, 19. Oktober 2018, 08:53:15 CEST schrieb Wolfgang Denk:
> In message <2092760.TlMJupW03t at ada> you wrote:
> > I played with the extlinux.conf format snippets from the U-Boot docs.
> > Upstream extlinux docs are not really helpful, especially not for options
> > regarding dtb> 
> > files. And I tried a config based on the Boot Loader Spec:
> > 	Scanning mmc 2:1...
> > 	Found /boot/extlinux/extlinux.conf
> > 	Retrieving file: /boot/extlinux/extlinux.conf
> > 	366 bytes read in 268 ms (1000 Bytes/s)
> > 	Ignoring unknown command: title
> > 	Ignoring unknown command: version
> > 	Ignoring unknown command: options
> > 	Ignoring unknown command: linux
> > 	Ignoring unknown command: devicetree
> > 
> > Am I right, U-Boot does not support that spec at all? Files are in
> > different positions, and the keywords are all different? If so, then the
> > U-Boot documentation is misleading (and people will be frustrated to
> > follow the hints given in there).
> 
> It would definitely help if you tell us which actual command
> (sequence) you used to get this output, and what the exact content
> of this extlinux.conf was.

Okay first the content of /boot/extlinux/extlinux.conf from the root 
filesystem, which does not work (of course without additional linebreaks from 
my mail client):

title          PTXdist
version                4.9.133
options                mtdparts=gpmi-nand:8M(fcb),7M(reserved)ro,512k(env1),
512k(env2),-(fs) ubi.mtd=fs console=ttymxc0,115200 rootwait rw root=/dev/
mmcblk0p1
linux          /boot/zImage
devicetree     /boot/imx6dl-ttcore.dtb

As you might guess, I use ptxdist for building the BSP for an i.MX6 based 
platform. Currently everything is on a SD-Card and the system can boot from 
that card, if I load kernel image and dtb manually in U-Boot (or use another 
extlinux.conf).

> Without such information, we cannot even guess what you did.

I was basically following the instructions from doc/README.distro so I read 
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ as mentioned in 
section "Boot Configuration Files" and set CONFIG_DISTRO_DEFAULTS=y and added 
the following to the board configuration header file in include/configs/

/*  PHYS_ADDR is 0x10000000 for i.MX6S,
 *  Kernel doc recommends to put dtb at 128 MiB, zImage above 32 MiB,
 *  but below 128 MiB. So we put them there and scriptaddr after dtb.
 *  We don't strictly need ramdisk_addr_r, but just set it to some
 *  reasonable value according to doc/README.distro …
 *  This should not collide with U-Boot which places itself at the
 *  lowest 8k and something around 8 MB at the top of the memory, the
 *  board currently has 512 MiB.    */
#define MEM_LAYOUT_ENV_SETTINGS \
        "kernel_addr_r=0x12000000\0" \
        "fdt_addr_r=0x18000000\0" \
        "scriptaddr=0x18100000\0" \
        "pxefile_addr_r=0x18200000\0" \
        "ramdisk_addr_r=0x18300000\0"

#define BOOT_TARGET_DEVICES(func) \
        func(MMC, mmc, 0) \
        func(MMC, mmc, 1) \
        func(MMC, mmc, 2) \
        func(UBIFS, ubifs, 0) \
        func(USB, usb, 0)

#ifndef CONFIG_SPL_BUILD
#include <config_distro_defaults.h>
#include <config_distro_bootcmd.h>
#endif

So in U-Boot env the following is set (this is populated by U-Boot itself by 
default, I removed non interesting lines and added some linebreaks):

boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} $
{prefix}${script}; source ${scriptaddr}

boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any $
{scriptaddr} ${prefix}extlinux/extlinux.conf

boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc0 mmc1 mmc2 ubifs0 usb0 
bootcmd=run distro_bootcmd
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_mmc2=setenv devnum 2; run mmc_boot
bootcmd_ubifs0=setenv devnum 0; run ubifs_boot
bootcmd_usb0=setenv devnum 0; run usb_boot
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run 
scan_dev_for_boot_part; fi
pxefile_addr_r=0x18200000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; 
for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run 
scan_dev_for_scripts; done;

scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env 
exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do 
if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run 
scan_dev_for_boot; fi; done

scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} $
{prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/
extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi

scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} $
{devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script 
${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; 
done


What happens is what I wrote in the first mail. extlinux.conf is found and 
'sysboot' fails because it ignores all the keywords.

What actually works is using an extlinux.conf similar to the examples in doc/
README.distro, but there are two things to mention:

1) keywords are used which are not mentioned in the upstream extlinux 
documentation
2) keywords from the bootloader spec don't work at all

So, although the idea to have a config file in the Linux filesystem an let the 
distribution set things in it, might be the same as in the Boot Loader 
Specification, my impression is, U-Boot does not follow the specification. 
Neither does it support multiple files (just /boot/extlinux/extlinux.conf 
works) nor the keywords specified?

An extlinux.conf that works is this:

label   PTXdist
  kernel    /boot/zImage
  fdtdir    /boot
  append    mtdparts=gpmi-nand:8M(fcb),7M(reserved)ro,512k(env1),512k(env2),-
(UBI) ubi.mtd=UBI console=ttymxc0,115200 rootwait rw root=/dev/mmcblk0p1

I have to add, I currently still use U-Boot 2016.09, but I did a thorough 
research in master and the responsible code in cmd/pxe.c did not change from a 
functional point of view since 2016.09.

Greets
Alex


More information about the U-Boot mailing list