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

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "{{subst:Standalone_boot | nome-som=ORCA | kit-code=MX8M | kit = mx8 | kit-repo = desk-mx-l}}")
 
Line 7: Line 7:
 
!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"|X.Y.Z
+
|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.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"|Month Year
+
|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"|TBD
+
|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-MX8M-L 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"|[TBD_link X.Y.Z]
 
|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"|Month Year
 
|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"|TBD
 
 
|-
 
|-
 
|}
 
|}
Line 21: Line 16:
  
 
==Standalone boot==
 
==Standalone boot==
 
'''TBD: rifare tutti i dump con le versioni corrette '''
 
 
'''TBD: eliminare eventuali sezioni non pertinenti (es. eMMC) per il SOC '''
 
 
  
 
=== Introduction ===
 
=== Introduction ===
Line 41: Line 31:
 
** 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
 
** 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 ===
+
=== Program boot images into eMMC ===
  
====u-Boot====
+
====Boot====
 
+
Update to the latest Boot image 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">
 
=> run load
 
Using FEC device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
 
Filename 'sdvx/u-boot/sdvx-1.0.0_mx6dl_sfczg_spi_u-boot.imx'.
 
Load address: 0x12000000
 
Loading: #################################################################
 
        #################################################################
 
        ##
 
        1.4 MiB/s
 
done
 
Bytes transferred = 671788 (a402c hex)
 
=> run spi_update
 
SF: Detected S25FL256S with page size 64 KiB, total 32 MiB
 
=>
 
</pre>
 
 
 
====kernel image and device tree====
 
 
 
We assume that the following environment variables are present in u-boot:
 
  
 
<pre>
 
<pre>
loadk=tftpboot ${loadaddr} ${serverip}:${bootfile}
+
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
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
 
 
</pre>
 
</pre>
  
* Update the <code>bootfile</code> and <code>fdtfile</code> environment variables to fit the filename as found inside the TFTP server.
+
Load Boot binary form a <code>tftp</code> server:
* Program kernel and device tree on NOR flash with the following U-Boot command
 
 
 
<pre class="board-terminal">
 
sf probe; run loadk spi_updatek loadfdt spi_updatefdt
 
</pre>
 
 
 
E.g.:
 
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
=> sf probe; run loadk spi_updatek loadfdt spi_updatefdt
+
u-boot=> run load
SF: Detected S25FL256S with page size 64 KiB, total 32 MiB
+
Using ethernet@30be0000 device
Using FEC device
+
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
+
Filename 'desk-mx8m/flash.bin'.
Filename 'sdvx/linux/sdvx-1.0.0_lite_uImage'.
+
Load address: 0x40480000
Load address: 0x12000000
 
 
Loading: #################################################################
 
Loading: #################################################################
 
         #################################################################
 
         #################################################################
Line 100: Line 54:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #############################################
 
        1.6 MiB/s
 
done
 
Bytes transferred = 6437016 (623898 hex)
 
Using FEC device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
 
Filename 'sdvx/linux/sdvx-1.0.0_lite_imx6dl-sfczg-cb0043.dtb'.
 
Load address: 0x18000000
 
Loading: #########
 
        1.2 MiB/s
 
done
 
Bytes transferred = 42547 (a633 hex)
 
=>
 
</pre>
 
 
Reboot the system and configure U-Boot to apply the new configuration
 
 
<pre class="workstation-terminal">
 
=> setenv bootcmd run spi_nand
 
=> saveenv
 
</pre>
 
 
=== Program boot images into NAND flash ===
 
====u-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.
 
 
Here below an example:
 
* 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>)
 
* 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
 
 
<pre class="workstation-terminal">
 
root@imx6qxelk:~# kobs-ng -x -v -w sdvx-1.0.0_mx6dl_sfczg_nand_u-boot.imx
 
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
 
        -- 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 = 3670016
 
mtd: boot_stream_size_in_bytes = 672812
 
mtd: boot_stream_size_in_pages = 329
 
mtd: #1 0x00100000 - 0x00480000 (0x001a442c)
 
mtd: #2 0x00480000 - 0x00800000 (0x0052442c)
 
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 = 2304
 
  m_u32PagesInFirmware1 = 329
 
  m_u32PagesInFirmware2 = 329
 
  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 0xa4800 - available 0x380000
 
Firmware: image #1 @ 0x480000 size 0xa4800 - available 0x380000
 
-------------- 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 - 0x001a4800
 
mtd: erasing @0:0x100000-0x120000
 
mtd: erasing @0:0x120000-0x140000
 
mtd: erasing @0:0x140000-0x160000
 
mtd: erasing @0:0x160000-0x180000
 
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. *
 
root@imx6qxelk:~#
 
</pre>
 
 
====kernel image and device tree====
 
 
We assume that the following environment variables are present in u-boot:
 
 
<pre>
 
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
 
</pre>
 
 
* Update the <code>bootfile</code> and <code>fdtfile</code> environment variables to fit the filename as found inside the TFTP server.
 
* Program kernel and device tree on NAND flash with the following U-Boot command
 
 
<pre class="board-terminal">
 
run loadk nand_updatek loadfdt nand_updatefdt
 
</pre>
 
 
E.g.:
 
 
<pre class="workstation-terminal">
 
U-Boot > run loadk nand_updatek loadfdt nand_updatefdt
 
Using FEC device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.98
 
Filename 'sdvx/linux/sdvx-1.0.0_lite_uImage'.
 
Load address: 0x12000000
 
Loading: #################################################################
 
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
Line 327: Line 72:
 
         #################################################################
 
         #################################################################
 
         #################################################################
 
         #################################################################
        #######################
 
        1.4 MiB/s
 
done
 
Bytes transferred = 6437016 (623898 hex)
 
 
NAND erase.part: device 0 offset 0xc00000, size 0x800000
 
Erasing at 0x13e0000 -- 100% complete.
 
OK
 
 
NAND write: device 0 offset 0xc00000, size 0x623898
 
6437016 bytes written: OK
 
Using FEC device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
 
Filename 'sdvx/linux/sdvx-1.0.0_lite_imx6dl-sfczg-cb0043.dtb'.
 
Load address: 0x18000000
 
Loading: #########
 
        525.4 KiB/s
 
done
 
Bytes transferred = 42547 (a633 hex)
 
 
NAND erase.part: device 0 offset 0xa00000, size 0x100000
 
Erasing at 0xae0000 -- 100% complete.
 
OK
 
 
NAND write: device 0 offset 0xa00000, size 0xa633
 
42547 bytes written: OK
 
=>
 
</pre>
 
 
Reboot the system and configure U-Boot to apply the new configuration
 
 
<pre class="workstation-terminal">
 
=> setenv bootcmd run nand_nand
 
=> saveenv
 
</pre>
 
 
=== Program boot images into eMMC ===
 
 
====u-Boot====
 
Update to the latest u-boot version allows usage of u-boot environment variables available.
 
 
<pre>
 
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}
 
</pre>
 
 
Load u-boot binary form a <code>tftp</code> server:
 
 
<pre class="workstation-terminal">
 
=> run load
 
Using FEC device
 
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
 
Filename 'sdvx/u-boot/sdvx-1.0.0_mx6dl_sfczg_u-boot.imx'.
 
Load address: 0x12000000
 
Loading: #################################################################
 
 
         #################################################################
 
         #################################################################
         ##
+
         ########
         1.5 MiB/s
+
         1.8 MiB/s
 
done
 
done
Bytes transferred = 671788 (a402c hex)
+
Bytes transferred = 8355840 (7f8000 hex)
=> run mmc_update
+
u-boot=> mmc dev 2
 
switch to partitions #0, OK
 
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
+
mmc2(part 0) is current device
 
+
u-boot=> run mmc_update
MMC write: dev # 2, block # 2, count 1313 ... 1313 blocks written: OK
 
 
=>
 
=>
 
</pre>
 
</pre>
  
Load u-boot binary form an <code>SD</code> card:
+
Load Boot binary form an <code>SD</code> card:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
Hit ENTER within 1 seconds to stop autoboot
 
Hit ENTER within 1 seconds to stop autoboot
=> fatload mmc 0:1 ${loadaddr} sdvx-1.0.1_mx6dlaxel_u-boot.imx
+
=> fatload mmc 1:1 ${loadaddr} flash.bin
reading sdvx-1.0.1_mx6dlaxel_u-boot.imx
+
fatload mmc 1:1 ${loadaddr} flash.bin
671788 bytes read in 50 ms (12.8 MiB/s)
+
8355840 bytes read in 373 ms (21.4 MiB/s)
=> mmc dev 2
+
u-boot=> mmc dev 2
 
switch to partitions #0, OK
 
switch to partitions #0, OK
mmc2(part 0) is current device (eMMC)
+
mmc2(part 0) is current device
=> run mmc_update
+
u-boot=> run mmc_update
switch to partitions #0, OK
 
mmc2(part 0) is current device (eMMC)
 
 
 
MMC write: dev # 2, block # 2, count 1313 ... 1313 blocks written: OK
 
 
=>
 
=>
 
</pre>
 
</pre>
Line 414: Line 100:
 
====kernel image and device tree====
 
====kernel image and device tree====
  
We assume that the following environment variables are present in u-boot:
+
The following environment variables has to be set (or at least checked) in u-boot; depending on the formatted eMMC partition (<code>FAT32</code> or <code>ext4</code>), the vars has to be properly modified:
  
 +
==== FAT32 ====
 
<pre>
 
<pre>
mmc_loadk=fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}
+
setenv mmc_loadk 'fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'
mmc_loadfdt=fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile}
+
setenv mmc_loadfdt 'fatload mmc ${mmcdev}:1 ${fdt_addr} ${fdt_file}'
mmc_loadsplash=fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}
+
setenv 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
+
</pre>
 +
 
 +
==== ext4  ====
 +
<pre>
 +
setenv mmc_loadk 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'
 +
setenv mmc_loadfdt 'ext4load mmc ${mmcdev}:1 ${fdt_addr} ${fdt_file}'
 +
setenv mmc_loadsplash 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}'
 
</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 previously 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:
 
 
<pre>
 
<pre>
mmcargs=setenv bootargs root=${mmcroot}
+
setenv 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'
mmcroot=/dev/mmcblk2p2 rootwait rw
+
setenv mmcargs 'setenv bootargs root=${mmcroot}'
 +
setenv mmcroot '/dev/mmcblk2p2 rootwait rw'
 +
saveenv
 
</pre>
 
</pre>
 +
  
 
==== boot vars ====
 
==== boot vars ====
Line 439: Line 133:
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
=> setenv normalboot mmcboot
 
=> setenv normalboot mmcboot
=> setenv bootfile sdvx-1.0.1_lite_uImage
+
=> setenv bootfile Image
=> setenv fdtfile sdvx-1.0.1_lite_imx6dl-sdv03-cb002a.dtb
+
=> setenv fdt_file imx8mp-mito8mplus-cb1001.dtb
 
=> setenv splashfile splash_image.bmp
 
=> setenv splashfile splash_image.bmp
 
</pre>
 
</pre>
Line 453: Line 147:
 
</pre>
 
</pre>
  
=== Program root file system into NAND flash ===
+
=== Program root file system into eMMC ===
 
 
* 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 [[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">
 
root@sdvx-lite:~# cat /proc/mtd
 
dev:    size  erasesize  name
 
mtd0: 00800000 00020000 "nand-uboot"
 
mtd1: 00100000 00020000 "nand-env1"
 
mtd2: 00100000 00020000 "nand-env2"
 
mtd3: 00100000 00020000 "nand-fdt"
 
mtd4: 00100000 00020000 "nand-spare"
 
mtd5: 00800000 00020000 "nand-kernel"
 
mtd6: 00600000 00020000 "nand-splash"
 
mtd7: 3e600000 00020000 "nand-ubi"
 
root@sdvx-lite:~#
 
</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}}
 
 
 
 
 
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
 
 
 
<pre>
 
ubiformat /dev/mtd7
 
ubiattach -m 7
 
ubimkvol /dev/ubi0 -N rootfs -m
 
</pre>
 
 
 
E.g.
 
 
 
<pre class="workstation-terminal">
 
root@sdvx-lite:~# ubiformat /dev/mtd7
 
ubiformat: mtd7 (nand), size 1048576000 bytes (1000.0 MiB), 8000 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
 
libscan: scanning eraseblock 7999 -- 100 % complete
 
ubiformat: 8000 eraseblocks have valid erase counter, mean value is 1
 
ubiformat: formatting eraseblock 7999 -- 100 % complete
 
root@sdvx-lite:~# ubiattach -m 7
 
[ 1714.823600] UBI: attaching mtd7 to ubi0
 
[ 1726.415587] UBI: scanning is finished
 
[ 1726.483765] UBI: attached mtd7 (name "nand-ubi", size 1000 MiB) to ubi0
 
[ 1726.491062] UBI: 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
 
[ 1726.505030] UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
 
[ 1726.512430] UBI: good PEBs: 8000, bad PEBs: 0, corrupted PEBs: 0
 
[ 1726.518861] UBI: 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
 
[ 1726.535433] UBI: available PEBs: 7836, total reserved PEBs: 164, PEBs reserved for bad PEB handling: 160
 
[ 1726.545260] UBI: background thread "ubi_bgt0d" started, PID 714
 
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)
 
root@sdvx-lite:~# ubimkvol /dev/ubi0 -N rootfs -m
 
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
 
</pre>
 
 
 
* Now mount the UBI volume using [[Memory Tecnology Device (MTD)#UBIFS|UBIFS]] in a temporary directory
 
 
 
<pre>
 
mkdir -p /mnt/nand
 
mount -t ubifs ubi0_0 /mnt/nand
 
</pre>
 
 
 
E.g.:
 
 
 
<pre class="workstation-terminal">
 
root@sdvx-lite:~# mkdir -p /mnt/nand
 
root@sdvx-lite:~# mount -t ubifs ubi0_0 /mnt/nand
 
[ 1810.301461] UBIFS: default file-system created
 
[ 1810.308952] UBIFS: background thread "ubifs_bgt0_0" started, PID 717
 
[ 1810.452274] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
 
[ 1810.459421] UBIFS: LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
 
[ 1810.469398] UBIFS: FS size: 992698368 bytes (946 MiB, 7818 LEBs), journal size 33521664 bytes (31 MiB, 264 LEBs)
 
[ 1810.480976] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
 
[ 1810.487210] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 99D0F3C6-5955-4B30-9E2D-72202281BD30, small LPT model
 
</pre>
 
 
 
* you can now extract the root file system into that directory
 
 
 
<pre>
 
tar xvjf sdvx-1.0.1_image-devel-sdvx-lite.tar.bz2 -C /mnt/nand
 
</pre>
 
 
 
* finally, you need to cleanly umount and detach the MTD partition
 
  
<pre>
+
* boot the system via SD or NFS as described in the e [[DESK-MX8M-L/General/Booting_from_NFS|Booting from NFS]]
umount /mnt/nand/
 
ubidetach -m 7
 
</pre>
 
 
 
E.g.
 
 
 
<pre class="workstation-terminal">
 
root@sdvx-lite:~# umount /mnt/nand/
 
[ 2446.743091] UBIFS: un-mount UBI device 0, volume 0
 
[ 2446.749670] UBIFS: background thread "ubifs_bgt0_0" stops
 
root@sdvx-lite:~# ubidetach -m 7
 
[ 2450.738153] UBI: detaching mtd7 from ubi0
 
[ 2450.759527] UBI: mtd7 is detached from ubi0
 
</pre>
 
 
 
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
 
 
 
<pre>
 
nand_args=setenv bootargs root=ubi0:rootfs rootfstype=ubifs rw ubi.mtd=7
 
</pre>
 
 
 
=== 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]]
 
 
* 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:
  
==== FAT32 partition ====
+
==== Partitioning ====
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
Line 600: Line 186:
  
 
# call sfdisk to create partition table
 
# call sfdisk to create partition table
{ echo ${boot_start},${boot_size},0c,-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}
+
{ echo ${boot_start},${boot_size},'''83''',-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}
  
 
# format the SDCARD partition
 
# format the SDCARD partition
 
echo "formatting boot"
 
echo "formatting boot"
mkfs.vfat -F 32 -n boot ${node}${part}1
+
mkfs.ext4 -F ${node}${part}1 -Lboot
 
echo "formatting rfs"
 
echo "formatting rfs"
 
mkfs.ext4 -F ${node}${part}2 -Lrfs
 
mkfs.ext4 -F ${node}${part}2 -Lrfs
Line 610: Line 196:
  
 
E.g.
 
E.g.
 +
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
 
root@sdvx-lite:~# ./sdcard-partition.sh /dev/mmcblk2
 
root@sdvx-lite:~# ./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
 
 
root@sdvx-lite:~#
 
 
</pre>
 
</pre>
  
Line 675: Line 217:
 
[  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@sdvx-lite:~# cd /mnt/emmc
 
root@sdvx-lite:~# cd /mnt/emmc
root@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/sdvx-1.0.1*dtb .
+
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/*dtb .
root@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/sdvx-1.0.1*uImage .
+
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/Image .
root@sdvx-lite:/mnt/emmc# cp /tftpboot/sdvx/linux/splash_image.bmp .
+
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/splash_image.bmp .
 
root@sdvx-lite:/mnt/emmc# cd
 
root@sdvx-lite:/mnt/emmc# cd
 
root@sdvx-lite:~# umount /mnt/emmc
 
root@sdvx-lite:~# umount /mnt/emmc
Line 687: Line 229:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@sdvx-lite:~# mount /dev/mmcblk2p2 /mnt/emmc
+
root@desk-mx8mp:~# mount /dev/mmcblk2p2 /mnt/emmc
[ 1810.899327] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
+
[   27.437492] EXT4-fs (mmcblk2p2): mounting ext3 file system using the ext4 subsystem
root@sdvx-lite:~# cd /mnt/emmc
+
[  27.455201] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
root@sdvx-lite:/mnt/emmc#  
+
root@desk-mx8mp:~# cd /mnt/emmc/
 +
root@desk-mx8mp:/mnt/emmc#
 
</pre>
 
</pre>
  
Line 696: Line 239:
  
 
<pre>
 
<pre>
tar xvjf sdvx-1.0.1_image-devel-sdvx-lite.tar.bz2
+
tar xvjf dave-image-devel-desk-mx8mp.tar.bz2
 
</pre>
 
</pre>
  
Line 702: Line 245:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@sdvx-lite:/mnt/emmc# cd
+
root@desk-mx8mp:/mnt/emmc# cd
root@sdvx-lite:~# umount /mnt/emmc
+
root@desk-mx8mp:~# umount /mnt/emmc
root@sdvx-lite:~# reboot
+
root@desk-mx8mp:~# reboot
 
</pre>
 
</pre>
  
Line 710: Line 253:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
=> setenv bootcmd run mmcboot
+
u-boot=> setenv bootcmd run mmcboot
=> saveenv
+
u-boot=> saveenv
</pre>
 
 
 
==== ext4 partition ====
 
For using an <b>ext4</b> 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 <code>environment</code> has to be properly configured:
 
 
 
<pre class="workstation-terminal">
 
=> 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
 
 
</pre>
 
</pre>
  
 
----
 
----
  
[[Category:ORCA]]
+
[[Category:ORCA]] [[Category:MITO 8M Mini]]

Revision as of 11:28, 16 February 2022

History
Version Issue Date Notes
1.0.0 Feb 2022 First DESK-MX8M-L 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 threee 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 eMMC[edit | edit source]

Boot[edit | edit source]

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

mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 2 ${blocks}

Load Boot binary form a tftp server:

u-boot=> run load
Using ethernet@30be0000 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.90
Filename 'desk-mx8m/flash.bin'.
Load address: 0x40480000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ########
         1.8 MiB/s
done
Bytes transferred = 8355840 (7f8000 hex)
u-boot=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device
u-boot=> run mmc_update
=>

Load Boot binary form an SD card:

Hit ENTER within 1 seconds to stop autoboot
=> fatload mmc 1:1 ${loadaddr} flash.bin
fatload mmc 1:1 ${loadaddr} flash.bin
8355840 bytes read in 373 ms (21.4 MiB/s)
u-boot=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device
u-boot=> run mmc_update
=>

kernel image and device tree[edit | edit source]

The following environment variables has to be set (or at least checked) in u-boot; depending on the formatted eMMC partition (FAT32 or ext4), the vars has to be properly modified:

FAT32[edit | edit source]

setenv mmc_loadk 'fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'
setenv mmc_loadfdt 'fatload mmc ${mmcdev}:1 ${fdt_addr} ${fdt_file}'
setenv mmc_loadsplash 'fatload mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}'

ext4[edit | edit source]

setenv mmc_loadk 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'
setenv mmc_loadfdt 'ext4load mmc ${mmcdev}:1 ${fdt_addr} ${fdt_file}'
setenv mmc_loadsplash 'ext4load mmc ${mmcdev}:1 ${loadaddr} ${splashfile}; cp.b ${loadaddr} ${splashimage} ${filesize}'

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 previously 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):

setenv 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'
setenv mmcargs 'setenv bootargs root=${mmcroot}'
setenv mmcroot '/dev/mmcblk2p2 rootwait rw'
saveenv


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 Image
=> setenv fdt_file imx8mp-mito8mplus-cb1001.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 eMMC[edit | edit source]

  • boot the system via SD or NFS as described in the e Booting from NFS
  • 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:

Partitioning[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},'''83''',-; echo ${rfs_start},${rfs_size},83,-; } | sfdisk --force ${node}

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

E.g.


root@sdvx-lite:~# ./sdcard-partition.sh /dev/mmcblk2
...
...

  • 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@sdvx-lite:~# mount /dev/mmcblk2p1 /mnt/emmc
[   40.988575] FAT-fs (mmcblk2p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
root@sdvx-lite:~# cd /mnt/emmc
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/*dtb .
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/Image .
root@sdvx-lite:/mnt/emmc# cp /tftpboot/desk-mx-l/splash_image.bmp .
root@sdvx-lite:/mnt/emmc# cd
root@sdvx-lite:~# umount /mnt/emmc
  • now mount the EXT4 volume in the temporary directory

E.g.:

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

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

u-boot=> setenv bootcmd run mmcboot
u-boot=> saveenv