Open main menu

DAVE Developer's Wiki β

Changes

Standalone boot (XUELK)

10,679 bytes added, 08:12, 3 March 2020
Creating and flashing a UBI root file system image
!Date
!XUELK version
!Hardware Part Nr
!Notes
|-
|November 2016
|[[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#XUELK_1.0.0|XUELK 1.0.0]]
|XUBE0000I1R
|
|-
== Introduction ==
This document has been was written and tested with the software/hardware combination described in the history table above. However , it contains general concept concepts that can be adapted on any DAVE Embedded Systems' Linux platform.
We'll explain how to program and configure a an [[:Category:SBC Lynx|SBC Lynx]] to boot in standalone mode, without the need of a system microSD card or a 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 fetch fetched from NANDflash.
== Program Storing root file system in into NAND flash ==
This is a common step for both booting options.
{{ImportantMessage|text=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 <code>/proc/mtd</code> to match your specific layout}}
=== Flashing the root file system from a tarball archive ===
This example is using a <code>tarball</code> compressed archive to be extracted into a formatted and mounted UBI File System.
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
You can now safely reboot or turn off the system.
== Program boot images =Creating and flashing a UBI root file system image ===This example is using the <code>UBI tools</code> for creating an UBI File System image.
=== NOR flash ===* Prepare and initialize a ''UBI'' image to be flashed with:
<pre>mkfs.ubifsubinize</pre> E.g. preparing an image for a 512MB SLC NAND with:* 2048 bytes page size (parameter <code>-m</code>)* 126976 bytes LEB size (parameter <code>-e</code>)* 4095 LEBs (parameter <code>-c</code>) * an already extracted root file system into the directory <code>xuelk-2.0.1-rfs</code>  <pre class="board-terminal">root@sbc-lynx:~# mkfs.ubifs -m 2048 -e 126976 -c 4095 -r xuelk-2.0.1-rfs -o xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifs</pre> the output file is then: <pre>root@sbc-lynx:~# ls -la xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifs-rw-r--r-- 1 root root 41140224 Mar 2 2020 xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifsroot@sbc-lynx:~#</pre> The ''ubifs'' file can be used for creating a UBI image using <code>ubinize</code> with a proper configuration file: <pre class="board-terminal">root@sbc-lynx:~# cat lynx-ubi.cfg[rootfs]mode=ubiimage=xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifsvol_id=0vol_type=dynamicvol_name=rootfsvol_flags=autoresizevol_alignment=1root@sbc-lynx:~# ubinize -o xuelk-2.0.1_lynx-image-core-sbc-lynx.img -m 2048 -p 128KiB -s 2048 lynx-ubi.cfgubinize: volume size was not specified in section "rootfs", assume minimum to fit image "xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifs"41140224 bytes (39.2 MiB)root@sbc-lynx:~# ls -la xuelk-2.0.1_lynx-image-core-sbc-lynx.img-rw-r--r-- 1 root root 42729472 Mar 2 2020 xuelk-2.0.1_lynx-image-core-sbc-lynx.imgroot@sbc-lynx:~#</pre> Then, the ''UBI image'' can be directly flashed on NAND using <code>ubiformat</code>: <pre class="board-terminal">root@sbc-lynx:~# ubiformat /dev/mtd7 -f xuelk-2.0.1_lynx-image-core-sbc-lynx.imgubiformat: mtd7 (nand), size 1048576000 bytes (1000.0 MiB), 8000 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 byteslibscan: scanning eraseblock 7999 -- 100 % completeubiformat: 8000 eraseblocks have valid erase counter, mean value is 50ubiformat: flashing eraseblock 325 -- 100 % completeubiformat: formatting eraseblock 7999 -- 100 % completeroot@sbc-lynx:~#</pre> ==== Flashing the UBI image using u-boot ====Once created, it is possibile to flash the ''UBI image'' directly on u-boot, e.g. * load the previosuly created UBI img on memory using tftp<pre class="board-terminal">=> tftp ${loadaddr} lynx/xuelk-2.0.1_lynx-image-core-sbc-lynx.imgUsing FEC0 deviceTFTP from server 192.168.0.13; our IP address is 192.168.0.90Filename 'lynx/xuelk-2.0.1_lynx-image-core-sbc-lynx.img'.Load address: 0x80800000Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# #################################################################......... ################################################################# ################################################################# ################################################################# ###################################### 1.3 MiB/sdoneBytes transferred = 42729472 (28c0000 hex)=></pre> * erase the nand part<pre class="board-terminal">=> pri mtdpartsmtdparts=mtdparts=gpmi-nand:8M(nand-uboot),1M(nand-env1),1M(nand-env2),1M(nand-fdt),1M(nand-spare),8M(nand-kernel),4M(nand-splash),-(nand-ubi)=> nand erase.part nand-ubi NAND erase.part: device 0 offset 0x1800000, size 0x3e800000Erasing at 0x3ffe0000 -- 100% complete.OK=></pre> * flash the image using <code>nand write</code> <pre class="board-terminal">=> nand write.trimffs ${loadaddr} nand-ubi ${filesize} NAND write: device 0 offset 0x1800000, size 0x28c0000 42729472 bytes written: OK=></pre> Once flashed, it is possible to verify the ''UBI filesystem'' mounting the partition: <pre class="board-terminal">=> ubi part nand-ubiubi0: attaching mtd1ubi0: scanning is finishedubi0: volume 0 ("rootfs") re-sized from 324 to 7836 LEBsubi0: attached mtd1 (name "mtd=7", size 1000 MiB)ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytesubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 969162404ubi0: available PEBs: 0, total reserved PEBs: 8000, PEBs reserved for bad PEB handling: 160=> ubifsmount ubi0:rootfs=> ubifsls<DIR> 4816 Wed Oct 04 07:27:18 2017 bin<DIR> 160 Fri Sep 29 14:38:33 2017 dev<DIR> 5168 Wed Oct 04 07:27:36 2017 etc<DIR> 4760 Tue Oct 03 16:38:32 2017 lib<DIR> 160 Fri Sep 29 14:38:33 2017 mnt<DIR> 160 Fri Sep 29 14:38:33 2017 run<DIR> 160 Fri Sep 29 14:38:34 2017 tmp<DIR> 160 Fri Sep 29 14:38:33 2017 sys<DIR> 744 Fri Sep 29 15:18:32 2017 var<DIR> 672 Fri Sep 29 15:08:41 2017 usr<DIR> 320 Wed Oct 04 07:27:03 2017 boot<DIR> 224 Wed Oct 04 07:27:01 2017 home<DIR> 160 Fri Sep 29 14:38:33 2017 proc<DIR> 5176 Wed Oct 04 07:27:20 2017 sbin<DIR> 160 Fri Sep 29 14:38:33 2017 media=></pre> You can now safely boot the system. === u.boot configuration ===In U-Boot environment check the following variable, which must contain the same MTD partition number used above <pre>nand_args=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=7</pre> == Storing boot images ...== ==... into NOR flash ==We assume that the following environment variables are present defined in uthe U-bootBoot environment:
<pre>
load=tftp ${loadaddr} ${uboot}
loadk=tftpboot ${loadaddr} ${serverip}:${bootfile}
loadfdt=tftpboot ${fdtaddr} ${serverip}:${fdtfile}
spi_updatek=sf erase 200000 600000800000; sf write ${loadaddr} 200000 ${filesize}
spi_updatefdt=sf erase 180000 80000; sf write ${fdtaddr} 180000 ${filesize}
spi_loadk=sf read ${loadaddr} 200000 600000800000
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
spi_update=sf probe; sf erase 0 +${filesize};sf write ${loadaddr} 400 ${filesize}
</pre>
 
===U-Boot===
The following example shows how to store a U-Boot image in NOR flash replacing the existing one (version <code>xuelk-2.0.0</code>). The variable <code>uboot</code> is edited to select a specific U-Boot image which is download from the TFTP server (version <code>xuelk-2.0.2</code>) over the Ethernet connection.
 
<pre class="board-terminal">
U-Boot 2016.03-xuelk-2.0.0 (Sep 27 2017 - 16:52:39 +0200), Build: jenkins-XUELK_U-Boot-35
 
CPU: Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 34C
Reset cause: POR
Environment: SPI Flash
I2C: ready
DRAM: 512 MiB
Relocating to 9ff24000, new gd at 9ef13eb8, sp at 9ef13e90
WARNING: CB ConfigID is UNLOCKED, use configid cb_lock 0 to lock it
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11
NAND: 2048 MiB
MMC: FSL_SDHC: 0
SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
In: serial
Out: serial
Err: serial
MMC: no card present
SOM ConfigID#: 00000013
SOM UniqueID#: e6b3f362:262c61d4
CB ConfigID#: 00000030
CB UniqueID#: 00000000:00000000
Board: MX6UL SBC Lynx
Net: FEC0
Normal Boot
Hit any key to stop autoboot: 0
=> editenv uboot
edit: lynx/u-boot/xuelk-2.0.2_mx6ul_lynx_spi_u-boot.imx
=> run load
Using FEC0 device
TFTP from server 192.168.0.23; our IP address is 192.168.0.80
Filename 'lynx/u-boot/xuelk-2.0.2_mx6ul_lynx_spi_u-boot.imx'.
Load address: 0x80800000
Loading: #################################################################
##############################################
1.8 MiB/s
done
Bytes transferred = 565292 (8a02c hex)
=> run update
## Error: "update" not defined
=> run spi_update
SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 589824 bytes @ 0x0 Erased: OK
device 0 offset 0x400, size 0x8a02c
SF: 565292 bytes @ 0x400 Written: OK
=> res
resetting ...
 
 
U-Boot 2016.03-xuelk-2.0.2 (Jan 12 2018 - 09:14:35 +0100), Build: jenkins-XUELK_U-Boot-38
 
CPU: Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 44C
Reset cause: POR
Environment: SPI Flash
I2C: ready
DRAM: 512 MiB
Relocating to 9ff24000, new gd at 9ef13eb8, sp at 9ef13e90
WARNING: CB ConfigID is UNLOCKED, use configid cb_lock 0 to lock it
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11
NAND: 2048 MiB
MMC: FSL_SDHC: 0
SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
In: serial
Out: serial
Err: serial
MMC: no card present
SOM ConfigID#: 00000013
SOM UniqueID#: e6b3f362:262c61d4
CB ConfigID#: 00000030
CB UniqueID#: 00000000:00000000
Board: MX6UL SBC Lynx
Net: FEC0
Normal Boot
Hit any key to stop autoboot: 0
=>
</pre>
===Linux kernel image and device tree===
* Update the <code>bootfile</code> and <code>fdtfile</code> 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
<pre class="board-terminal">
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
</pre>
<pre class="board-terminal">
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdtSF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB
Using FEC0 device
TFTP from server 192.168.0.1323; our IP address is 192.168.0.7786Filename 'lynx/linux/xuelk-1.01.0_uImage'.
Load address: 0x80800000
Loading: #################################################################
[...]
###########################
2 MiB/s
done
Bytes transferred = 6459304 6723656 (628fa8 669848 hex)SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiBSF: 6291456 8388608 bytes @ 0x200000 Erased: OKSF: 6459304 6723656 bytes @ 0x200000 Written: OK
Using FEC0 device
TFTP from server 192.168.0.1323; our IP address is 192.168.0.7786Filename 'lynx/linux/xuelk-1.01.0_imx6ul-lynx-som0010.dtb'.
Load address: 0x83000000
Loading: ####### 7761.4 KiB6 MiB/s
done
Bytes transferred = 29446 31663 (7306 7baf hex)SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiBSF: 131072 524288 bytes @ 0x180000 Erased: OKSF: 29446 31663 bytes @ 0x180000 Written: OK
</pre>
</pre>
== ... into NAND flash == 
We assume that the following environment variables are present in u-boot:
<pre>
nand_loadk=nand read ${loadaddr} nand-kernel
nand_loadfdt=nand read ${fdtaddr} nand-fdt
nand_args=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=7
nand_nand=run nand_loadk nand_loadfdt nandargs addip addcons addmisc; bootm ${loadaddr} - ${fdtaddr}
</pre>
 
 
* Update the <code>bootfile</code> and <code>fdtfile</code> 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
 
<pre class="board-terminal">
=> run loadk nand_updatek loadfdt nand_updatefdt
</pre>
 
E.g.:
 
<pre class="board-terminal">
=> 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
</pre>
 
 
Reboot the system and configure U-Boot to apply the new configuration
 
<pre class="board-terminal">
=> setenv bootcmd run nand_nand
=> saveenv
</pre>
8,220
edits