Difference between revisions of "Standalone boot (XELK)"

From DAVE Developer's Wiki
Jump to: navigation, search
(Update u-boot)
(9 intermediate revisions by 3 users not shown)
Line 25: Line 25:
 
|-
 
|-
 
|4.0.0
 
|4.0.0
|Aug 2019
+
|July 2018
 
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_4.0.0|XELK 4.0.0]]
 
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_4.0.0|XELK 4.0.0]]
 
|XELK 4.0.0
 
|XELK 4.0.0
Line 31: Line 31:
 
|-
 
|-
 
|}
 
|}
 +
  
 
== Introduction ==
 
== Introduction ==
Line 36: Line 37:
 
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 using the SPL.
 
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 using the SPL.
  
We'll explain how to program and configure a  
+
We'll explain how to program and configure a [[Category: AxelLite|Axel Lite]] to boot in standalone mode, without the need of a system microSD card or a NFS server, with two options:
[[Category:AxelLite|Axel Lite]]
 
to boot in standalone mode, without the need of a system microSD card or a NFS server, with two options:
 
 
* booting with NOR + NAND
 
* 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.
 
** 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.
Line 61: Line 60:
 
=> run load_spl
 
=> run load_spl
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'axel/xelk-4.0.0_mx6qdlaxel_spi_SPL'.
+
Filename 'xelk4/SPL.spi'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: ############
 
Loading: ############
Line 75: Line 74:
 
=> run load_uboot  
 
=> run load_uboot  
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'axel/xelk-4.0.0_mx6qdlaxel_spi_u-boot.img'.
+
Filename 'xelk4/u-boot.img.spi'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: #################################################################
 
Loading: #################################################################
Line 102: Line 101:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@imx6dlxelk:~# kobs-ng -x -v -w xelk-4.0.0_mx6qdlaxel_nand_SPL
+
root@imx6dlxelk:~# kobs-ng -x -v -w  
 +
MTD CONFIG:
 +
  chip_0_device_path = "/dev/mtd0"
 +
  chip_1_device_path = "(null)"
 +
  search_exponent = 2
 +
  data_setup_time = 80
 +
  data_hold_time = 60
 +
  address_setup_time = 25
 +
  data_sample_time = 6
 +
  row_address_size = 3
 +
  column_address_size = 2
 +
  read_command_code1 = 0
 +
  read_command_code2 = 48
 +
  boot_stream_major_version = 1
 +
  boot_stream_minor_version = 0
 +
  boot_stream_sub_version = 0
 +
  ncb_version = 3
 +
  boot_stream_1_address = 0
 +
  boot_stream_2_address = 0
 +
unable to create a temporary file
 +
root@imx6dlxelk:~# kobs-ng -x -v -w SPL.nand
 
MTD CONFIG:
 
MTD CONFIG:
 
   chip_0_device_path = "/dev/mtd0"
 
   chip_0_device_path = "/dev/mtd0"
Line 226: Line 245:
 
mtd: We write one page for save guard. *
 
mtd: We write one page for save guard. *
  
root@imx6qxelk:~# flash_erase /dev/mtd1 0 0
+
root@imx6dlxelk:~# nandwrite -p /dev/mtd1 u-boot.img.nand
Erasing 128 Kibyte @ 5e0000 -- 100 % complete
 
 
 
root@imx6dlxelk:~# nandwrite -p /dev/mtd1 xelk-4.0.0_mx6qdlaxel_nand_u-boot.img
 
 
Writing data to block 0 at offset 0x0
 
Writing data to block 0 at offset 0x0
 
Writing data to block 1 at offset 0x20000
 
Writing data to block 1 at offset 0x20000
Line 244: Line 260:
 
* Boot the system via SD or NFS as described into the [[XELK_Quick_Start_Guide|Quick_start_guide]]
 
* Boot the system via SD or NFS as described into the [[XELK_Quick_Start_Guide|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 [[Memory Tecnology Device (MTD)|MTD]] partitions can be dumped with <code>/proc/mtd</code> (the partition's name should be self-explanatory)
 
* 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 [[Memory Tecnology Device (MTD)|MTD]] partitions can be dumped with <code>/proc/mtd</code> (the partition's name should be self-explanatory)
 +
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@imx6dlxelk:~# cat /proc/mtd  
+
root@axel-lite:~# cat /proc/mtd
 
dev:    size  erasesize  name
 
dev:    size  erasesize  name
mtd0: 00200000 00020000 "nand-SPL"
+
mtd0: 00800000 00020000 "nand-uboot"
mtd1: 00600000 00020000 "nand-uboot"
+
mtd1: 00100000 00020000 "nand-env1"
mtd2: 00100000 00020000 "nand-env1"
+
mtd2: 00100000 00020000 "nand-env2"
mtd3: 00100000 00020000 "nand-env2"
+
mtd3: 00100000 00020000 "nand-fdt"
mtd4: 00100000 00020000 "nand-fdt"
+
mtd4: 00100000 00020000 "nand-spare"
mtd5: 00100000 00020000 "nand-spare"
+
mtd5: 00800000 00020000 "nand-kernel"
mtd6: 00800000 00020000 "nand-kernel"
+
mtd6: 00400000 00020000 "nand-splash"
mtd7: 00400000 00020000 "nand-splash"
+
mtd7: 1e800000 00020000 "nand-ubi"
mtd8: 1e800000 00020000 "nand-ubi"
+
mtd8: 00100000 00010000 "spi-uboot"
mtd9: 00010000 00010000 "spi-SPL"
+
mtd9: 00040000 00010000 "spi-env1"
mtd10: 000f0000 00010000 "spi-uboot"
+
mtd10: 00040000 00010000 "spi-env2"
mtd11: 00040000 00010000 "spi-env1"
+
mtd11: 00080000 00010000 "spi-dtb"
mtd12: 00040000 00010000 "spi-env2"
+
mtd12: 00600000 00010000 "spi-kernel"
mtd13: 00080000 00010000 "spi-dtb"
+
mtd13: 00400000 00010000 "spi-splash"
mtd14: 00800000 00010000 "spi-kernel"
+
mtd14: 01400000 00010000 "spi-free"
mtd15: 00400000 00010000 "spi-splash"
+
root@axel-lite:~#
mtd16: 01200000 00010000 "spi-free"
 
 
</pre>
 
</pre>
  
Line 270: Line 286:
  
  
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd8</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
+
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
  
 
<pre>
 
<pre>
ubiformat /dev/mtd8
+
ubiformat /dev/mtd7
ubiattach -m 8
+
ubiattach -m 7
 
ubimkvol /dev/ubi0 -N rootfs -m
 
ubimkvol /dev/ubi0 -N rootfs -m
 
</pre>
 
</pre>
Line 281: Line 297:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@axel-lite:~# ubiformat /dev/mtd8
+
root@axel-lite:~# ubiformat /dev/mtd7
ubiformat: mtd8 (nand), size 511705088 bytes (488.0 MiB), 3904 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
+
ubiformat: mtd7 (nand), size 511705088 bytes (488.0 MiB), 3904 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
 
libscan: scanning eraseblock 3903 -- 100 % complete
 
libscan: scanning eraseblock 3903 -- 100 % complete
 
ubiformat: 3904 eraseblocks have valid erase counter, mean value is 31
 
ubiformat: 3904 eraseblocks have valid erase counter, mean value is 31
 
ubiformat: formatting eraseblock 3903 -- 100 % complete
 
ubiformat: formatting eraseblock 3903 -- 100 % complete
root@axel-lite:~# ubiattach -m 8
+
root@axel-lite:~# ubiattach -m 7
[  517.999286] UBI: attaching mtd8 to ubi0
+
[  517.999286] UBI: attaching mtd7 to ubi0
 
[  524.468201] UBI: scanning is finished
 
[  524.468201] UBI: scanning is finished
[  524.498833] UBI: attached mtd8 (name "nand-ubi", size 488 MiB) to ubi0
+
[  524.498833] UBI: attached mtd7 (name "nand-ubi", size 488 MiB) to ubi0
 
[  524.505476] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
 
[  524.505476] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
 
[  524.512290] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
 
[  524.512290] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
Line 330: Line 346:
  
 
<pre>
 
<pre>
tar xvjf xelk-4.0.0_axel-image-qt5.tar.bz2 -C /mnt/nand
+
tar xvjf xelk-2.2.0_axel-fsl-image-qt5-xelk-l.tar.bz2 -C /mnt/nand
 
</pre>
 
</pre>
  
Line 337: Line 353:
 
<pre>
 
<pre>
 
umount /mnt/nand/
 
umount /mnt/nand/
ubidetach -m 8
+
ubidetach -m 7
 
</pre>
 
</pre>
  
Line 346: Line 362:
 
[  575.115560] UBIFS: un-mount UBI device 0, volume 0
 
[  575.115560] UBIFS: un-mount UBI device 0, volume 0
 
[  575.120424] UBIFS: background thread "ubifs_bgt0_0" stops
 
[  575.120424] UBIFS: background thread "ubifs_bgt0_0" stops
root@axel-lite:~# ubidetach -m 8
+
root@axel-lite:~# ubidetach -m 7
[  575.171074] UBI: detaching mtd8 from ubi0
+
[  575.171074] UBI: detaching mtd7 from ubi0
[  575.182401] UBI: mtd8 is detached from ubi0
+
[  575.182401] UBI: mtd7 is detached from ubi0
 
root@axel-lite:~#
 
root@axel-lite:~#
 
</pre>
 
</pre>
Line 357: Line 373:
  
 
<pre>
 
<pre>
nand_args=setenv bootargs ubi.mtd=8 root=ubi0_0 rootfstype=ubifs rw
+
nand_args=setenv bootargs ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw
 
</pre>
 
</pre>
 +
 +
'''Note:''' In Xelk-3.0.0 ''nand_args'' has been replaced by ''nandargs''
  
 
== Program boot images ==
 
== Program boot images ==
Line 386: Line 404:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
+
U-Boot > 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
+
SF: Detected S25FL256S with page size 64 KiB, total 32 MiB
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/xelk-4.0.0_uImage'.
+
Filename 'axel/linux/xelk-2.3.1_uImage'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: #################################################################
 
Loading: #################################################################
Line 409: Line 427:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
         #################################################################
+
         #############################################
        #################################################################
+
         1.6 MiB/s
        #################################################################
 
        ###
 
         1.3 MiB/s
 
 
done
 
done
Bytes transferred = 6668104 (65bf48 hex)
+
Bytes transferred = 5887704 (59d6d8 hex)
SF: 8388608 bytes @ 0x200000 Erased: OK
 
device 0 offset 0x200000, size 0x65bf48
 
SF: 6668104 bytes @ 0x200000 Written: OK
 
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/xelk-4.0.0_imx6q-sbcx-cb0012.dtb_wl'.
+
Filename 'axel/linux/xelk-2.3.1_imx6q-xelk-l-2.0.0.dtb'.
 
Load address: 0x18000000
 
Load address: 0x18000000
Loading: ###########
+
Loading: ##########
         604.5 KiB/s
+
         1.2 MiB/s
 
done
 
done
Bytes transferred = 51400 (c8c8 hex)
+
Bytes transferred = 46326 (b4f6 hex)
SF: 524288 bytes @ 0x180000 Erased: OK
+
U-Boot ></pre>
device 0 offset 0x180000, size 0xc8c8
 
SF: 51400 bytes @ 0x180000 Written: OK
 
 
 
</pre>
 
  
  
Line 437: Line 445:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
=> setenv bootcmd run spi_nand
+
U-Boot > setenv bootcmd run spi_nand
=> saveenv
+
U-Boot > saveenv
 
</pre>
 
</pre>
  
Line 446: Line 454:
  
 
<pre>
 
<pre>
=> print nand_updatek nand_updatefdt nand_loadk nand_loadfdt nand_nand
 
 
nand_updatek=nand erase.part nand-kernel; nand write ${loadaddr} nand-kernel ${filesize}
 
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_updatefdt=nand erase.part nand-fdt; nand write ${fdtaddr} nand-fdt ${filesize}
 +
 
nand_loadk=nand read ${loadaddr} nand-kernel
 
nand_loadk=nand read ${loadaddr} nand-kernel
 
nand_loadfdt=nand read ${fdtaddr} nand-fdt
 
nand_loadfdt=nand read ${fdtaddr} nand-fdt
Line 465: Line 473:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
=> run loadk nand_updatek loadfdt nand_updatefdt
+
U-Boot > run loadk nand_updatek loadfdt nand_updatefdt
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/xelk-4.0.0_uImage'.
+
Filename 'axel/linux/xelk-2.3.1_uImage'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: #################################################################
 
Loading: #################################################################
Line 487: Line 495:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
         #################################################################
+
         #############################################
        #################################################################
+
         1.6 MiB/s
        #################################################################
 
        ###
 
         1.2 MiB/s
 
 
done
 
done
Bytes transferred = 6668104 (65bf48 hex)
+
Bytes transferred = 5887704 (59d6d8 hex)
  
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
Skipping bad block at  0x00d00000                                         
+
size adjusted to 0x7e0000 (1 bad blocks)
Erasing at 0x13e0000 -- 100% complete.
+
Skipping bad block at  0x00d60000
 +
Erasing at 0x13c0000 -- 100% complete.
 
OK
 
OK
  
NAND write: device 0 offset 0xc00000, size 0x65bf48
+
NAND write: device 0 offset 0xc00000, size 0x59d6d8
Skip bad block 0x00d00000
+
Skip bad block 0x00d60000
  6668104 bytes written: OK
+
  5887704 bytes written: OK
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.89; our IP address is 192.168.0.83
+
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/xelk-4.0.0_imx6q-sbcx-cb0012.dtb'.
+
Filename 'axel/linux/xelk-2.3.1_imx6q-xelk-l-2.0.0.dtb'.
 
Load address: 0x18000000
 
Load address: 0x18000000
Loading: ###########
+
Loading: ##########
         726.6 KiB/s
+
         1.3 MiB/s
 
done
 
done
Bytes transferred = 51400 (c8c8 hex)
+
Bytes transferred = 46326 (b4f6 hex)
  
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
Line 516: Line 522:
 
OK
 
OK
  
NAND write: device 0 offset 0xa00000, size 0xc8c8
+
NAND write: device 0 offset 0xa00000, size 0xb4f6
  51400 bytes written: OK
+
  46326 bytes written: OK
=>  
+
U-Boot >
 
</pre>
 
</pre>
  
Line 525: Line 531:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
=> setenv bootcmd run nand_nand
+
U-Boot > setenv bootcmd run nand_nand
=> saveenv
+
U-Boot > saveenv
 
</pre>
 
</pre>

Revision as of 07:56, 25 June 2018

Info Box
Axel-lite 02.png Applies to Axel Lite

History[edit | edit source]

Version Date XELK version Hardware Part Nr Notes

2.3.1

June 2017 XELK 2.3.1 XELK 2.0.0

3.0.1

Nov 2017 XELK 3.0.1 XELK 3.0.1
4.0.0 July 2018 XELK 4.0.0 XELK 4.0.0


Introduction[edit | edit source]

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 using the SPL.

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 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 storage, all images and the root file system will be fetch from NAND.

Update u-boot[edit | edit source]

In order to support the SPL, new additional uboot variables have been introduced.

=> print load_spl load_uboot spi_update_spl spi_update_uboot
load_spl=tftp ${loadaddr} ${spl}
load_uboot=tftp ${loaddr} ${ubootimg}
spi_update_spl=sf probe; sf erase 0 10000;sf write ${loadaddr} 400 ${filesize}
spi_update_uboot=sf probe; sf erase 10000 f0000;sf write ${loadaddr} 10000 ${filesize}

u-boot on NOR SPI[edit | edit source]

Uboot can be flashed into NOR following the example below. Firstly, the SPL is fetched from the tftpserver and then it is flashed into the NOR SPL partition. Lastly, the same operation is performed for the uboot image.

=> run load_spl
Using FEC device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'xelk4/SPL.spi'.
Load address: 0x12000000
Loading: ############
         335 KiB/s
done
Bytes transferred = 56320 (dc00 hex)
=> run spi_update_spl 
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 65536 bytes @ 0x0 Erased: OK
device 0 offset 0x400, size 0xdc00
SF: 56320 bytes @ 0x400 Written: OK
=> run load_uboot 
Using FEC device
TFTP from server 192.168.0.82; our IP address is 192.168.0.83
Filename 'xelk4/u-boot.img.spi'.
Load address: 0x12000000
Loading: #################################################################
         ################################
         1.2 MiB/s
done
Bytes transferred = 493272 (786d8 hex)
=> run spi_update_uboot 
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 983040 bytes @ 0x10000 Erased: OK
device 0 offset 0x10000, size 0x786d8
SF: 493272 bytes @ 0x10000 Written: OK

u-boot on NAND[edit | edit source]

The SPL and u-boot image, must be flashed on NAND using the NXP kobs-ng utility. This tool is required for writing correct information needed by bootrom to identify the NAND as a boot device.

The following steps are therefore necessary:

  • boot the system via SD on NFS
  • uses a rfs with kobs-ng utility available on it (e.g. DAVE's rfs provided with XELK)
  • copy the related u-boot ans SPL files on nfs /home/root (for example)
  • execute kobs-ng passing the parameters for flashing the SPL on NAND.
  • execute nandwrite to flash uboot image on NAND.
root@imx6dlxelk:~# kobs-ng -x -v -w    
MTD CONFIG:
  chip_0_device_path = "/dev/mtd0"
  chip_1_device_path = "(null)"
  search_exponent = 2
  data_setup_time = 80
  data_hold_time = 60
  address_setup_time = 25
  data_sample_time = 6
  row_address_size = 3
  column_address_size = 2
  read_command_code1 = 0
  read_command_code2 = 48
  boot_stream_major_version = 1
  boot_stream_minor_version = 0
  boot_stream_sub_version = 0
  ncb_version = 3
  boot_stream_1_address = 0
  boot_stream_2_address = 0
unable to create a temporary file
root@imx6dlxelk:~# kobs-ng -x -v -w SPL.nand 
MTD CONFIG:
  chip_0_device_path = "/dev/mtd0"
  chip_1_device_path = "(null)"
  search_exponent = 2
  data_setup_time = 80
  data_hold_time = 60
  address_setup_time = 25
  data_sample_time = 6
  row_address_size = 3
  column_a[  171.755580] nand: nand_erase_nand: attempt to erase a bad block at page 0x00000000
ddress_size = 2
  read_command_code1 = 0
  read_command_code2 = 48
  boot_stream_major_version = 1
  boot_stream_minor_version = 0
  boot_stream_sub_version = 0
  ncb_version = 3
  boot_stream_1_address = 0
  boot_stream_2_address = 0
         -- We add the 1k-padding to the uboot.
.tmp_kobs_ng: verifying using key '00000000000000000000000000000000'
.tmp_kobs_ng: is a valid bootstream for key '00000000000000000000000000000000'
mtd: use new bch layout raw access mode
mtd: opening: "/dev/mtd0"
NFC geometry :
        ECC Strength       : 2
        Page Size in Bytes : 2071
        Metadata size      : 10
        ECC Chunk Size in byte : 512
        ECC Chunk count        : 4
        Block Mark Byte Offset : 2028
        Block Mark Bit Offset  : 2
====================================================
mtd: opened '/dev/mtd0' - '(null)'
mtd: max_boot_stream_size_in_bytes = 524288
mtd: boot_stream_size_in_bytes = 49152
mtd: boot_stream_size_in_pages = 24
mtd: #1 0x00100000 - 0x00180000 (0x0010c000)
mtd: #2 0x00180000 - 0x00200000 (0x0018c000)
FCB
  m_u32Checksum = 0x00000000
  m_u32FingerPrint = 0x20424346
  m_u32Version = 0x01000000
  m_NANDTiming.m_u8DataSetup = 80
  m_NANDTiming.m_u8DataHold = 60
  m_NANDTiming.m_u8AddressSetup = 25
  m_NANDTiming.m_u8DSAMPLE_TIME = 6
  m_u32PageDataSize = 2048
  m_u32TotalPageSize = 2112
  m_u32SectorsPerBlock = 64
  m_u32NumberOfNANDs = 0
  m_u32TotalInternalDie = 0
  m_u32CellType = 0
  m_u32EccBlockNEccType = 1
  m_u32EccBlock0Size = 512
  m_u32EccBlockNSize = 512
  m_u32EccBlock0EccType = 1
  m_u32MetadataBytes = 10
  m_u32NumEccBlocksPerPage = 3
  m_u32EccBlockNEccLevelSDK = 0
  m_u32EccBlock0SizeSDK = 0
  m_u32EccBlockNSizeSDK = 0
  m_u32EccBlock0EccLevelSDK = 0
  m_u32NumEccBlocksPerPageSDK = 0
  m_u32MetadataBytesSDK = 0
  m_u32EraseThreshold = 0
  m_u32Firmware1_startingPage = 512
  m_u32Firmware2_startingPage = 768
  m_u32PagesInFirmware1 = 24
  m_u32PagesInFirmware2 = 24
  m_u32DBBTSearchAreaStartAddress = 256
  m_u32BadBlockMarkerByte = 2028
  m_u32BadBlockMarkerStartBit = 2
  m_u32BBMarkerPhysicalOffset = 2048
  m_u32BCHType = 0
  m_NANDTMTiming.m_u32TMTiming2_ReadLatency = 0
  m_NANDTMTiming.m_u32TMTiming2_PreambleDelay = 0
  m_NANDTMTiming.m_u32TMTiming2_CEDelay = 0
  m_NANDTMTiming.m_u32TMTiming2_PostambleDelay = 0
  m_NANDTMTiming.m_u32TMTiming2_CmdAddPause = 0
  m_NANDTMTiming.m_u32TMTiming2_DataPause = 0
  m_NANDTMTiming.m_u32TMSpeed = 0
  m_NANDTMTiming.m_u32TMTiming1_BusyTimeout = 0
  m_u32DISBBM = 0
  m_u32BBMarkerPhysicalOffsetInSpareData = 0
DBBT
  m_u32Checksum = 0x00000000
  m_u32FingerPrint = 0x54424244
  m_u32Version = 0x01000000
  m_u32DBBTNumOfPages = 0
Firmware: image #0 @ 0x100000 size 0xc000 - available 0x80000
Firmware: image #1 @ 0x180000 size 0xc000 - available 0x80000
-------------- Start to write the [ FCB ] -----
mtd: erasing @0:0x0-0x20000
mtd: device 0 fails MEMERASE (0x0 - 0x20000)
mtd: Failed to erase block @0x0
mtd: erasing @0:0x20000-0x40000
mtd: Writing FCB1 [ @0:0x20000 ] (840) *
mtd: erasing @0:0x40000-0x60000
mtd: Writing FCB2 [ @0:0x40000 ] (840) *
mtd: erasing @0:0x60000-0x80000
mtd: Writing FCB3 [ @0:0x60000 ] (840) *
mtd_commit_bcb(FCB): status 1

-------------- Start to write the [ DBBT ] -----
mtd: erasing @0:0x80000-0xa0000
mtd: Writing DBBT0 [ @0:0x80000 ] (800) *
mtd: erasing @0:0xa0000-0xc0000
mtd: Writing DBBT1 [ @0:0xa0000 ] (800) *
mtd: erasing @0:0xc0000-0xe0000
mtd: Writing DBBT2 [ @0:0xc0000 ] (800) *
mtd: erasing @0:0xe0000-0x100000
mtd: Writing DBBT3 [ @0:0xe0000 ] (800) *
mtd_commit_bcb(DBBT): status 0

---------- Start to write the [ .tmp_kobs_ng ]----
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x0010c000
mtd: erasing @0:0x100000-0x120000
mtd: We write one page for save guard. *
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018c000
mtd: erasing @0:0x180000-0x1a0000
mtd: We write one page for save guard. *

root@imx6dlxelk:~# nandwrite -p /dev/mtd1 u-boot.img.nand 
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000

For more details, please refer to this page.

Program root file system in NAND flash[edit | edit source]

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@axel-lite:~# 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: 1e800000 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"
root@axel-lite:~#


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@axel-lite:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 511705088 bytes (488.0 MiB), 3904 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 3903 -- 100 % complete
ubiformat: 3904 eraseblocks have valid erase counter, mean value is 31
ubiformat: formatting eraseblock 3903 -- 100 % complete
root@axel-lite:~# ubiattach -m 7
[  517.999286] UBI: attaching mtd7 to ubi0
[  524.468201] UBI: scanning is finished
[  524.498833] UBI: attached mtd7 (name "nand-ubi", size 488 MiB) to ubi0
[  524.505476] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  524.512290] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[  524.519046] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
[  524.525984] UBI: good PEBs: 3904, bad PEBs: 0, corrupted PEBs: 0
[  524.532010] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
[  524.539190] UBI: max/mean erase counter: 33/32, WL threshold: 4096, image sequence number: 483560195
[  524.548381] UBI: available PEBs: 3820, total reserved PEBs: 84, PEBs reserved for bad PEB handling: 80
[  524.557836] UBI: background thread "ubi_bgt0d" started, PID 856
UBI device number 0, total 3904 LEBs (495714304 bytes, 472.8 MiB), available 3820 LEBs (485048320 bytes, 462.6 MiB), LEB size 126976 bytes (124.0 KiB)
root@axel-lite:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 485048320
Volume ID 0, size 3820 LEBs (485048320 bytes, 462.6 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
root@axel-lite:~#
  • 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@axel-lite:~# mkdir -p /mnt/nand
root@axel-lite:~# mount -t ubifs ubi0_0 /mnt/nand
[  553.177151] UBIFS: default file-system created
[  553.186049] UBIFS: background thread "ubifs_bgt0_0" started, PID 860
[  553.366834] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  553.372931] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  553.382300] UBIFS: FS size: 483016704 bytes (460 MiB, 3804 LEBs), journal size 24252416 bytes (23 MiB, 191 LEBs)
[  553.392542] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[  553.398464] UBIFS: media format: w4/r0 (latest is w4/r0), UUID CB1521BE-B0D5-4CDA-B52A-25BAFDB755C2, small LPT model
root@axel-lite:~#
  • you can now extract the root file system into that directory
tar xvjf xelk-2.2.0_axel-fsl-image-qt5-xelk-l.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@axel-lite:~# umount /mnt/nand/
[  575.115560] UBIFS: un-mount UBI device 0, volume 0
[  575.120424] UBIFS: background thread "ubifs_bgt0_0" stops
root@axel-lite:~# ubidetach -m 7
[  575.171074] UBI: detaching mtd7 from ubi0
[  575.182401] UBI: mtd7 is detached from ubi0
root@axel-lite:~#

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 ubi.mtd=7 root=ubi0_0 rootfstype=ubifs rw

Note: In Xelk-3.0.0 nand_args has been replaced by nandargs

Program boot images[edit | edit source]

NOR flash[edit | edit source]

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 600000; sf write ${loadaddr} 200000 ${filesize}
spi_updatefdt=sf erase 180000 80000; sf write ${fdtaddr} 180000 ${filesize}
spi_loadk=sf read ${loadaddr} 200000 600000
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.:

U-Boot > sf probe; run loadk spi_updatek loadfdt spi_updatefdt
SF: Detected S25FL256S with page size 64 KiB, total 32 MiB
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/linux/xelk-2.3.1_uImage'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############################################
         1.6 MiB/s
done
Bytes transferred = 5887704 (59d6d8 hex)
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/linux/xelk-2.3.1_imx6q-xelk-l-2.0.0.dtb'.
Load address: 0x18000000
Loading: ##########
         1.2 MiB/s
done
Bytes transferred = 46326 (b4f6 hex)
U-Boot >


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

U-Boot > setenv bootcmd run spi_nand
U-Boot > saveenv

NAND flash[edit | edit source]

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 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 NAND flash with the following U-Boot command
run loadk nand_updatek loadfdt nand_updatefdt

E.g.:

U-Boot > run loadk nand_updatek loadfdt nand_updatefdt
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/linux/xelk-2.3.1_uImage'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############################################
         1.6 MiB/s
done
Bytes transferred = 5887704 (59d6d8 hex)

NAND erase.part: device 0 offset 0xc00000, size 0x800000
size adjusted to 0x7e0000 (1 bad blocks)
Skipping bad block at  0x00d60000
Erasing at 0x13c0000 -- 100% complete.
OK

NAND write: device 0 offset 0xc00000, size 0x59d6d8
Skip bad block 0x00d60000
 5887704 bytes written: OK
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
Filename 'axel/linux/xelk-2.3.1_imx6q-xelk-l-2.0.0.dtb'.
Load address: 0x18000000
Loading: ##########
         1.3 MiB/s
done
Bytes transferred = 46326 (b4f6 hex)

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

NAND write: device 0 offset 0xa00000, size 0xb4f6
 46326 bytes written: OK
U-Boot >


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

U-Boot > setenv bootcmd run nand_nand
U-Boot > saveenv