Difference between revisions of "DESK-MX6-L/Deployment/Standalone boot"

From DAVE Developer's Wiki
Jump to: navigation, search
(Updating outputs for DESK-MX6-L 3.0.0 release tested on SBCX)
Line 14: Line 14:
 
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |Jun 2022
 
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |Jun 2022
 
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |U-Boot root file system parameters
 
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |U-Boot root file system parameters
 +
|-
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |3.0.0
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |Feb 2022
 +
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000" |3.0.0 DESK release tested on SBCX
 
|-
 
|-
 
|}
 
|}
Line 27: Line 31:
  
  
We'll explain how to program and configure a <SOM> to boot in standalone mode, without the need of a system microSD card or an NFS server, with threee options:
+
We'll explain how to program and configure a <SOM> to boot in standalone mode, without the need of a system microSD card or an NFS server, with three options:
 
* booting with NOR and NAND internal storage
 
* booting with NOR and NAND internal storage
 
** in this configuration the primary boot images will be fetched from NOR flash storage, while the root file system will be fetched from NAND flash
 
** in this configuration the primary boot images will be fetched from NOR flash storage, while the root file system will be fetched from NAND flash
Line 37: Line 41:
 
=== Program boot images into NOR flash ===
 
=== Program boot images into NOR flash ===
  
It is supposed tat the proper filenames are configured on u-boot variables. In the following examples, we use the boot images:
+
{{ImportantMessage|text=This example was not tested with '''DESK-MX6-L 3.0.0''' release as '''SBCX''' do not have NOR flash. Nevertheless provided commands should work on other platforms that do have this storage.}}
 +
 
 +
It is supposed that the proper filenames are configured on U-Boot variables. Those files should be available on TFTP server. In the following examples, we use the boot images:
  
 
<pre>
 
<pre>
Line 46: Line 52:
 
</pre>
 
</pre>
  
We assume that the following environment variables are present in u-boot too:
+
We assume that the following environment variables are present in U-Boot too:
  
 
<pre>
 
<pre>
Line 55: Line 61:
 
</pre>
 
</pre>
  
====u-Boot====
+
====U-Boot====
  
Update to the latest u-boot version allows usage of u-boot environment variables available.
+
Update to the latest U-Boot version allows usage of U-Boot environment variables available.
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 94: Line 100:
 
====kernel image and device tree====
 
====kernel image and device tree====
  
We assume that the following environment variables are present in u-boot:
+
We assume that the following environment variables are present in U-Boot:
  
 
<pre>
 
<pre>
Line 172: Line 178:
  
 
=== Program boot images into NAND flash ===
 
=== Program boot images into NAND flash ===
====u-Boot====
+
====U-Boot====
  
u-boot SPL on NAND flash must be programmed using NXP <code>kobs-ng</code> utility and the second stage using the <code>nandwrite</code>: this tool is required for writing the correct u-boot image on NAND storing all information needed by bootrom to identify the NAND as a boot device.
+
U-Boot SPL on NAND flash must be programmed using NXP <code>kobs-ng</code> utility and the second stage using the <code>nandwrite</code>: this tool is required for writing the correct U-Boot image on NAND storing all information needed by bootrom to identify the NAND as a boot device.
  
 
Here below an example:
 
Here below an example:
 
* boot the system via SD on NFS
 
* boot the system via SD on NFS
 
* uses a rfs with <b>kobs-ng</b> utility available on it (e.g. DAVE's rfs provided with <KIT>)
 
* uses a rfs with <b>kobs-ng</b> utility available on it (e.g. DAVE's rfs provided with <KIT>)
* copy the related u-boot imx image file on nfs /home/root (for example)
+
* copy the related U-Boot imx image file on nfs /home/root (for example)
* execute ''kobs-ng'' passing the parameters for flashing u-boot on NAND
+
* execute ''kobs-ng'' passing the parameters for flashing U-Boot on NAND
 
* erase and program the second stage using '''flash_erase''' and '''nandwrite'''
 
* erase and program the second stage using '''flash_erase''' and '''nandwrite'''
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# kobs-ng -x -v -f desk-mx6-l-1.0.0_mx6qdldesk_nand_SPL
+
root@desk-mx6:~# kobs-ng -x -v -w desk-mx6-l-3.0.0_mx6qdldesk_nand_SPL
 
MTD CONFIG:
 
MTD CONFIG:
 
   chip_0_device_path = "/dev/mtd0"
 
   chip_0_device_path = "/dev/mtd0"
Line 220: Line 226:
 
mtd: opened '/dev/mtd0' - '(null)'
 
mtd: opened '/dev/mtd0' - '(null)'
 
mtd: max_boot_stream_size_in_bytes = 524288
 
mtd: max_boot_stream_size_in_bytes = 524288
mtd: boot_stream_size_in_bytes = 57344
+
mtd: boot_stream_size_in_bytes = 61440
mtd: boot_stream_size_in_pages = 28
+
mtd: boot_stream_size_in_pages = 30
mtd: #1 0x00100000 - 0x00180000 (0x0010e000)
+
mtd: #1 0x00100000 - 0x00180000 (0x0010f000)
mtd: #2 0x00180000 - 0x00200000 (0x0018e000)
+
mtd: #2 0x00180000 - 0x00200000 (0x0018f000)
 
FCB
 
FCB
 
   m_u32Checksum = 0x00000000
 
   m_u32Checksum = 0x00000000
Line 253: Line 259:
 
   m_u32Firmware1_startingPage = 512
 
   m_u32Firmware1_startingPage = 512
 
   m_u32Firmware2_startingPage = 768
 
   m_u32Firmware2_startingPage = 768
   m_u32PagesInFirmware1 = 28
+
   m_u32PagesInFirmware1 = 30
   m_u32PagesInFirmware2 = 28
+
   m_u32PagesInFirmware2 = 30
 
   m_u32DBBTSearchAreaStartAddress = 256
 
   m_u32DBBTSearchAreaStartAddress = 256
 
   m_u32BadBlockMarkerByte = 2028
 
   m_u32BadBlockMarkerByte = 2028
Line 275: Line 281:
 
   m_u32Version = 0x01000000
 
   m_u32Version = 0x01000000
 
   m_u32DBBTNumOfPages = 0
 
   m_u32DBBTNumOfPages = 0
Firmware: image #0 @ 0x100000 size 0xe000 - available 0x80000
+
Firmware: image #0 @ 0x100000 size 0xf000 - available 0x80000
Firmware: image #1 @ 0x180000 size 0xe000 - available 0x80000
+
Firmware: image #1 @ 0x180000 size 0xf000 - available 0x80000
 +
-------------- Start to write the [ FCB ] -----
 
-------------- Start to write the [ FCB ] -----
 
-------------- Start to write the [ FCB ] -----
 
mtd: erasing @0:0x0-0x20000
 
mtd: erasing @0:0x0-0x20000
Line 300: Line 307:
  
 
---------- Start to write the [ .tmp_kobs_ng ]----
 
---------- Start to write the [ .tmp_kobs_ng ]----
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x0010e000
+
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x0010f000
 
mtd: erasing @0:0x100000-0x120000
 
mtd: erasing @0:0x100000-0x120000
 
mtd: We write one page for save guard. *
 
mtd: We write one page for save guard. *
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018e000
+
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018f000
 
mtd: erasing @0:0x180000-0x1a0000
 
mtd: erasing @0:0x180000-0x1a0000
 
mtd: We write one page for save guard. *
 
mtd: We write one page for save guard. *
root@imx6qdlxelk:~# flash_erase /dev/mtd1 0 0
+
root@desk-mx6:~# flash_erase /dev/mtd1 0 0
Erasing 128 Kibyte @ 5e0000 -- 100 % complete
+
Erasing 128 Kibyte @ 5e0000 -- 100 % complete  
root@imx6qdlxelk:~# nandwrite -p /dev/mtd1 desk-mx6-l-1.0.0_mx6qdldesk_nand_u-boot.img
+
root@desk-mx6:~# nandwrite -p /dev/mtd1 desk-mx6-l-3.0.0_mx6qdldesk_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 314: Line 321:
 
Writing data to block 3 at offset 0x60000
 
Writing data to block 3 at offset 0x60000
 
Writing data to block 4 at offset 0x80000
 
Writing data to block 4 at offset 0x80000
root@imx6qdlxelk:~#
 
 
</pre>
 
</pre>
  
 
====kernel image and device tree====
 
====kernel image and device tree====
  
We assume that the following environment variables are present in u-boot:
+
We assume that the following environment variables are present in U-Boot:
  
 
<pre>
 
<pre>
Line 339: Line 345:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
U-Boot > run loadk nand_updatek loadfdt nand_updatefdt
+
=> run loadk nand_updatek loadfdt nand_updatefdt
 
Using FEC device
 
Using FEC device
Filename 'desk-mx-l/uImage'.
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.231
 +
Filename 'axel/uImage'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: #################################################################
 
Loading: #################################################################
Line 364: Line 371:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
         #########
+
         #################################################################
         1.2 MiB/s
+
        #################################################################
 +
        #################################################################
 +
        #################################
 +
         1.5 MiB/s
 
done
 
done
Bytes transferred = 7031520 (6b4ae0 hex)
+
Bytes transferred = 8154280 (7c6ca8 hex)
  
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
Line 373: Line 383:
 
OK
 
OK
  
NAND write: device 0 offset 0xc00000, size 0x6b4ae0
+
NAND write: device 0 offset 0xc00000, size 0x7c6ca8
  7031520 bytes written: OK
+
  8154280 bytes written: OK
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.231
Filename 'desk-mx-l/imx6q-sbcx-cb0012.dtb'.
+
Filename 'axel/imx6dl-sbcx-cb0012.dtb'.
 
Load address: 0x18000000
 
Load address: 0x18000000
 
Loading: ###########
 
Loading: ###########
         564.5 KiB/s
+
         858.4 KiB/s
 
done
 
done
Bytes transferred = 53760 (d200 hex)
+
Bytes transferred = 51910 (cac6 hex)
  
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
Line 388: Line 398:
 
OK
 
OK
  
NAND write: device 0 offset 0xa00000, size 0xd200
+
NAND write: device 0 offset 0xa00000, size 0xcac6
  53760 bytes written: OK
+
  51910 bytes written: OK
=>
 
 
</pre>
 
</pre>
  
Line 402: Line 411:
 
=== Program boot images into eMMC ===
 
=== Program boot images into eMMC ===
  
====u-Boot====
+
{{ImportantMessage|text=This example was not tested with '''DESK-MX6-L 3.0.0''' release as '''SBCX''' do not have internal eMMC. Nevertheless provided commands should work on other platforms that do have this storage.}}
Update to the latest u-boot version allows usage of u-boot environment variables available.
+
 
 +
====U-Boot====
 +
Update to the latest U-Boot version allows usage of U-Boot environment variables available.
  
 
<pre>
 
<pre>
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
+
=> printenv mmc_update_spl
 +
mmc_update_spl=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
 +
=> printenv mmc_update_uboot
 +
mmc_update_uboot=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 0x8a  ${blocks}
 
</pre>
 
</pre>
  
Load u-boot binary form a <code>tftp</code> server:
+
Load U-Boot binary form a <code>tftp</code> server:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
=> run load_spl
+
=> run load_spl  
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.125; our IP address is 192.168.0.90
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.49
Filename 'desk-mx-l/SPL'.
+
Filename 'axel/SPL'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: ############
 
Loading: ############
         560.5 KiB/s
+
         1.1 MiB/s
 
done
 
done
Bytes transferred = 56320 (dc00 hex)
+
Bytes transferred = 60416 (ec00 hex)
=> run mmc_update_spl
+
=> run mmc_update_spl  
 
switch to partitions #0, OK
 
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
+
mmc0 is current device (SD)
  
MMC write: dev # 2, block # 2, count 1313 ... 1313 blocks written: OK
+
MMC write: dev # 0, block # 2, count 119 ... 119 blocks written: OK
=> run load_uboot
+
=> run load_uboot  
 
Using FEC device
 
Using FEC device
TFTP from server 192.168.0.125; our IP address is 192.168.0.90
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.49
Filename 'desk-mx-l/u-boot.img'.
+
Filename 'axel/u-boot.img'.
 
Load address: 0x12000000
 
Load address: 0x12000000
 
Loading: #################################################################
 
Loading: #################################################################
         ###############################################
+
         ##########################################################
         1009.8 KiB/s
+
         1.5 MiB/s
 
done
 
done
Bytes transferred = 569864 (8b208 hex)
+
Bytes transferred = 624932 (98924 hex)
=> run mmc_update_uboot
+
=> run mmc_update_uboot  
 
switch to partitions #0, OK
 
switch to partitions #0, OK
mmc2 is current device (eMMC)
+
mmc0 is current device (SD)
  
MMC write: dev # 2, block # 138, count 1114 ... 1114 blocks written: OK
+
MMC write: dev # 0, block # 138, count 1221 ... 1221 blocks written: OK
=>
 
 
</pre>
 
</pre>
  
Load u-boot binary form an <code>SD</code> card:
+
Load U-Boot binary from an <code>SD</code> card:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 473: Line 486:
 
====kernel image and device tree====
 
====kernel image and device tree====
  
We assume that the following environment variables are present in u-boot:
+
We assume that the following environment variables are present in U-Boot:
  
 
<pre>
 
<pre>
Line 479: Line 492:
 
mmc_loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
 
mmc_loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
 
mmc_loadsplash=fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}
 
mmc_loadsplash=fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}
mmcboot=run mmcargs addcons addmisc; if run mmc_loadk; then if run mmc_loadfdt; then if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi; fi; fi
+
mmcboot=run mmcargs addcons addmisc; if run mmc_loadk; then if run mmc_loadfdt; then bootm ${loadaddr} - ${fdtaddr}; fi; fi
 
</pre>
 
</pre>
  
 
Using an SD card or an eMMC device assumes that <code>bootfile</code>, <code>fdtfile</code> and <code>splashfile</code> are stored into fist MMC device partition.  
 
Using an SD card or an eMMC device assumes that <code>bootfile</code>, <code>fdtfile</code> and <code>splashfile</code> are stored into fist MMC device partition.  
  
Then, u-boot uses the previous listed commands for reading the binary images and starting the linux bootstrap from the ''MMC part 2'' (which is reserved for the root-file system storage).
+
Then, U-Boot uses the previous listed commands for reading the binary images and starting the linux bootstrap from the ''MMC part 2'' (which is reserved for the root-file system storage).
  
The following u-boot environment variables are present for this purposes:
+
The following U-Boot environment variables are present for this purposes:
 
<pre>
 
<pre>
 
mmcargs=setenv bootargs root=${mmcroot}
 
mmcargs=setenv bootargs root=${mmcroot}
Line 494: Line 507:
 
==== boot vars ====
 
==== boot vars ====
  
The following environment variables should be configured for u-boot properly reading the boot files from the first SD card partition, e.g.
+
The following environment variables should be configured for U-Boot properly reading the boot files from the first SD card partition, e.g.
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
=> setenv normalboot mmcboot
 
=> setenv normalboot mmcboot
 
=> setenv bootfile uImage
 
=> setenv bootfile uImage
=> setenv fdtfile imx6q-sbcx-cb0012.dtb
+
=> setenv fdtfile imx6dl-sbcx-cb0012.dtb
 
=> setenv splashfile splash_image.bmp
 
=> setenv splashfile splash_image.bmp
 
</pre>
 
</pre>
Line 514: Line 527:
 
=== Program root file system into NAND flash ===
 
=== Program root file system into NAND flash ===
  
* Boot the system via SD or NFS as described in the e [[(<KIT>)#Quick_start_guide|Quick start guide]]
+
* Boot the system via SD or NFS as described in the [[(<KIT>)#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="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@imx6qdlxelk:~# cat /proc/mtd
 
root@imx6qdlxelk:~# cat /proc/mtd
Line 531: Line 544:
 
</pre>
 
</pre>
  
{{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}}
+
{{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}}
  
  
Line 545: Line 558:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# ubiformat /dev/mtd8
+
root@desk-mx6:~# ubiformat /dev/mtd8
 
ubiformat: mtd8 (nand), size 1048576000 bytes (1000.0 MiB), 8000 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
 
ubiformat: mtd8 (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
+
libscan: scanning eraseblock 7999 -- 100 % complete
ubiformat: 8000 eraseblocks have valid erase counter, mean value is 1
+
ubiformat: 8000 eraseblocks have valid erase counter, mean value is 48
ubiformat: formatting eraseblock 7999 -- 100 % complete
+
ubiformat: formatting eraseblock 7999 -- 100 % complete
root@imx6qdlxelk:~# ubiattach -m 8
+
root@desk-mx6:~# ubiattach -m 8
[ 1714.823600] UBI: attaching mtd8 to ubi0
+
[ 360.013629] ubi0: attaching mtd8
[ 1726.415587] UBI: scanning is finished
+
[ 361.991725] ubi0: scanning is finished
[ 1726.483765] UBI: attached mtd8 (name "nand-ubi", size 1000 MiB) to ubi0
+
[ 362.009988] ubi0: attached mtd8 (name "nand-ubi", size 1000 MiB)
[ 1726.491062] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
+
[ 362.016138] ubi0: 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
+
[ 362.023029] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 1726.505030] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
+
[ 362.030324] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 1726.512430] UBI: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
+
[ 362.037598] ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
[ 1726.518861] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
+
[ 362.043702] ubi0: 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
+
[ 362.051238] ubi0: max/mean erase counter: 60/49, WL threshold: 4096, image sequence number: 1933293895
[ 1726.535433] UBI: available PEBs: 7836, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
+
[ 362.060761] ubi0: available PEBs: 7836, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
[ 1726.545260] UBI: background thread "ubi_bgt0d" started, PID 714
+
[ 362.070564] ubi0: background thread "ubi_bgt0d" started, PID 636
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)
+
UBI device number 0, total 8000 LEBs (1015808000 bytes, 968.7 MiB), available 7836 LEBs (994983936 bytes, 948.8 MiB), LEB size 126976 bytes (124.0 KiB)
root@imx6qdlxelk:~# ubimkvol /dev/ubi0 -N rootfs -m
+
root@desk-mx6:~# ubimkvol /dev/ubi0 -N rootfs -m
 
Set volume size to 994983936
 
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
+
Volume ID 0, size 7836 LEBs (994983936 bytes, 948.8 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
 
</pre>
 
</pre>
  
Line 578: Line 591:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# mkdir -p /mnt/nand
+
root@desk-mx6:~# mkdir -p /mnt/nand
root@imx6qdlxelk:~# mount -t ubifs ubi0_0 /mnt/nand
+
root@desk-mx6:~# mount -t ubifs ubi0_0 /mnt/nand/
[ 1810.301461] UBIFS: default file-system created
+
[ 409.697677] UBIFS (ubi0:0): default file-system created
[ 1810.308952] UBIFS: background thread "ubifs_bgt0_0" started, PID 717
+
[ 409.703241] UBIFS (ubi0:0): Mounting in unauthenticated mode
[ 1810.452274] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
+
[  409.709114] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 655
[ 1810.459421] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
+
[ 409.742889] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 1810.469398] UBIFS: FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
+
[ 409.750360] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 1810.480976] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
+
[ 409.760923] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[ 1810.487210] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 99D0F3C6-5955-4B30-9E2D-72202281BD30, small LPT model
+
[ 409.772226] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
 +
[ 409.778855] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 98CA79BD-2EC2-4B4E-A244-32553E1049FC, small LPT model
 
</pre>
 
</pre>
  
Line 592: Line 606:
  
 
<pre>
 
<pre>
tar xvjf desk-image-qt5-desk-mx6.tar.bz2 -C /mnt/nand
+
tar xvjf dave-image-devel-desk-mx6.tar.bz2 -C /mnt/nand
 
</pre>
 
</pre>
  
Line 605: Line 619:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# umount /mnt/nand/
+
root@desk-mx6:~# umount /mnt/nand/
[ 2446.743091] UBIFS: un-mount UBI device 0, volume 0
+
[ 4485.370345] UBIFS (ubi0:0): un-mount UBI device 0
[ 2446.749670] UBIFS: background thread "ubifs_bgt0_0" stops
+
[ 4485.377962] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
root@imx6qdlxelk:~# ubidetach -m 8
+
root@desk-mx6:~# ubidetach -m 8
[ 2450.738153] UBI: detaching mtd8 from ubi0
+
[ 4493.929166] ubi0: detaching mtd8
[ 2450.759527] UBI: mtd8 is detached from ubi0
+
[ 4493.942262] ubi0: mtd8 is detached
 
</pre>
 
</pre>
  
Line 623: Line 637:
 
=== Program root file system into eMMC flash ===
 
=== Program root file system into eMMC flash ===
  
* Boot the system via SD or NFS as described in the e [[(<KIT>)#Quick_start_guide|Quick start guide]]
+
{{ImportantMessage|text=This example was not tested with '''DESK-MX6-L 3.0.0''' release as '''SBCX''' do not have internal eMMC. Nevertheless provided commands should work on other platforms that do have this storage.}}
 +
* Boot the system via SD or NFS as described in the [[(<KIT>)#Quick_start_guide|Quick start guide]]
 
* eMMC device has to be partitioned and properly formatted choosing the <code>file system</code> for each partition
 
* eMMC device has to be partitioned and properly formatted choosing the <code>file system</code> for each partition
 
* an example of SD partitioning script is the following one:
 
* an example of SD partitioning script is the following one:
Line 672: Line 687:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# ./sdcard-partition.sh /dev/mmcblk2
+
root@desk-mx6:~# ./sdcard-partition.sh /dev/mmcblk2
 
SD total size: 3776KB
 
SD total size: 3776KB
 
[ 1341.905014]  mmcblk2: p1 p2
 
[ 1341.905014]  mmcblk2: p1 p2
Line 719: Line 734:
 
Creating journal (16384 blocks): done
 
Creating journal (16384 blocks): done
 
Writing superblocks and filesystem accounting information: done
 
Writing superblocks and filesystem accounting information: done
 
root@imx6qdlxelk:~#
 
 
</pre>
 
</pre>
  
Line 732: Line 745:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# mount /dev/mmcblk2p1 /mnt/emmc
+
root@desk-mx6:~# mount /dev/mmcblk2p1 /mnt/emmc
 
[  40.988575] FAT-fs (mmcblk2p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
 
[  40.988575] FAT-fs (mmcblk2p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
root@imx6qdlxelk:~# cd /mnt/emmc
+
root@desk-mx6:~# cd /mnt/emmc
root@imx6qdlxelk:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*dtb .
+
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*dtb .
root@imx6qdlxelk:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*uImage .
+
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*uImage .
root@imx6qdlxelk:/mnt/emmc# cp /tftpboot/desk-mx/linux/splash_image.bmp .
+
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/splash_image.bmp .
root@imx6qdlxelk:/mnt/emmc# cd
+
root@desk-mx6:/mnt/emmc# cd
root@imx6qdlxelk:~# umount /mnt/emmc
+
root@desk-mx6:~# umount /mnt/emmc
 
</pre>
 
</pre>
  
Line 747: Line 760:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:~# mount /dev/mmcblk2p2 /mnt/emmc
+
root@desk-mx6:~# mount /dev/mmcblk2p2 /mnt/emmc
 
[ 1810.899327] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
 
[ 1810.899327] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
root@imx6qdlxelk:~# cd /mnt/emmc
+
root@desk-mx6:~# cd /mnt/emmc
root@imx6qdlxelk:/mnt/emmc#  
+
root@desk-mx6:/mnt/emmc#  
 
</pre>
 
</pre>
  
Line 756: Line 769:
  
 
<pre>
 
<pre>
tar xvjf axel-image-qt5-imx6qdlxelk.tar.tar.bz2
+
tar xvjf dave-image-devel-desk-mx6.tar.bz2 -C /mnt/emmc
 
</pre>
 
</pre>
  
Line 762: Line 775:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@imx6qdlxelk:/mnt/emmc# cd
+
root@desk-mx6:/mnt/emmc# cd
root@imx6qdlxelk:~# umount /mnt/emmc
+
root@desk-mx6:~# umount /mnt/emmc
root@imx6qdlxelk:~# reboot
+
root@desk-mx6:~# reboot
 
</pre>
 
</pre>
  
Line 783: Line 796:
 
  mkfs.ext4 -F ${node}${part}1 -Lboot
 
  mkfs.ext4 -F ${node}${part}1 -Lboot
  
then, the u-boot <code>environment</code> has to be properly configured:
+
then, the U-Boot <code>environment</code> has to be properly configured:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 801: Line 814:
 
...
 
...
 
...
 
...
[    2.884838] Creating 9 MTD partitions on "gpmi-nand":
+
[    3.859646] 9 cmdlinepart partitions found on MTD device gpmi-nand
[    2.889901] 0x000000000000-0x000000200000 : "nand-SPL"
+
[    3.865861] Creating 9 MTD partitions on "gpmi-nand":
[    2.904875] 0x000000200000-0x000000800000 : "nand-uboot"
+
[    3.870924] 0x000000000000-0x000000200000 : "nand-SPL"
[    2.914921] 0x000000800000-0x000000900000 : "nand-env1"
+
[    3.885045] 0x000000200000-0x000000800000 : "nand-uboot"
[    2.924903] 0x000000900000-0x000000a00000 : "nand-env2"
+
[    3.895099] 0x000000800000-0x000000900000 : "nand-env1"
[    2.934931] 0x000000a00000-0x000000b00000 : "nand-fdt"
+
[    3.905059] 0x000000900000-0x000000a00000 : "nand-env2"
[    2.944880] 0x000000b00000-0x000000c00000 : "nand-spare"
+
[    3.915071] 0x000000a00000-0x000000b00000 : "nand-fdt"
[    2.954958] 0x000000c00000-0x000001400000 : "nand-kernel"
+
[    3.925049] 0x000000b00000-0x000000c00000 : "nand-spare"
[    2.964920] 0x000001400000-0x000001800000 : "nand-splash"
+
[    3.935124] 0x000000c00000-0x000001400000 : "nand-kernel"
[    2.974934] 0x000001800000-0x000020000000 : "nand-ubi"
+
[    3.945057] 0x000001400000-0x000001800000 : "nand-splash"
 +
[    3.955104] 0x000001800000-0x000040000000 : "nand-ubi"
 
...
 
...
 
...
 
...
Line 820: Line 834:
 
...
 
...
 
...
 
...
[    4.708969] ubi0: attaching mtd8
+
[    5.559821] ubi0: attaching mtd8
[    9.673466] ubi0: scanning is finished
+
[    7.990342] ubi0: scanning is finished
[    9.702506] ubi0: attached mtd8 (name "nand-ubi", size 488 MiB)
+
[    8.021500] ubi0: attached mtd8 (name "nand-ubi", size 1000 MiB)
[    9.708522] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
+
[    8.027595] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    9.715452] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
+
[    8.034504] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    9.722260] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
+
[    8.041299] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    9.729329] ubi0: good PEBs: 3903, bad PEBs: 1, corrupted PEBs: 0
+
[    8.048291] ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
[    9.735502] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
+
[    8.054414] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[    9.742759] ubi0: max/mean erase counter: 17/11, WL threshold: 4096, image sequence number: 855057006
+
[    8.061644] ubi0: max/mean erase counter: 63/52, WL threshold: 4096, image sequence number: 819217695
[    9.752222] ubi0: available PEBs: 16, total reserved PEBs: 3887, PEBs reserved for bad PEB handling: 79
+
[    8.070886] ubi0: available PEBs: 0, total reserved PEBs: 8000, PEBs reserved for bad PEB handling: 160
[    9.761688] ubi0: background thread "ubi_bgt0d" started, PID 140
+
[    8.080359] ubi0: background thread "ubi_bgt0d" started, PID 157
[    9.815346] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 141
+
[    8.164282] UBIFS (ubi0:0): Mounting in unauthenticated mode
[    9.941878] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
+
[    8.170156] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 163
[    9.949339] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
+
[    8.210063] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[    9.959283] UBIFS (ubi0:0): FS size: 480985088 bytes (458 MiB, 3788 LEBs), journal size 24125440 bytes (23 MiB, 190 LEBs)
+
[    8.217549] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    9.970279] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
+
[    8.227505] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[    9.976924] UBIFS (ubi0:0): media format: w4/r0 (latest is w5/r0), UUID 759D6A88-1C15-4293-BA54-6D740D559A46, small LPT model
+
[    8.238514] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[    9.991302] VFS: Mounted root (ubifs filesystem) on device 0:13.
+
[    8.245169] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID BEC33049-213B-4D02-A9CE-5F0D7EB5DAA8, small LPT model
[    9.999829] devtmpfs: mounted
+
[    8.257174] VFS: Mounted root (ubifs filesystem) on device 0:14.
[  10.003881] Freeing unused kernel memory: 1024K
 
INIT: version 2.88 booting
 
 
...
 
...
 
...
 
...
Line 849: Line 861:
 
...
 
...
 
...
 
...
[ 3.938852] mmc0: host does not support reading read-only switch, assuming write-enable
+
[   5.061660] mmc0: new high speed SDHC card at address aaaa
[ 3.952617] mmc0: new high speed SDHC card at address aaaa
+
[   5.071528] mmcblk0: mmc0:aaaa SC16G 14.8 GiB
[ 3.958846] mmcblk0: mmc0:aaaa SC16G 14.8 GiB
+
[    5.071528] mmcblk0: mmc0:aaaa SC16G 14.8 GiB  
[ 3.972173] mmcblk0: p1 p2
+
[   5.088454] mmcblk0: p1 p2
 
...
 
...
 
...
 
...
Line 864: Line 876:
 
...
 
...
 
...
 
...
[ 4.782443] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
+
[   5.681176] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 4.790648] VFS: Mounted root (ext4 filesystem) on device 179:2.
+
[   5.689678] VFS: Mounted root (ext3 filesystem) on device 179:2.
[ 4.807855] devtmpfs: mounted
+
[   5.707149] devtmpfs: mounted
[ 4.811984] Freeing unused kernel memory: 1024K
+
[   5.713124] Freeing unused kernel memory: 1024K
 
...
 
...
 
...
 
...

Revision as of 13:22, 25 February 2022

History
Version Issue Date Notes

1.0.0

Jun 2021 First DESK release
1.0.1 Jun 2022 U-Boot root file system parameters
3.0.0 Feb 2022 3.0.0 DESK release tested on SBCX


Standalone boot[edit | edit source]

Introduction[edit | edit source]

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.


200px-Emblem-important.svg.png

The following programming examples are intended for laboratory usage or for preliminary deployment strategy.

A complete deployment strategy has to be carefully identifiyed taking into account the overall arguments like: boot speed, safe boot, recovery mechanisms, watchdog supervisor, etc.


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

  • booting with NOR and NAND internal storage
    • in this configuration the primary boot images will be fetched from NOR flash storage, while the root file system will be fetched from NAND flash
  • 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
  • booting with eMMC only
    • in this configuration the whole system will boot without the need of a NOR/NAND flashes storage, all images and the root file system will be fetched from eMMC flash

Program boot images into NOR flash[edit | edit source]

200px-Emblem-important.svg.png

This example was not tested with DESK-MX6-L 3.0.0 release as SBCX do not have NOR flash. Nevertheless provided commands should work on other platforms that do have this storage.

It is supposed that the proper filenames are configured on U-Boot variables. Those files should be available on TFTP server. In the following examples, we use the boot images:

spl=desk-mx-l/SPL
ubootimg=desk-mx-l/u-boot.img
bootfile=desk-mx-l/uImage
fdtfile=desk-mx-l/imx6q-sbcx-cb0012.dtb

We assume that the following environment variables are present in U-Boot too:

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[edit | edit source]

Update to the latest U-Boot version allows usage of U-Boot environment variables available.

=> run load_spl
Using FEC device
TFTP from server 192.168.0.125; our IP address is 192.168.0.90
Filename 'desk-mx-l/SPL'.
Load address: 0x12000000
Loading: ############
         560.5 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.125; our IP address is 192.168.0.90
Filename 'desk-mx-l/u-boot.img'.
Load address: 0x12000000
Loading: #################################################################
         ###############################################
         1009.8 KiB/s
done
Bytes transferred = 569864 (8b208 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 0x8b208
SF: 569864 bytes @ 0x10000 Written: OK
=>

kernel image and device tree[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 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 FEC device
TFTP from server 192.168.0.125; our IP address is 192.168.0.90
Filename 'desk-mx-l/uImage'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########
         1.2 MiB/s
done
Bytes transferred = 7031520 (6b4ae0 hex)
SF: 8388608 bytes @ 0x200000 Erased: OK
device 0 offset 0x200000, size 0x6b4ae0
SF: 7031520 bytes @ 0x200000 Written: OK
Using FEC device
TFTP from server 192.168.0.125; our IP address is 192.168.0.90
Filename 'desk-mx-l/imx6q-sbcx-cb0012.dtb'.
Load address: 0x18000000
Loading: ###########
         564.5 KiB/s
done
Bytes transferred = 53760 (d200 hex)
SF: 524288 bytes @ 0x180000 Erased: OK
device 0 offset 0x180000, size 0xd200
SF: 53760 bytes @ 0x180000 Written: OK
=>

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

=> setenv bootcmd run spi_nand
=> saveenv

Program boot images into NAND flash[edit | edit source]

U-Boot[edit | edit source]

U-Boot SPL on NAND flash must be programmed using NXP kobs-ng utility and the second stage using the nandwrite: this tool is required for writing the correct U-Boot image on NAND storing all information needed by bootrom to identify the NAND as a boot device.

Here below an example:

  • boot the system via SD on NFS
  • uses a rfs with kobs-ng utility available on it (e.g. DAVE's rfs provided with <KIT>)
  • copy the related U-Boot imx image file on nfs /home/root (for example)
  • execute kobs-ng passing the parameters for flashing U-Boot on NAND
  • erase and program the second stage using flash_erase and nandwrite
root@desk-mx6:~# kobs-ng -x -v -w desk-mx6-l-3.0.0_mx6qdldesk_nand_SPL
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
  secondary_boot_stream_off_in_MB = 64
         -- 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 = 61440
mtd: boot_stream_size_in_pages = 30
mtd: #1 0x00100000 - 0x00180000 (0x0010f000)
mtd: #2 0x00180000 - 0x00200000 (0x0018f000)
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 = 30
  m_u32PagesInFirmware2 = 30
  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 0xf000 - available 0x80000
Firmware: image #1 @ 0x180000 size 0xf000 - available 0x80000
-------------- Start to write the [ FCB ] -----
-------------- Start to write the [ FCB ] -----
mtd: erasing @0:0x0-0x20000
mtd: Writing FCB0 [ @0:0x0 ] (840) *
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 0

-------------- 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 - 0x0010f000
mtd: erasing @0:0x100000-0x120000
mtd: We write one page for save guard. *
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018f000
mtd: erasing @0:0x180000-0x1a0000
mtd: We write one page for save guard. *
root@desk-mx6:~# flash_erase /dev/mtd1 0 0
Erasing 128 Kibyte @ 5e0000 -- 100 % complete 
root@desk-mx6:~# nandwrite -p /dev/mtd1 desk-mx6-l-3.0.0_mx6qdldesk_nand_u-boot.img 
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
Writing data to block 4 at offset 0x80000

kernel image and device tree[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.:

=> run loadk nand_updatek loadfdt nand_updatefdt
Using FEC device
TFTP from server 192.168.4.240; our IP address is 192.168.4.231
Filename 'axel/uImage'.
Load address: 0x12000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################
         1.5 MiB/s
done
Bytes transferred = 8154280 (7c6ca8 hex)

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

NAND write: device 0 offset 0xc00000, size 0x7c6ca8
 8154280 bytes written: OK
Using FEC device
TFTP from server 192.168.4.240; our IP address is 192.168.4.231
Filename 'axel/imx6dl-sbcx-cb0012.dtb'.
Load address: 0x18000000
Loading: ###########
         858.4 KiB/s
done
Bytes transferred = 51910 (cac6 hex)

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

NAND write: device 0 offset 0xa00000, size 0xcac6
 51910 bytes written: OK

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

=> setenv bootcmd run nand_nand
=> saveenv

Program boot images into eMMC[edit | edit source]

200px-Emblem-important.svg.png

This example was not tested with DESK-MX6-L 3.0.0 release as SBCX do not have internal eMMC. Nevertheless provided commands should work on other platforms that do have this storage.

U-Boot[edit | edit source]

Update to the latest U-Boot version allows usage of U-Boot environment variables available.

=> printenv mmc_update_spl 
mmc_update_spl=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
=> printenv mmc_update_uboot 
mmc_update_uboot=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 0x8a  ${blocks}

Load U-Boot binary form a tftp server:

=> run load_spl 
Using FEC device
TFTP from server 192.168.4.240; our IP address is 192.168.4.49
Filename 'axel/SPL'.
Load address: 0x12000000
Loading: ############
         1.1 MiB/s
done
Bytes transferred = 60416 (ec00 hex)
=> run mmc_update_spl 
switch to partitions #0, OK
mmc0 is current device (SD)

MMC write: dev # 0, block # 2, count 119 ... 119 blocks written: OK
=> run load_uboot 
Using FEC device
TFTP from server 192.168.4.240; our IP address is 192.168.4.49
Filename 'axel/u-boot.img'.
Load address: 0x12000000
Loading: #################################################################
         ##########################################################
         1.5 MiB/s
done
Bytes transferred = 624932 (98924 hex)
=> run mmc_update_uboot 
switch to partitions #0, OK
mmc0 is current device (SD)

MMC write: dev # 0, block # 138, count 1221 ... 1221 blocks written: OK

Load U-Boot binary from an SD card:

Hit ENTER within 1 seconds to stop autoboot
=> fatload mmc 0:1 ${loadaddr} SPL
56320 bytes read in 20 ms (2.7 MiB/s)
=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
=> run mmc_update_spl
switch to partitions #0, OK
mmc2 is current device (eMMC)

MMC write: dev # 2, block # 2, count 111 ... 111 blocks written: OK
=> fatload mmc 0:1 ${loadaddr} u-boot.img
569864 bytes read in 45 ms (12.1 MiB/s)
=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
=> run mmc_update_uboot
switch to partitions #0, OK
mmc2 is current device (eMMC)

MMC write: dev # 2, block # 138, count 1114 ... 1114 blocks written: OK
=>

kernel image and device tree[edit | edit source]

We assume that the following environment variables are present in U-Boot:

mmc_loadk=fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}
mmc_loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
mmc_loadsplash=fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}
mmcboot=run mmcargs addcons addmisc; if run mmc_loadk; then if run mmc_loadfdt; then bootm ${loadaddr} - ${fdtaddr}; fi; fi

Using an SD card or an eMMC device assumes that bootfile, fdtfile and splashfile are stored into fist MMC device partition.

Then, U-Boot uses the previous listed commands for reading the binary images and starting the linux bootstrap from the MMC part 2 (which is reserved for the root-file system storage).

The following U-Boot environment variables are present for this purposes:

mmcargs=setenv bootargs root=${mmcroot}
mmcroot=/dev/mmcblk2p2 rootwait rw

boot vars[edit | edit source]

The following environment variables should be configured for U-Boot properly reading the boot files from the first SD card partition, e.g.

=> setenv normalboot mmcboot
=> setenv bootfile uImage
=> setenv fdtfile imx6dl-sbcx-cb0012.dtb
=> setenv splashfile splash_image.bmp

then save the environment and reboot the system to apply the new configuration:

=> saveenv
Saving Environment to MMC...
Writing to MMC(2)... done
=> reset

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

  • Boot the system via SD or NFS as described in the [[(<KIT>)#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 MTD partitions can be dumped with /proc/mtd (the partition's name should be self-explanatory)
root@imx6qdlxelk:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "nand-SPL"
mtd1: 00600000 00020000 "nand-uboot"
mtd2: 00100000 00020000 "nand-env1"
mtd3: 00100000 00020000 "nand-env2"
mtd4: 00100000 00020000 "nand-fdt"
mtd5: 00100000 00020000 "nand-spare"
mtd6: 00800000 00020000 "nand-kernel"
mtd7: 00400000 00020000 "nand-splash"
mtd8: 1e800000 00020000 "nand-ubi"
root@imx6qdlxelk:~#


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


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

E.g.

root@desk-mx6:~# ubiformat /dev/mtd8
ubiformat: mtd8 (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 48
ubiformat: formatting eraseblock 7999 -- 100 % complete  
root@desk-mx6:~# ubiattach -m 8
[  360.013629] ubi0: attaching mtd8
[  361.991725] ubi0: scanning is finished
[  362.009988] ubi0: attached mtd8 (name "nand-ubi", size 1000 MiB)
[  362.016138] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[  362.023029] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[  362.030324] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[  362.037598] ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
[  362.043702] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[  362.051238] ubi0: max/mean erase counter: 60/49, WL threshold: 4096, image sequence number: 1933293895
[  362.060761] ubi0: available PEBs: 7836, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
[  362.070564] ubi0: background thread "ubi_bgt0d" started, PID 636
UBI device number 0, total 8000 LEBs (1015808000 bytes, 968.7 MiB), available 7836 LEBs (994983936 bytes, 948.8 MiB), LEB size 126976 bytes (124.0 KiB)
root@desk-mx6:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 994983936
Volume ID 0, size 7836 LEBs (994983936 bytes, 948.8 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@desk-mx6:~# mkdir -p /mnt/nand
root@desk-mx6:~# mount -t ubifs ubi0_0 /mnt/nand/
[  409.697677] UBIFS (ubi0:0): default file-system created
[  409.703241] UBIFS (ubi0:0): Mounting in unauthenticated mode
[  409.709114] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 655
[  409.742889] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  409.750360] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  409.760923] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[  409.772226] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[  409.778855] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 98CA79BD-2EC2-4B4E-A244-32553E1049FC, small LPT model
  • you can now extract the root file system into that directory
tar xvjf dave-image-devel-desk-mx6.tar.bz2 -C /mnt/nand
  • finally, you need to cleanly umount and detach the MTD partition
umount /mnt/nand/
ubidetach -m 8

E.g.

root@desk-mx6:~# umount /mnt/nand/
[ 4485.370345] UBIFS (ubi0:0): un-mount UBI device 0
[ 4485.377962] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
root@desk-mx6:~# ubidetach -m 8
[ 4493.929166] ubi0: detaching mtd8
[ 4493.942262] ubi0: mtd8 is detached

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=8

Program root file system into eMMC flash[edit | edit source]

200px-Emblem-important.svg.png

This example was not tested with DESK-MX6-L 3.0.0 release as SBCX do not have internal eMMC. Nevertheless provided commands should work on other platforms that do have this storage.

  • Boot the system via SD or NFS as described in the [[(<KIT>)#Quick_start_guide|Quick start guide]]
  • eMMC device has to be partitioned and properly formatted choosing the file system for each partition
  • an example of SD partitioning script is the following one:

FAT32 partition[edit | edit source]

#!/bin/sh

node=$1

# partition size in MB
BOOTLOAD_RESERVE=8
BOOT_ROM_SIZE=128
RFS_SIZE=2048

# create the SDCARD partition
part=""
echo ${node} | grep mmcblk > /dev/null
if [ "$?" -eq "0" ]; then
        part="p"
fi

# print the SD total capacity
total_size=`sfdisk -s ${node}`
total_size=`expr ${total_size} / 1024`
echo SD total size: ${total_size}KB

# calculate partition sizes
boot_start=`expr ${BOOTLOAD_RESERVE} \\* 1024 \\* 1024 / 512`
boot_size=`expr ${BOOT_ROM_SIZE} \\* 1024 \\* 1024 / 512`
rfs_start=`expr ${boot_size} + ${boot_start}`
rfs_size=`expr ${RFS_SIZE} \\* 1024 \\* 1024 / 512`

umount ${node}${part}1 > /dev/null 2>&1
umount ${node}${part}2 > /dev/null 2>&1

# call sfdisk to create partition table
{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}

# format the SDCARD partition
echo "formatting boot"
mkfs.vfat -F 32 -n boot ${node}${part}1
echo "formatting rfs"
mkfs.ext4 -F ${node}${part}2 -Lrfs

E.g.

root@desk-mx6:~# ./sdcard-partition.sh /dev/mmcblk2
SD total size: 3776KB
[ 1341.905014]  mmcblk2: p1 p2
Checking that no-one is using this disk right now ... OK

Disk /dev/mmcblk2: 3.7 GiB, 3959422976 bytes, 7733248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical):[ 1341.922729]  mmcblk2: p1 p2
 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa77eb3f0

Old situation:

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk2p1        2048  264191  262144  128M  c W95 FAT32 (LBA)
/dev/mmcblk2p2      264192 4458495 4194304    2G 83 Linux

>>> Created a new DOS disklabel with disk identifier 0xcce0c36f.
Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 128 MiB.
/dev/mmcblk2p2: Created a new partition 2 of type 'Linux' and of size 2 GiB.
/dev/mmcblk2p3:
New situation:

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk2p1       16384  278527  262144  128M  c W95 FAT32 (LBA)
/dev/mmcblk2p2      278528 4472831 4194304    2G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
formatting boot
mkfs.fat 3.0.28 (2015-05-16)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
formatting rfs
mke2fs 1.43-WIP (18-May-2015)
Discarding device blocks: done
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 9a685543-1af2-4e39-83f3-b8a32248c021
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
  • create a mount point and mount the first partition
mkdir -p /mnt/emmc
mount /dev/mmcblk2p1 /mnt/emmc
  • copy kernel, dtb and splash_image files
root@desk-mx6:~# mount /dev/mmcblk2p1 /mnt/emmc
[   40.988575] FAT-fs (mmcblk2p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
root@desk-mx6:~# cd /mnt/emmc
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*dtb .
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/desk-mx-1.0.0*uImage .
root@desk-mx6:/mnt/emmc# cp /tftpboot/desk-mx/linux/splash_image.bmp .
root@desk-mx6:/mnt/emmc# cd
root@desk-mx6:~# umount /mnt/emmc
  • now mount the EXT4 volume in the temporary directory

E.g.:

root@desk-mx6:~# mount /dev/mmcblk2p2 /mnt/emmc
[ 1810.899327] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
root@desk-mx6:~# cd /mnt/emmc
root@desk-mx6:/mnt/emmc# 
  • you can now extract the root file system into that directory
tar xvjf dave-image-devel-desk-mx6.tar.bz2 -C /mnt/emmc
  • finally, you need to cleanly umount and safely reboot or turn off the system.
root@desk-mx6:/mnt/emmc# cd
root@desk-mx6:~# umount /mnt/emmc
root@desk-mx6:~# reboot

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

=> setenv bootcmd run mmcboot
=> saveenv

ext4 partition[edit | edit source]

For using an ext4 partition also for boot files, it is possibile to change the formatting script:

{ echo ${boot_start},${boot_size},83,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}

and formatting the first partition using mkfs.ext4

mkfs.ext4 -F ${node}${part}1 -Lboot

then, the U-Boot environment has to be properly configured:

=> setenv mmc_loadk 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'
=> setenv mmc_loadfdt 'ext4load mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}'
=> setenv mmc_loadsplash 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}'
=> saveenv

U-Boot parameters for root file system device[edit | edit source]

Once booted, the kernel looks for a device where reading and starting the root file system. See more information in the man pages.

Here below some examples and configuration used in the DAVE's U-Boot environment:

rfs in NAND[edit | edit source]

The root file system can be programmed into an UBI formatted partition and, for example, the nandargs parameters can be used. The following rows show the standard DAVE's NAND partitioning:

...
...
[    3.859646] 9 cmdlinepart partitions found on MTD device gpmi-nand
[    3.865861] Creating 9 MTD partitions on "gpmi-nand":
[    3.870924] 0x000000000000-0x000000200000 : "nand-SPL"
[    3.885045] 0x000000200000-0x000000800000 : "nand-uboot"
[    3.895099] 0x000000800000-0x000000900000 : "nand-env1"
[    3.905059] 0x000000900000-0x000000a00000 : "nand-env2"
[    3.915071] 0x000000a00000-0x000000b00000 : "nand-fdt"
[    3.925049] 0x000000b00000-0x000000c00000 : "nand-spare"
[    3.935124] 0x000000c00000-0x000001400000 : "nand-kernel"
[    3.945057] 0x000001400000-0x000001800000 : "nand-splash"
[    3.955104] 0x000001800000-0x000040000000 : "nand-ubi"
...
...

and then the corresponding U-Boot parameter for using the /dev/mtd8 device:

nandargs=setenv bootargs ubi.mtd=8 root=ubi0_0 rootfstype=ubifs rw

In this configuration, the kernel attachs the UBI partition, mount the UBIFS file system and starts it:

...
...
[    5.559821] ubi0: attaching mtd8
[    7.990342] ubi0: scanning is finished
[    8.021500] ubi0: attached mtd8 (name "nand-ubi", size 1000 MiB)
[    8.027595] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    8.034504] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    8.041299] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    8.048291] ubi0: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
[    8.054414] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[    8.061644] ubi0: max/mean erase counter: 63/52, WL threshold: 4096, image sequence number: 819217695
[    8.070886] ubi0: available PEBs: 0, total reserved PEBs: 8000, PEBs reserved for bad PEB handling: 160
[    8.080359] ubi0: background thread "ubi_bgt0d" started, PID 157
[    8.164282] UBIFS (ubi0:0): Mounting in unauthenticated mode
[    8.170156] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 163
[    8.210063] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[    8.217549] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    8.227505] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[    8.238514] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[    8.245169] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID BEC33049-213B-4D02-A9CE-5F0D7EB5DAA8, small LPT model
[    8.257174] VFS: Mounted root (ubifs filesystem) on device 0:14.
...
...

rfs in SD card[edit | edit source]

The root file system can be programmed into an SD card partition and, for example, the mmcargs parameters can be used. The following row in an example to use an SD card with two partition:

...
...
[    5.061660] mmc0: new high speed SDHC card at address aaaa
[    5.071528] mmcblk0: mmc0:aaaa SC16G 14.8 GiB
[    5.071528] mmcblk0: mmc0:aaaa SC16G 14.8 GiB 
[    5.088454]  mmcblk0: p1 p2
...
...

and then the corresponding U-Boot parameters for using the /dev/mmcblk0p2 partition (which is typically the second ext4 formatted SD partition):

mmcargs=setenv bootargs root=${mmcroot}

mmcroot=/dev/mmcblk0p2 rootwait rw

In this configuration the kernel mounts the root file system correctly in this way:

...
...
[    5.681176] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    5.689678] VFS: Mounted root (ext3 filesystem) on device 179:2.
[    5.707149] devtmpfs: mounted
[    5.713124] Freeing unused kernel memory: 1024K
...
...