Open main menu

DAVE Developer's Wiki β

Changes

Standalone boot (XUELK)

8,866 bytes added, 08:12, 3 March 2020
Creating and flashing a UBI root file system image
** 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.
== Programming 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.
=== 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.
 
* Prepare and initialize a ''UBI'' image to be flashed with:
 
<pre>
mkfs.ubifs
ubinize
</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.ubifs
root@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=ubi
image=xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifs
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
vol_alignment=1
root@sbc-lynx:~# ubinize -o xuelk-2.0.1_lynx-image-core-sbc-lynx.img -m 2048 -p 128KiB -s 2048 lynx-ubi.cfg
ubinize: 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.img
root@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.img
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 50
ubiformat: flashing eraseblock 325 -- 100 % complete
ubiformat: formatting eraseblock 7999 -- 100 % complete
root@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.img
Using FEC0 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
Filename 'lynx/xuelk-2.0.1_lynx-image-core-sbc-lynx.img'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
...
...
...
#################################################################
#################################################################
#################################################################
######################################
1.3 MiB/s
done
Bytes transferred = 42729472 (28c0000 hex)
=>
</pre>
 
* erase the nand part
<pre class="board-terminal">
=> pri mtdparts
mtdparts=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 0x3e800000
Erasing 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-ubi
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: volume 0 ("rootfs") re-sized from 324 to 7836 LEBs
ubi0: attached mtd1 (name "mtd=7", size 1000 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 969162404
ubi0: 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>
== Programming Storing boot images ...== 
==... into NOR flash ==
We assume that the following variables are defined in the U-Boot environment:
<pre>
load=tftp ${loadaddr} ${uboot}
loadk=tftpboot ${loadaddr} ${serverip}:${bootfile}
loadfdt=tftpboot ${fdtaddr} ${serverip}:${fdtfile}
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
8,204
edits