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

From DAVE Developer's Wiki
Jump to: navigation, search
(Partitioning)
(Program boot images into eMMC)
Line 39: Line 39:
  
 
<pre>
 
<pre>
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 64 ${blocks}
+
mmc_update=mmc dev; setexpr blocks ${filesize} / 0x200; setexpr blocks ${blocks} + 1; mmc write ${loadaddr} 0x40 ${blocks}
 
</pre>
 
</pre>
  
Line 79: Line 79:
 
done
 
done
 
Bytes transferred = 8355840 (7f8000 hex)
 
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
 
 
u-boot=>
 
u-boot=>
 
</pre>
 
</pre>
  
Load Boot binary form an <code>SD</code> card:
+
or load Boot binary form an <code>SD</code> card:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
Line 92: Line 88:
 
u-boot=> fatload mmc 1:1 ${loadaddr} flash.bin
 
u-boot=> fatload mmc 1:1 ${loadaddr} flash.bin
 
8355840 bytes read in 373 ms (21.4 MiB/s)
 
8355840 bytes read in 373 ms (21.4 MiB/s)
 +
u-boot=>
 +
</pre>
 +
 +
Program the Boot image on eMMC:
 +
 +
<pre class="workstation-terminal">
 
u-boot=> mmc dev 2
 
u-boot=> mmc dev 2
 
switch to partitions #0, OK
 
switch to partitions #0, OK
 
mmc2(part 0) is current device
 
mmc2(part 0) is current device
 
u-boot=> run mmc_update
 
u-boot=> run mmc_update
 +
switch to partitions #0, OK
 +
mmc2(part 0) is current device
 +
 +
MMC write: dev # 2, block # 64, count 16319 ... 16319 blocks written: OK
 
u-boot=>
 
u-boot=>
 
</pre>
 
</pre>

Revision as of 15:13, 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


200px-Emblem-important.svg.png

In the following paragraphs, we will take into account a real case using an embedded eMMC mounted in the ORCA or MITO 8M Mini SOMs

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} 0x40 ${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=>

or load Boot binary form an SD card:

Hit ENTER within 1 seconds to stop autoboot
u-boot=> fatload mmc 1:1 ${loadaddr} flash.bin
8355840 bytes read in 373 ms (21.4 MiB/s)
u-boot=>

Program the Boot image on eMMC:

u-boot=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device
u-boot=> run mmc_update
switch to partitions #0, OK
mmc2(part 0) is current device

MMC write: dev # 2, block # 64, count 16319 ... 16319 blocks written: OK
u-boot=>

Configuring the u-boot environment[edit | edit source]

Once the Boot Image has been correctly programmed, start the system from eMMC in order to configure/program the u-boot environment variables for a correct boot sequence.

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}'

Then, u-boot uses the previously listed commands for reading the binary images and starting the Linux file system from the eMMC 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 booti ${loadaddr} - ${fdtaddr}; fi; fi; fi'
setenv mmcargs 'setenv bootargs root=${mmcroot}'
setenv mmcroot '/dev/mmcblk2p2 rootwait rw'

boot vars[edit | edit source]

The following environment variables should be configured for u-boot properly identify the boot files, 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:

u-boot=> saveenv
Saving Environment to MMC...
Writing to MMC(2)... done
u-boot=> 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