Standalone boot (BXELK)

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
BORA Xpress.png Applies to BORA Xpress

History

Version Date BXELK version Hardware Part Nr Notes
1.0.0 December 2016 BXELK 1.0.0 DBXF4110D2R
EVBBX0000C0R

Introduction

This document has been written and tested with the software/hardware combination described in the history table above. However it contains general concept that can be adapted on any DAVE Embedded Systems' Linux platform.

We'll explain how to program and configure a to boot in standalone mode, without the need of a system microSD card or a NFS server, with two options:

  • booting with NOR + NAND
    • U-Boot will fetch and program PL bitstream and then fetch Linux kernel binary images (kernel + device tree) from on-board NOR flash memory, while later the OS will mount the root file system from a NAND partition.

Program root file system in NAND flash

This is a common step for both booting options.

  • Boot the system via SD or NFS as described into the System boot and recovery via microSD card and Booting the system via NFS
  • By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for FSBL, U-boot and kernel images. Here we won't modify this default configuration. The MTD partitions can be dumped with /proc/mtd (the partition's name should be self-explanatory)


root@bora:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "nand-SPL"
mtd1: 00080000 00020000 "nand-uboot"
mtd2: 00040000 00020000 "nand-uboot-env1"
mtd3: 00040000 00020000 "nand-uboot-env2"
mtd4: 00440000 00020000 "nand-bitstream"
mtd5: 00040000 00020000 "nand-device-tree"
mtd6: 00400000 00020000 "nand-linux"
mtd7: 1f600000 00020000 "nand-rootfs"


200px-Emblem-important.svg.png Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside /proc/mtd to match your specific layout 200px-Emblem-important.svg.png


  • Format and initialize nand-ubi partition, which in our case is mtd7, using UBI with:
ubiformat /dev/mtd7
ubiattach -m 7
ubimkvol /dev/ubi0 -N rootfs -m

E.g.

root@bora:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 526385152 bytes (502.0 MiB), 4016 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 4015 -- 100 % complete
ubiformat: 4016 eraseblocks have valid erase counter, mean value is 2
ubiformat: formatting eraseblock 4015 -- 100 % complete
root@bora:~# ubiattach -m 7
[   95.732434] UBI: attaching mtd7 to ubi0
[  100.930047] UBI: scanning is finished
[  100.954932] UBI: attached mtd7 (name "nand-rootfs", size 502 MiB) to ubi0
[  100.961772] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  100.968534] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[  100.975248] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
[  100.982129] UBI: good PEBs: 4016, bad PEBs: 0, corrupted PEBs: 0
[  100.988100] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
[  100.995271] UBI: max/mean erase counter: 4/3, WL threshold: 4096, image sequence number: 1955579947
[  101.004308] UBI: available PEBs: 3852, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
[  101.013959] UBI: background thread "ubi_bgt0d" started, PID 913
UBI device number 0, total 4016 LEBs (509935616 bytes, 486.3 MiB), available 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB)
root@bora:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 489111552
Volume ID 0, size 3852 LEBs (489111552 bytes, 466.5 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
  • Now mount the UBI volume using UBIFS in a temporary directory
mkdir -p /mnt/nand
mount -t ubifs ubi0_0 /mnt/nand

E.g.:

root@bora:~# mkdir -p /mnt/nand
root@bora:~# mount -t ubifs ubi0_0 /mnt/nand
[  151.397013] UBIFS: default file-system created
[  151.402858] UBIFS: background thread "ubifs_bgt0_0" started, PID 918
[  151.529438] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  151.535395] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  151.544507] UBIFS: FS size: 487079936 bytes (464 MiB, 3836 LEBs), journal size 24379392 bytes (23 MiB, 192 LEBs)
[  151.554646] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[  151.560452] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 447F1480-E173-4BE9-B5BE-A3EC1267F99E, small LPT model
  • you can now extract the root file system into that directory
tar zxvf belk-3.0.1_bora-image-devel-bora.tar.gz -C /mnt/nand
  • finally, you need to cleanly umount and detach the MTD partition
umount /mnt/nand/
ubidetach -m 7

E.g.

root@bora:~# umount /mnt/nand/
[  385.604146] UBIFS: un-mount UBI device 0, volume 0
[  385.608892] UBIFS: background thread "ubifs_bgt0_0" stops
root@bora:~# ubidetach -m 7
[  387.671411] UBI: detaching mtd7 from ubi0
[  387.677554] UBI: mtd7 is detached from ubi0
root@bora:~#

You can now safely reboot or turn off the system.

Program boot images

NOR flash

We assume that the following environment variables are present in u-boot:

loadk=tftpboot ${loadaddr} ${bootfile}
loadfdt=tftpboot ${fdtaddr} ${fdtfile}
loadfpga=tftpboot ${loadaddr} ${fpgafile}
updatek=sf probe 0 0 0;sf erase ${kernel_base} +${filesize};sf write ${loadaddr} ${kernel_base} ${filesize}
updatefdt=sf probe 0 0 0;sf erase ${fdt_base} +${filesize};sf write ${fdtaddr} ${fdt_base} ${filesize}
updatefpga=sf probe 0 0 0;sf erase ${fpga_base} +${filesize};sf write ${loadaddr} ${fpga_base} ${filesize}
spi_loadk=sf read ${loadaddr} ${kernel_base} 0x800000
spi_loadfdt=sf read ${fdtaddr} ${fdt_base} 0x80000
spi_loadfpga=sf read ${loadaddr} ${fpga_base} 0x600000
program_fpga=run spi_loadfpga;fpga load 0 ${loadaddr} 0x5b3f0c
  • Update the bootfile, fdtfile and fpgafile environment variables to fit the filename as found inside the TFTP server.
  • Program kernel and device tree on NOR flash with the following U-Boot command
zynq-uboot> sf probe; run loadfpga updatefpga loadk updatek loadfdt updatefdt

E.g.:

zynq-uboot> sf probe; run loadfpga updatefpga loadk updatek loadfdt updatefdt
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/borax-BELK-3.0.0-fpga.bin'.
Load address: 0x2080000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################################
         823.2 KiB/s
done
Bytes transferred = 5979916 (5b3f0c hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 6029312 bytes @ 0x180000 Erased: OK
SF: 5979916 bytes @ 0x180000 Written: OK
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/linux/belk-3.0.0_uImage'.
Load address: 0x2080000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##############################
         545.9 KiB/s
done
Bytes transferred = 3477184 (350ec0 hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 3538944 bytes @ 0x800000 Erased: OK
SF: 3477184 bytes @ 0x800000 Written: OK
Using Gem.e000b000 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.209
Filename 'bora/linux/belk-3.0.0_bora.dtb'.
Load address: 0x2000000
Loading: T ##
         2 KiB/s
done
Bytes transferred = 10019 (2723 hex)
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
SF: 65536 bytes @ 0x780000 Erased: OK
SF: 10019 bytes @ 0x780000 Written: OK


In U-Boot environment please set the following variables in order to be able to boot from NOR + NAND

nandargs=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
spi_nand=sf probe; run program_fpga spi_loadk spi_loadfdt nandargs addcons addmisc; bootm ${loadaddr} - ${fdtaddr}


Reboot the system and configure U-Boot to apply the new configuration

=> setenv bootcmd run spi_nand
=> saveenv