Open main menu

DAVE Developer's Wiki β

DESK-MX8M-L/Deployment/Standalone boot

< DESK-MX8M-L
Revision as of 11:47, 16 February 2022 by U0007 (talk | contribs) (Program boot images into eMMC)

History
Version Issue Date Notes
1.0.0 Feb 2022 First DESK-MX8M-L release


Contents

Standalone bootEdit

IntroductionEdit

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.


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


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 eMMCEdit

BootEdit

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
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 treeEdit

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:

FAT32Edit

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

ext4Edit

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, fdt_file 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 varsEdit

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 eMMCEdit

  • 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:

PartitioningEdit

#!/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