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

From DAVE Developer's Wiki
Jump to: navigation, search
(Updating outputs for DESK-MX6UL-L 3.0.0)
Line 1: Line 1:
<section begin=History/>
+
<section begin="History" />
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
+
! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History
 
|-  
 
|-  
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Version
+
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Version
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
+
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Issue Date
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
+
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white" |Notes
 
|-
 
|-
|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"|1.0.1
+
| 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" |1.0.1
|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 2021
+
| 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 2021
|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"|First DESK release
+
| 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" |First DESK release
 +
|-
 +
| 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
 
|-
 
|-
 
|}
 
|}
<section end=History/>
+
<section end="History" />
<section begin=Body/>
+
<section begin="Body" />
  
 
==Standalone boot==
 
==Standalone boot==
Line 23: Line 27:
  
  
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 33: Line 37:
 
=== Program boot images into NOR flash ===
 
=== Program boot images into NOR flash ===
  
====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">
=> run load
+
=> run load_spl
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.157
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_mx6uldesk_axelulite_spi_SPL'.
+
Filename 'lynx/SPL'.
 
Load address: 0x80800000
 
Load address: 0x80800000
Loading: ############
+
Loading: #########
         543.9 KiB/s
+
         1.8 MiB/s
 
done
 
done
Bytes transferred = 56320 (dc00 hex)
+
Bytes transferred = 44032 (ac00 hex)
 
=> run spi_update_spl
 
=> run spi_update_spl
SF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB
+
SF: Detected is25lp256 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
 
SF: 65536 bytes @ 0x0 Erased: OK
 
SF: 65536 bytes @ 0x0 Erased: OK
device 0 offset 0x400, size 0xdc00
+
device 0 offset 0x400, size 0xac00
SF: 56320 bytes @ 0x400 Written: OK
+
SF: 44032 bytes @ 0x400 Written: OK
 
=> run load_uboot
 
=> run load_uboot
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.157
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_mx6uldesk_axelulite_spi_u-boot.img'.
+
Filename 'lynx/u-boot.img'.
 
Load address: 0x80800000
 
Load address: 0x80800000
 
Loading: #################################################################
 
Loading: #################################################################
         ####################################
+
         ##############################################
         584 KiB/s
+
         1.8 MiB/s
 
done
 
done
Bytes transferred = 512568 (7d238 hex)
+
Bytes transferred = 564844 (89e6c hex)
 
=> run spi_update_uboot
 
=> run spi_update_uboot
SF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB
+
SF: Detected is25lp256 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 524288 bytes @ 0x10000 Erased: OK
+
SF: 589824 bytes @ 0x10000 Erased: OK
device 0 offset 0x10000, size 0x7d238
+
device 0 offset 0x10000, size 0x89e6c
SF: 512568 bytes @ 0x10000 Written: OK
+
SF: 564844 bytes @ 0x10000 Written: OK
=>
+
 
 
</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 95: Line 99:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
 
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
SF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB
 
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_uImage'.
+
Filename 'lynx/uImage'.
 
Load address: 0x80800000
 
Load address: 0x80800000
 
Loading: #################################################################
 
Loading: #################################################################
Line 121: Line 124:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
         ##############
+
         #################################################################
         553.7 KiB/s
+
         #################################################################
 +
        #################################################################
 +
        ########################################
 +
        1.9 MiB/s
 
done
 
done
Bytes transferred = 7056696 (6bad38 hex)
+
Bytes transferred = 8189464 (7cf618 hex)
 
SF: 8388608 bytes @ 0x200000 Erased: OK
 
SF: 8388608 bytes @ 0x200000 Erased: OK
device 0 offset 0x200000, size 0x6bad38
+
device 0 offset 0x200000, size 0x7cf618
SF: 7056696 bytes @ 0x200000 Written: OK
+
SF: 8189464 bytes @ 0x200000 Written: OK
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_imx6ul-axelulite-cb003a.dtb'.
+
Filename 'lynx/imx6ul-lynx.dtb'.
 
Load address: 0x83000000
 
Load address: 0x83000000
 
Loading: #######
 
Loading: #######
         584 KiB/s
+
         1.5 MiB/s
 
done
 
done
Bytes transferred = 34095 (852f hex)
+
Bytes transferred = 32518 (7f06 hex)
 
SF: 524288 bytes @ 0x180000 Erased: OK
 
SF: 524288 bytes @ 0x180000 Erased: OK
device 0 offset 0x180000, size 0x852f
+
device 0 offset 0x180000, size 0x7f06
SF: 34095 bytes @ 0x180000 Written: OK
+
SF: 32518 bytes @ 0x180000 Written: OK
=>
 
 
</pre>
 
</pre>
  
Line 150: Line 155:
  
 
=== Program boot images into NAND flash ===
 
=== Program boot images into NAND flash ===
====u-Boot====
+
====U-Boot====
 +
 
 +
{{ImportantMessage|text=Only flashing the NAND device was tested for '''DESK-MX6UL-L 3.0.0''' release as neither SDV04 nor SBC Lynx support NAND boot.}}
  
u-boot on NAND flash must be programmed using NXP <code>kobs-ng</code> utility: 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 on NAND flash must be programmed using NXP <code>kobs-ng</code> utility: 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 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
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# kobs-ng -x -v -w desk-mx6ul-l-1.0.2_mx6uldesk_axelulite_nand_SPL
+
root@desk-mx6ul-axelulite:~# kobs-ng -x -v -w desk-mx6ul-l-3.0.0_mx6uldesk_axelulite_devel_SPL
 
MTD CONFIG:
 
MTD CONFIG:
 
   chip_0_device_path = "/dev/mtd0"
 
   chip_0_device_path = "/dev/mtd0"
Line 180: Line 187:
 
   boot_stream_1_address = 0
 
   boot_stream_1_address = 0
 
   boot_stream_2_address = 0
 
   boot_stream_2_address = 0
        -- We add the 1k-padding to the uboot.
+
  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: verifying using key '00000000000000000000000000000000'
 
.tmp_kobs_ng: is a valid bootstream for key '00000000000000000000000000000000'
 
.tmp_kobs_ng: is a valid bootstream for key '00000000000000000000000000000000'
Line 186: Line 194:
 
mtd: opening: "/dev/mtd0"
 
mtd: opening: "/dev/mtd0"
 
NFC geometry :
 
NFC geometry :
        ECC Strength      : 2
+
ECC Strength      : 2
        Page Size in Bytes : 2071
+
Page Size in Bytes : 2071
        Metadata size      : 10
+
Metadata size      : 10
        ECC Chunk Size in byte : 512
+
ECC Chunk Size in byte : 512
        ECC Chunk count        : 4
+
ECC Chunk count        : 4
        Block Mark Byte Offset : 2028
+
Block Mark Byte Offset : 2028
        Block Mark Bit Offset  : 2
+
Block Mark Bit Offset  : 2
 
====================================================
 
====================================================
 
mtd: opened '/dev/mtd0' - '(null)'
 
mtd: opened '/dev/mtd0' - '(null)'
mtd: max_boot_stream_size_in_bytes = 3670016
+
mtd: max_boot_stream_size_in_bytes = 524288
mtd: boot_stream_size_in_bytes = 672812
+
mtd: boot_stream_size_in_bytes = 45056
mtd: boot_stream_size_in_pages = 329
+
mtd: boot_stream_size_in_pages = 22
mtd: #1 0x00100000 - 0x00480000 (0x001a442c)
+
mtd: #1 0x00100000 - 0x00180000 (0x0010b000)
mtd: #2 0x00480000 - 0x00800000 (0x0052442c)
+
mtd: #2 0x00180000 - 0x00200000 (0x0018b000)
 
FCB
 
FCB
 
   m_u32Checksum = 0x00000000
 
   m_u32Checksum = 0x00000000
Line 228: Line 236:
 
   m_u32EraseThreshold = 0
 
   m_u32EraseThreshold = 0
 
   m_u32Firmware1_startingPage = 512
 
   m_u32Firmware1_startingPage = 512
   m_u32Firmware2_startingPage = 2304
+
   m_u32Firmware2_startingPage = 768
   m_u32PagesInFirmware1 = 329
+
   m_u32PagesInFirmware1 = 22
   m_u32PagesInFirmware2 = 329
+
   m_u32PagesInFirmware2 = 22
 
   m_u32DBBTSearchAreaStartAddress = 256
 
   m_u32DBBTSearchAreaStartAddress = 256
 
   m_u32BadBlockMarkerByte = 2028
 
   m_u32BadBlockMarkerByte = 2028
Line 246: Line 254:
 
   m_u32DISBBM = 0
 
   m_u32DISBBM = 0
 
   m_u32BBMarkerPhysicalOffsetInSpareData = 0
 
   m_u32BBMarkerPhysicalOffsetInSpareData = 0
 +
  m_u32OnfiSyncEnable = 0
 +
  m_NANDONFITiming.m_u32ONFISpeed = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_ReadLatency = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_CEDelay = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_PreambleDelay = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_PostambleDelay = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_CmdAddPause = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_DataPause = 0
 +
  m_NANDONFITiming.m_u32ONFITiming_BusyTimeout = 0
 +
  m_u32DISBBSearch = 0
 +
  m_u32RandomizerEnable = 0
 +
  m_u32ReadRetryEnable = 0
 +
  m_u32ReadRetrySeqLength = 0
 
DBBT
 
DBBT
 
   m_u32Checksum = 0x00000000
 
   m_u32Checksum = 0x00000000
Line 251: Line 272:
 
   m_u32Version = 0x01000000
 
   m_u32Version = 0x01000000
 
   m_u32DBBTNumOfPages = 0
 
   m_u32DBBTNumOfPages = 0
Firmware: image #0 @ 0x100000 size 0xa4800 - available 0x380000
+
Firmware: image #0 @ 0x100000 size 0xb000 - available 0x80000
Firmware: image #1 @ 0x480000 size 0xa4800 - available 0x380000
+
Firmware: image #1 @ 0x180000 size 0xb000 - available 0x80000
 
-------------- Start to write the [ FCB ] -----
 
-------------- Start to write the [ FCB ] -----
 
mtd: erasing @0:0x0-0x20000
 
mtd: erasing @0:0x0-0x20000
Line 276: Line 297:
  
 
---------- Start to write the [ .tmp_kobs_ng ]----
 
---------- Start to write the [ .tmp_kobs_ng ]----
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x001a4800
+
mtd: Writting .tmp_kobs_ng: #0 @0: 0x00100000 - 0x0010b000
 
mtd: erasing @0:0x100000-0x120000
 
mtd: erasing @0:0x100000-0x120000
mtd: erasing @0:0x120000-0x140000
+
mtd: We write one page for save guard. *
mtd: erasing @0:0x140000-0x160000
+
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018b000
mtd: erasing @0:0x160000-0x180000
 
 
mtd: erasing @0:0x180000-0x1a0000
 
mtd: erasing @0:0x180000-0x1a0000
mtd: erasing @0:0x1a0000-0x1c0000
 
mtd: The last page is not full : 1068
 
mtd: We write one page for save guard. *
 
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00480000 - 0x00524800
 
mtd: erasing @0:0x480000-0x4a0000
 
mtd: erasing @0:0x4a0000-0x4c0000
 
mtd: erasing @0:0x4c0000-0x4e0000
 
mtd: erasing @0:0x4e0000-0x500000
 
mtd: erasing @0:0x500000-0x520000
 
mtd: erasing @0:0x520000-0x540000
 
mtd: The last page is not full : 1068
 
 
mtd: We write one page for save guard. *
 
mtd: We write one page for save guard. *
 +
&lt;/pre>
 +
 +
then the second <code>mtd1</code> partition can be written using ''nandwrite'':
 +
 +
<pre class="workstation-terminal">
 
root@desk-mx6ul-axelulite:~# flash_erase /dev/mtd1 0 0
 
root@desk-mx6ul-axelulite:~# flash_erase /dev/mtd1 0 0
Erasing 128 Kibyte @ 5e0000 -- 100 % complete
+
Erasing 128 Kibyte @ 5e0000 -- 100 % complete  
root@desk-mx6ul-axelulite:~# nandwrite -p /dev/mtd1 desk-mx6ul-l-1.0.2_mx6uldesk_axelulite_nand_u-boot.img
+
root@desk-mx6ul-axelulite:~# nandwrite -p /dev/mtd1 desk-mx6ul-l-3.0.0_mx6uldesk_axelulite_devel_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
 
Writing data to block 2 at offset 0x40000
 
Writing data to block 2 at offset 0x40000
 
Writing data to block 3 at offset 0x60000
 
Writing data to block 3 at offset 0x60000
root@desk-mx6ul-axelulite:~#
+
Writing data to block 4 at offset 0x80000
 
</pre>
 
</pre>
  
Line 328: Line 342:
 
=> run loadk nand_updatek loadfdt nand_updatefdt
 
=> run loadk nand_updatek loadfdt nand_updatefdt
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_uImage'.
+
Filename 'lynx/uImage'.
 
Load address: 0x80800000
 
Load address: 0x80800000
 
Loading: #################################################################
 
Loading: #################################################################
Line 352: Line 366:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
         ##############
+
         #################################################################
         504.9 KiB/s
+
         #################################################################
 +
        #################################################################
 +
        ########################################
 +
        1.9 MiB/s
 
done
 
done
Bytes transferred = 7056696 (6bad38 hex)
+
Bytes transferred = 8189464 (7cf618 hex)
  
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
Line 361: Line 378:
 
OK
 
OK
  
NAND write: device 0 offset 0xc00000, size 0x6bad38
+
NAND write: device 0 offset 0xc00000, size 0x7cf618
  7056696 bytes written: OK
+
  8189464 bytes written: OK
 
Using FEC0 device
 
Using FEC0 device
TFTP from server 192.168.0.125; our IP address is 192.168.0.89
+
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'desk-mx-l/desk-mx6ul-l-1.0.1_imx6ul-axelulite-cb003a.dtb'.
+
Filename 'lynx/imx6ul-lynx.dtb'.
 
Load address: 0x83000000
 
Load address: 0x83000000
 
Loading: #######
 
Loading: #######
         165 KiB/s
+
         1.8 MiB/s
 
done
 
done
Bytes transferred = 34095 (852f hex)
+
Bytes transferred = 32518 (7f06 hex)
  
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
Line 376: Line 393:
 
OK
 
OK
  
NAND write: device 0 offset 0xa00000, size 0x852f
+
NAND write: device 0 offset 0xa00000, size 0x7f06
  34095 bytes written: OK
+
  32518 bytes written: OK
=>
 
 
</pre>
 
</pre>
  
Line 393: Line 409:
 
* 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@desk-mx6ul-axelulite:~# cat /proc/mtd
+
root@desk-mx6ul-lynx:~# cat /proc/mtd  
 
dev:    size  erasesize  name
 
dev:    size  erasesize  name
 
mtd0: 00200000 00020000 "nand-SPL"
 
mtd0: 00200000 00020000 "nand-SPL"
Line 403: Line 419:
 
mtd6: 00800000 00020000 "nand-kernel"
 
mtd6: 00800000 00020000 "nand-kernel"
 
mtd7: 00400000 00020000 "nand-splash"
 
mtd7: 00400000 00020000 "nand-splash"
mtd8: 06800000 00020000 "nand-ubi"
+
mtd8: 3e800000 00020000 "nand-ubi"
 
mtd9: 00010000 00001000 "spi-SPL"
 
mtd9: 00010000 00001000 "spi-SPL"
 
mtd10: 000f0000 00001000 "spi-uboot"
 
mtd10: 000f0000 00001000 "spi-uboot"
Line 411: Line 427:
 
mtd14: 00800000 00001000 "spi-kernel"
 
mtd14: 00800000 00001000 "spi-kernel"
 
mtd15: 00400000 00001000 "spi-splash"
 
mtd15: 00400000 00001000 "spi-splash"
mtd16: 00200000 00001000 "spi-free"
+
mtd16: 01200000 00001000 "spi-free"
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
Line 429: Line 444:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# ubiformat /dev/mtd8
+
root@desk-mx6ul-lynx:~# ubiformat /dev/mtd8
ubiformat: mtd8 (nand), size 109051904 bytes (104.0 MiB), 832 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
li[  52.440377] random: crng init done% complete
+
libscan: scanning eraseblock 7999 -- 100 % complete  
[  52.446177] random: 7 urandom warning(s) missed due to ratelimiting
+
ubiformat: 8000 eraseblocks have valid erase counter, mean value is 16
libscan: scanning eraseblock 831 -- 100 % complete
+
ubiformat: formatting eraseblock 7999 -- 100 % complete
ubiformat: 830 eraseblocks have valid erase counter, mean value is 0
+
root@desk-mx6ul-lynx:~# ubiattach -m 8
ubiformat: warning!: 2 of 832 eraseblocks contain non-UBI data
+
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)
ubiformat: continue? (y/N) y
+
root@desk-mx6ul-lynx:~# ubimkvol /dev/ubi0 -N rootfs -m
ubiformat: formatting eraseblock 831 -- 100 % complete
+
Set volume size to 994983936
root@desk-mx6ul-axelulite:~# ubiattach -m 8
+
Volume ID 0, size 7836 LEBs (994983936 bytes, 948.8 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
[  68.203880] ubi0: attaching mtd8
 
[  69.488529] ubi0: scanning is finished
 
[  69.526881] ubi0: attached mtd8 (name "nand-ubi", size 104 MiB)
 
[  69.545319] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
 
[  69.552230] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
 
[  69.576138] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
 
[  69.587298] ubi0: good PEBs: 832, bad PEBs: 0, corrupted PEBs: 0
 
[  69.594040] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
 
[  69.601292] ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 1623728395
 
[  69.613873] ubi0: available PEBs: 808, total reserved PEBs: 24, PEBs reserved for bad PEB handling: 20
 
[  69.623519] ubi0: background thread "ubi_bgt0d" started, PID 264
 
UBI device number 0, total 832 LEBs (105644032 bytes, 100.7 MiB), available 808 LEBs (102596608 bytes, 97.8 MiB), LEB size 126976 bytes (124.0 KiB)
 
root@desk-mx6ul-axelulite:~# ubimkvol /dev/ubi0 -N rootfs -m
 
Set volume size to 102596608
 
Volume ID 0, size 808 LEBs (102596608 bytes, 97.8 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootfs", alignment 1
 
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
Line 467: Line 466:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# mkdir -p /mnt/nand
+
root@desk-mx6ul-lynx:~# mkdir -p /mnt/nand
root@desk-mx6ul-axelulite:~# mount -t ubifs ubi0_0 /mnt/nand
+
root@desk-mx6ul-lynx:~# mount -t ubifs ubi0_0 /mnt/nand/
104.646929] UBIFS (ubi0:0): default file-system created
+
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
104.656524] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 271
+
201.602548] UBIFS (ubi0:0): Mounting in unauthenticated mode
104.795980] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
+
201.602935] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 293
104.803631] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
+
201.634481] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
104.817174] UBIFS (ubi0:0): FS size: 101199872 bytes (96 MiB, 797 LEBs), journal size 5079040 bytes (4 MiB, 40 LEBs)
+
201.634523] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
104.829554] UBIFS (ubi0:0): reserved for root: 4779919 bytes (4667 KiB)
+
201.634550] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
104.838248] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 0687F325-4ED1-488F-B637-57FAEADE745E, small LPT model
+
201.634570] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
root@desk-mx6ul-axelulite:~#
+
201.634596] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID CBE8807E-6A37-400B-9B56-E12B4C034D9E, small LPT model
 
</pre>
 
</pre>
  
Line 482: Line 481:
  
 
<pre>
 
<pre>
tar xvjf tar xjf dave-image-devel-desk-mx6ul-axelulite.tar.bz2 -C /mnt/nand
+
tar xvjf desk-image-qt5-desk-mx6ul-lynx.tar.bz2 -C /mnt/nand/
 
</pre>
 
</pre>
  
Line 495: Line 494:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# umount /mnt/nand/
+
root@desk-mx6ul-lynx:~# umount /mnt/nand
[ 1264.460672] UBIFS (ubi0:0): un-mount UBI device 0
+
root@desk-mx6ul-lynx:~# ubidetach -m 8
[ 1264.465626] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
+
root@desk-mx6ul-lynx:~# dmesg | tail -n 4
root@desk-mx6ul-axelulite:~# ubidetach -m 8
+
[ 1154.988629] UBIFS (ubi0:0): un-mount UBI device 0
[ 1270.298143] ubi0: detaching mtd8
+
[ 1154.989082] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
[ 1270.316092] ubi0: mtd8 is detached
+
[ 1160.907410] ubi0: detaching mtd8
root@desk-mx6ul-axelulite:~#
+
[ 1160.921595] ubi0: mtd8 is detached
 
</pre>
 
</pre>
  

Revision as of 12:03, 28 February 2022

History
Version Issue Date Notes
1.0.1 Jun 2021 First DESK release
3.0.0 Feb 2022 3.0.0 DESK release


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]

U-Boot[edit | edit source]

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

=> run load_spl
Using FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.157
Filename 'lynx/SPL'.
Load address: 0x80800000
Loading: #########
         1.8 MiB/s
done
Bytes transferred = 44032 (ac00 hex)
=> run spi_update_spl
SF: Detected is25lp256 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 65536 bytes @ 0x0 Erased: OK
device 0 offset 0x400, size 0xac00
SF: 44032 bytes @ 0x400 Written: OK
=> run load_uboot
Using FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.157
Filename 'lynx/u-boot.img'.
Load address: 0x80800000
Loading: #################################################################
         ##############################################
         1.8 MiB/s
done
Bytes transferred = 564844 (89e6c hex)
=> run spi_update_uboot
SF: Detected is25lp256 with page size 256 Bytes, erase size 64 KiB, total 32 MiB
SF: 589824 bytes @ 0x10000 Erased: OK
device 0 offset 0x10000, size 0x89e6c
SF: 564844 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
Using FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'lynx/uImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ########################################
         1.9 MiB/s
done
Bytes transferred = 8189464 (7cf618 hex)
SF: 8388608 bytes @ 0x200000 Erased: OK
device 0 offset 0x200000, size 0x7cf618
SF: 8189464 bytes @ 0x200000 Written: OK
Using FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'lynx/imx6ul-lynx.dtb'.
Load address: 0x83000000
Loading: #######
         1.5 MiB/s
done
Bytes transferred = 32518 (7f06 hex)
SF: 524288 bytes @ 0x180000 Erased: OK
device 0 offset 0x180000, size 0x7f06
SF: 32518 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]

200px-Emblem-important.svg.png

Only flashing the NAND device was tested for DESK-MX6UL-L 3.0.0 release as neither SDV04 nor SBC Lynx support NAND boot.

U-Boot on NAND flash must be programmed using NXP kobs-ng utility: 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 image file on nfs /home/root (for example)
  • execute kobs-ng passing the parameters for flashing U-Boot on NAND
root@desk-mx6ul-axelulite:~# kobs-ng -x -v -w desk-mx6ul-l-3.0.0_mx6uldesk_axelulite_devel_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 = 45056
mtd: boot_stream_size_in_pages = 22
mtd: #1 0x00100000 - 0x00180000 (0x0010b000)
mtd: #2 0x00180000 - 0x00200000 (0x0018b000)
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 = 22
  m_u32PagesInFirmware2 = 22
  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
  m_u32OnfiSyncEnable = 0
  m_NANDONFITiming.m_u32ONFISpeed = 0
  m_NANDONFITiming.m_u32ONFITiming_ReadLatency = 0
  m_NANDONFITiming.m_u32ONFITiming_CEDelay = 0
  m_NANDONFITiming.m_u32ONFITiming_PreambleDelay = 0
  m_NANDONFITiming.m_u32ONFITiming_PostambleDelay = 0
  m_NANDONFITiming.m_u32ONFITiming_CmdAddPause = 0
  m_NANDONFITiming.m_u32ONFITiming_DataPause = 0
  m_NANDONFITiming.m_u32ONFITiming_BusyTimeout = 0
  m_u32DISBBSearch = 0
  m_u32RandomizerEnable = 0
  m_u32ReadRetryEnable = 0
  m_u32ReadRetrySeqLength = 0
DBBT
  m_u32Checksum = 0x00000000
  m_u32FingerPrint = 0x54424244
  m_u32Version = 0x01000000
  m_u32DBBTNumOfPages = 0
Firmware: image #0 @ 0x100000 size 0xb000 - available 0x80000
Firmware: image #1 @ 0x180000 size 0xb000 - available 0x80000
-------------- 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 - 0x0010b000
mtd: erasing @0:0x100000-0x120000
mtd: We write one page for save guard. *
mtd: Writting .tmp_kobs_ng: #1 @0: 0x00180000 - 0x0018b000
mtd: erasing @0:0x180000-0x1a0000
mtd: We write one page for save guard. *
</pre>

then the second <code>mtd1</code> partition can be written using ''nandwrite'':

<pre class="workstation-terminal">
root@desk-mx6ul-axelulite:~# flash_erase /dev/mtd1 0 0
Erasing 128 Kibyte @ 5e0000 -- 100 % complete 
root@desk-mx6ul-axelulite:~# nandwrite -p /dev/mtd1 desk-mx6ul-l-3.0.0_mx6uldesk_axelulite_devel_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 FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'lynx/uImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ########################################
         1.9 MiB/s
done
Bytes transferred = 8189464 (7cf618 hex)

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

NAND write: device 0 offset 0xc00000, size 0x7cf618
 8189464 bytes written: OK
Using FEC0 device
TFTP from server 192.168.4.240; our IP address is 192.168.4.183
Filename 'lynx/imx6ul-lynx.dtb'.
Load address: 0x83000000
Loading: #######
         1.8 MiB/s
done
Bytes transferred = 32518 (7f06 hex)

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

NAND write: device 0 offset 0xa00000, size 0x7f06
 32518 bytes written: OK

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

=> setenv bootcmd run nand_nand
=> saveenv

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

  • Boot the system via SD or NFS as described in the e [[(<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@desk-mx6ul-lynx:~# 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: 3e800000 00020000 "nand-ubi"
mtd9: 00010000 00001000 "spi-SPL"
mtd10: 000f0000 00001000 "spi-uboot"
mtd11: 00040000 00001000 "spi-env1"
mtd12: 00040000 00001000 "spi-env2"
mtd13: 00080000 00001000 "spi-dtb"
mtd14: 00800000 00001000 "spi-kernel"
mtd15: 00400000 00001000 "spi-splash"
mtd16: 01200000 00001000 "spi-free"


200px-Emblem-important.svg.png

Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside /proc/mtd to match your specific layout


  • 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-mx6ul-lynx:~# 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 16
ubiformat: formatting eraseblock 7999 -- 100 % complete  
root@desk-mx6ul-lynx:~# ubiattach -m 8
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-mx6ul-lynx:~# 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-mx6ul-lynx:~# mkdir -p /mnt/nand
root@desk-mx6ul-lynx:~# mount -t ubifs ubi0_0 /mnt/nand/
root@desk-mx6ul-lynx:~# dmesg | tail -n 7
[  201.602548] UBIFS (ubi0:0): Mounting in unauthenticated mode
[  201.602935] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 293
[  201.634481] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[  201.634523] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[  201.634550] UBIFS (ubi0:0): FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
[  201.634570] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[  201.634596] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID CBE8807E-6A37-400B-9B56-E12B4C034D9E, small LPT model
  • you can now extract the root file system into that directory
tar xvjf desk-image-qt5-desk-mx6ul-lynx.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-mx6ul-lynx:~# umount /mnt/nand
root@desk-mx6ul-lynx:~# ubidetach -m 8
root@desk-mx6ul-lynx:~# dmesg | tail -n 4
[ 1154.988629] UBIFS (ubi0:0): un-mount UBI device 0
[ 1154.989082] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
[ 1160.907410] ubi0: detaching mtd8
[ 1160.921595] 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

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