Standalone boot (XUELK)

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
AXEL ULite-top.png Applies to AXEL ULite
SBC Lynx-top.png Applies to SBC Lynx

History

Version Date XUELK version Hardware Part Nr Notes
1.0.0 November 2016 XUELK 1.0.0 XUBE0000I1R

Introduction

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

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

  • booting with NOR + NAND
    • U-Boot will 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.
  • booting with NAND only
    • in this configuration the whole system will boot without the need of a NOR flash storage, all images and the root file system will be fetched from NAND flash.

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 Quick_start_guide
  • By default, the NAND is already partitioned to allow booting from NAND-only (see next section) and, thus, some partitions are reserved for 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@sbc-lynx:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00800000 00020000 "nand-uboot"
mtd1: 00100000 00020000 "nand-env1"
mtd2: 00100000 00020000 "nand-env2"
mtd3: 00100000 00020000 "nand-fdt"
mtd4: 00100000 00020000 "nand-spare"
mtd5: 00800000 00020000 "nand-kernel"
mtd6: 00400000 00020000 "nand-splash"
mtd7: 3e800000 00020000 "nand-ubi"
mtd8: 00100000 00010000 "spi-uboot"
mtd9: 00040000 00010000 "spi-env1"
mtd10: 00040000 00010000 "spi-env2"
mtd11: 00080000 00010000 "spi-dtb"
mtd12: 00600000 00010000 "spi-kernel"
mtd13: 00400000 00010000 "spi-splash"
mtd14: 01400000 00010000 "spi-free"


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@sbc-lynx:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 1048576000 bytes (1000.0 MiB), 8000 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 7999 -- 100 % complete
ubiformat: 8000 eraseblocks have valid erase counter, mean value is 1
ubiformat: formatting eraseblock 7999 -- 100 % complete
root@sbc-lynx:~# ubiattach -m 7
[ 1714.823600] UBI: attaching mtd7 to ubi0
[ 1726.415587] UBI: scanning is finished
[ 1726.483765] UBI: attached mtd7 (name "nand-ubi", size 1000 MiB) to ubi0
[ 1726.491062] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 1726.498301] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1726.505030] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1726.512430] UBI: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
[ 1726.518861] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 1726.526025] UBI: max/mean erase counter: 3/2, WL threshold: 4096, image sequence number: 623070258
[ 1726.535433] UBI: available PEBs: 7836, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
[ 1726.545260] UBI: background thread "ubi_bgt0d" started, PID 714
UBI device number 0, total 8000 LEBs (1015808000 bytes, 968.8 MiB), available 7836 LEBs (994983936 bytes, 948.9 MiB), LEB size 126976 bytes (124.0 KiB)
root@sbc-lynx:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 994983936
Volume ID 0, size 7836 LEBs (994983936 bytes, 948.9 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@sbc-lynx:~# mkdir -p /mnt/nand
root@sbc-lynx:~# mount -t ubifs ubi0_0 /mnt/nand
[ 1810.301461] UBIFS: default file-system created
[ 1810.308952] UBIFS: background thread "ubifs_bgt0_0" started, PID 717
[ 1810.452274] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 1810.459421] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 1810.469398] UBIFS: FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[ 1810.480976] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[ 1810.487210] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 99D0F3C6-5955-4B30-9E2D-72202281BD30, small LPT model
  • you can now extract the root file system into that directory
tar xvjf xuelk-1.0.0_lynx-image-gui-sbc-lynx.tar.bz2 -C /mnt/nand
  • finally, you need to cleanly umount and detach the MTD partition
umount /mnt/nand/
ubidetach -m 7

E.g.

root@sbc-lynx:~# umount /mnt/nand/
[ 2446.743091] UBIFS: un-mount UBI device 0, volume 0
[ 2446.749670] UBIFS: background thread "ubifs_bgt0_0" stops
root@sbc-lynx:~# ubidetach -m 7
[ 2450.738153] UBI: detaching mtd7 from ubi0
[ 2450.759527] UBI: mtd7 is detached from ubi0

You can now safely reboot or turn off the system.

In U-Boot environment check the following variable, which must contain the same MTD partition number used above

nand_args=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=7


Program boot images

NOR flash

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

loadk=tftpboot ${loadaddr} ${serverip}:${bootfile}
loadfdt=tftpboot ${fdtaddr} ${serverip}:${fdtfile}
spi_updatek=sf erase 200000 800000; sf write ${loadaddr} 200000 ${filesize}
spi_updatefdt=sf erase 180000 80000; sf write ${fdtaddr} 180000 ${filesize}
spi_loadk=sf read ${loadaddr} 200000 800000
spi_loadfdt=sf read ${fdtaddr} 180000 80000
spi_nand=sf probe; run spi_loadk spi_loadfdt nandargs addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi
  • Update the bootfile and fdtfile 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
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt

E.g.:

=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
Using FEC0 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.86
Filename 'lynx/linux/xuelk-1.1.0_uImage'.
Load address: 0x80800000
Loading: #################################################################
[...]
         ##############
         2 MiB/s
done
Bytes transferred = 6723656 (669848 hex)
SF: 8388608 bytes @ 0x200000 Erased: OK
SF: 6723656 bytes @ 0x200000 Written: OK
Using FEC0 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.86
Filename 'lynx/linux/xuelk-1.1.0_imx6ul-lynx-som0010.dtb'.
Load address: 0x83000000
Loading: #######
         1.6 MiB/s
done
Bytes transferred = 31663 (7baf hex)
SF: 524288 bytes @ 0x180000 Erased: OK
SF: 31663 bytes @ 0x180000 Written: OK


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

=> setenv bootcmd run spi_nand
=> saveenv

NAND flash

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

nand_updatek=nand erase.part nand-kernel; nand write ${loadaddr} nand-kernel ${filesize}
nand_updatefdt=nand erase.part nand-fdt; nand write ${fdtaddr} nand-fdt ${filesize}

nand_loadk=nand read ${loadaddr} nand-kernel
nand_loadfdt=nand read ${fdtaddr} nand-fdt
nand_nand=run nand_loadk nand_loadfdt nandargs addip addcons addmisc; bootm ${loadaddr} - ${fdtaddr}


  • Update the bootfile and fdtfile environment variables to fit the filename as found inside the TFTP server.
  • Program kernel and device tree on NAND flash with the following U-Boot command
=> run loadk nand_updatek loadfdt nand_updatefdt

E.g.:

=> run loadk nand_updatek loadfdt nand_updatefdt
Using FEC0 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.77
Filename 'lynx/linux/xuelk-1.0.0_uImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
[...]
         ###########################
         1.9 MiB/s
done
Bytes transferred = 6459304 (628fa8 hex)

NAND erase.part: device 0 offset 0xc00000, size 0x800000
Skipping bad block at  0x010a0000
Erasing at 0x13e0000 -- 100% complete.
OK

NAND write: device 0 offset 0xc00000, size 0x628fa8
Skip bad block 0x010a0000
 6459304 bytes written: OK
Using FEC0 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.77
Filename 'lynx/linux/xuelk-1.0.0_imx6ul-lynx-som000c.dtb'.
Load address: 0x83000000
Loading: #######
         1.3 MiB/s
done
Bytes transferred = 31168 (79c0 hex)

NAND erase.part: device 0 offset 0xa00000, size 0x100000
Erasing at 0xae0000 -- 100% complete.
OK

NAND write: device 0 offset 0xa00000, size 0x79c0
 31168 bytes written: OK


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

=> setenv bootcmd run nand_nand
=> saveenv