Skip to content
ckuethe edited this page Jan 12, 2015 · 15 revisions

uBoot is the boot-loader used to do some initial hardware setup, load more executable code (ie. Linux), and transfer control to it. uBoot supports many different devices, and it is necessary to compile a binary for each board type in use. The USB Armory strongly resembles mx53loco; to use uBoot under QEMU, compile for vexpress_ca9x4.

You may wish to keep multiple kernels on disk; in this example the `uname_r` environment variable is used to select the kernel to boot:

mmcinfo
ext2ls mmc 0:1 /boot

setenv bootdelay 5
setenv bootargs 'console=ttymxc0,115200 root=/dev/mmcblk0p1 rootwait rw panic=5'
setenv bootcmd 'ext2load mmc 0:1 0x70800000 /boot/${uname_r}/uImage; ext2load mmc 0:1 0x71000000 /boot/${uname_r}/imx53-usbarmory.dtb; bootm 0x70800000 - 0x71000000'
saveenv

setenv bootargs "${bootargs} ${bootargs_disk} ${bootargs_debug}"

boot

It is possible to load a kernel over the Serial Console using the xmodem or ymodem protocols. Below is an example.

=> loady 0x71000000
## Ready for binary (ymodem) download to 0x71000000 at 115200 bps...
C146(SOH)/0(STX)/0(CAN) packets, 5 retries
## Total Size      = 0x000047b1 = 18353 Bytes
=> loady 0x70800000
## Ready for binary (ymodem) download to 0x70800000 at 115200 bps...
C 15034(SOH)/0(STX)/0(CAN) packets, 4 retries
## Total Size      = 0x001d5bd8 = 1924056 Bytes
=> boot
## Booting kernel from Legacy Image at 70800000 ...
   Image Name:   Linux-3.18.0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1923992 Bytes = 1.8 MiB
   Load Address: 70008000
   Entry Point:  70008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 71000000
   Booting using the fdt blob at 0x71000000
   Loading Kernel Image ... OK
   Loading Device Tree to 8f566000, end 8f56d7b0 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 3.18.0 (ckuethe@ambiflex) (gcc version 4.9.1 (Ubuntu/Linaro 4.9.1-16ubuntu6) ) #1 PREEMPT Sat Dec 13 13:37:37 PST 2014
CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Inverse Path USB Armory
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 root=/dev/mmcblk0p1 rootwait rw
...

uBoot's env tools now support reading and writing settings from MMC; a suitable version of fw_printenv can be cross compiled with `env ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make env`. The resulting `fw_printenv` tool can be copied into userland and symlinked to `fw_setenv`; buildroot does this correctly. This is the required configuration file

root@usbarmory:~# cat /etc/fw_env.config 
# Device name    NVRAM offset    Env. size
/dev/mmcblk0     0x60000         0x2000

Note: NVRAM size and offset may change with future versions of u-Boot to allow for more features and a larger environment.

TODO: figure out how to put immutable kernel args into a signed FDT blob... something about a "chosen" section?

  • http://www.denx.de/wiki/DULG/UBootCmdFDT
  • https://www.kernel.org/doc/Documentation/devicetree/usage-model.txt
  • http://xillybus.com/tutorials/device-tree-zynq-2
Clone this wiki locally