Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX8M-L/Development/How to create a bootable microSD card

9,186 bytes removed, 18:17, 27 December 2023
no edit summary
|-
|-
!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"|ID#
!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:#edf8fb; padding:5px; color:#000000"|{{oldid|16139|16139}}|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"|172022/02/202217}}
|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:#ededed; padding:5px; color:#000000" |{{oldid|17546|17546}}| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |242023/02/202324}}
| style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX8M-L-2.0.0 release
|-
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |{{oldid|18303|18303}}! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |252023/0708/202323
! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000" |DESK-MX8M-L-4.0.0 release
|-
==How to create a bootable SD card==
{{ImportantMessage|text=The procedure described here was tested with a virtual machine such as the [[Managed_Virtual_Machine_This article shows how to (MVMre)|MVM]]. The USB controller of create the bootable SD card, from the MVM should be enabled binary images produced by default. If you are the DESK-MX-L Yocto build, using Linux-based distribution and are having trouble detecting a USB device in virtual machine, please make sure your user belongs to the vboxusers groupstandard SD image flasher like [https://etcher.balena.}}io/ balenaEtcher]
This article shows The process is relatively straightforward: it consists of writing the WIC file of interest generated by Yocto onto the SD card. The following instruction explains how to create use ''balenaEtcher'' on a bootable microSD for Windows host. The procedure is similar when working with a Linux host.* download the desired binary image to flash (<code>*.wic</code> or <code>*.wic.bz2</code>) from the [[DESKhttps://mirror.dave.eu/desk-MX8Mmx-Ll/General/Release_Notes_(mirror binary server] selecting the proper [[DESK-MX8M-L)|DESK-MX8M-L Release Notes] kit by using a simple bash script. <br>] release'''Note**among the binaries made available in the [[mirror:''' Starting from '''DESKdesk-MX8Mmp1-L-2l/| mirror]] there are several <code>*.0wic.0''' release bz2</code> files for the support for available releases. In particular, there is the SPL has been introduced in U<code>dave-image-devel-desk-Bootmx8mp. Previous versions of this script will no longer produce a fully functional and bootable microSD cardwic. bz2</code> (for ORCA) or <brcode> The procedure has been tested on a MVM released with '''DESKdave-image-devel-MX8Mdesk-L 4mx8mm.wic.0bz2</code> (for MITO8M Mini) files.0''' release This image is the one used to program the microSD card delivered along with the evaluation kit.*a 32 GB connect the microSD card [1]to the PC Host* open balenaEtcher tool*a USB SD card readeronce the tool is open:** select the binary files delivered along with to flash by clicking on "Flash from file"** select the [[DESK-MX8M-L/General/Release_Notes#Downloadable_binary_images_3|DESK-MX8M-L 4.0.0]]microSD to flash by clicking on "Select target"The resulting card is partitioned as depicted [[ORCA_SOM/ORCA_Evaluation_Kit/Getting_started/Unboxing#microSD_Layout|here]]** flash the uSD by clicking o "Flash".
The script - named <code>desk-mx8m-l-4.0.0_mksd.sh</code> - can be realized with the following code: <pre {| class="workstation-terminal">#!/bin/bash if [[ -z $1 || -z $2 || -z $3 || -z $4 ]]then echo "$0 Usage:" echo wikitable" $0 <device> <flash.bin> <binaries directory> <rootfs tar.bz2>" echo " Example: $0 /dev/sdc flash.bin binaries/ rootfs.tar.bz2" exitfi if [ "$(whoami)" !style= "root" ]then echo "you must be root to run this script!" exitfi if ! [[ text-b $1 ]]then echo "$1 is not a valid block device!align: center" exitfi if ! |[[ File:DESK-e $2 ]]then echo "Incorrect flash.bin location!" exitfi if ! [[ MP1-d $3 ]]then echo "Incorrect Binaries location!" exitfi if ! [[ L-f $4 ]]then echo "Incorrect rootfs location!" exitfi DRIVE=$1if [[ "$DRIVE" == *"mmcblk"* ]]then echo "You're using a mmc device, I need to fix partition names" PART="p"else PART=""fiBOOT=$2BINARIES=$3RFS=$4 echo "All data on "$DRIVE" now will be destroyed! Continue? [y/n]"read ansif ! [ $ans == 'y' ]then exitfi echo "[Partitioning $1.0.0 balenaEtcher unpack.]" dd if=/dev/zero of=$DRIVE bs=1024 count=1024 SIZE=`fdisk -l $DRIVE png| grep Disk center| awk '{print $5}'` echo DISK SIZE - $SIZE bytes CYLINDERS=`echo $SIZE/255/63/512 thumb| bc` # check if we're running an old (e.g. 2.20.x) or new (e.g. 2.24.x) sfdisksfdisk --help 200x200px| grep -- -H if [ "$?" -eq "0" Unpacking]]then { echo 40,1380,0x0c,* echo 1420,,83,- } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVEelse{ echo 16M,8176M,0x0c,* echo 8192M,,83,-} | sfdisk $DRIVEfi partprobe  echo "[Making filesystems...]"mkfs.vfat [File:DESK-F 32 -n BOOT "$DRIVE$PART"1 #> /dev/nullmkfs.ext3 -F MP1-L ROOTFS "$DRIVE$PART"2 #> /dev/null echo "[Copying files...]" binaries_dir=${BINARIES%/}mount "$DRIVE$PART"1 /mntcp -av --no-preserve=ownership $binaries_dir/* /mnt/umount "$DRIVE$PART"echo "[Extracting rfs (this may take a while.0..)]"mount "$DRIVE$PART"2 /mnttar jxf $RFS -C /mnt > /dev/nullchmod 755 /mntumount "$DRIVE$PART"2 echo "[Programming 0 balenaEtcher flash.binpng|center|thumb|200x200px|Flashing]"dd if=$BOOT of=$DRIVE bs=1k seek=32 conv=fsync echo "[Done]"</pre>{{ImportantMessage|text=if you are making a uSD for MITO 8M Mini SOM, then the last line must be modified with '''dd if=$BOOT of=$DRIVE bs=1k seek=33'''.}} Here is an example that shows how to use this script. We use here files delivered with [[File:DESK-MX8M-L/General/Release_Notes#Downloadable_binary_images_3|DESK-MX8MMP1-L 4.0.0]] release. Before invoking the script, the following files has to be renamed in order to make them compatible with the default U-Boot environment variables:* bootscript: <code>boot.scr</code>* Linux kernel: <code>Image</code>* Device tree blob: <code>imx8mp-mito8mplus-cb1008.dtb</code> or <code>imx8mm-mito8mmini-cb100a.dtb</code> Let's start with creating <code>boot.scr</code>. On MVM there is <code>/home/dvdk/desk-mx-l/desk-mx8m-l-4.0.0_bootscript.txt</code> file that we can use to create needed file. Here below there is an example on how to create a <code>boot.scr</code> file from the '''desk-mx8m-l-4.0.0_bootscript.txt''' for booting from SD card: <pre class="workstation-terminal">echo 'bootscript generated with command "mkimage -A ARM -T script -C none -n DESK-MX8M -d bootscript.txt boot.scr"' setenv desk_release 'desk-mx8m-l-4.0.0' if test 0x${cb_configid#} = 0x00001001;then setenv fdtfile imx8mp-mito8mplus-cb1001.dtbelif test 0x${cb_configid#} = 0x00001004;then setenv fdtfile imx8mp-mito8mplus-cb1004.dtbelif test 0x${cb_configid#} = 0x00001005;then setenv fdtfile imx8mp-mito8mplus-cb1005.dtb # CM7 boot setenv cm7_loadaddr 0x48000000 setenv cm7_tcm_start 0x7e0000 setenv cm7_boot 'fatload mmc ${sd_dev}:1 ${cm7_loadaddr} stress_m7.bin;cp.b ${cm7_loadaddr} ${cm7_tcm_start} 20000; bootaux ${cm7_tcm_start}'elif test 0x${cb_configid#} = 0x00001008;then setenv fdtfile imx8mp-mito8mplus-cb1008.dtbelif test 0x${cb_configid#} = 0x0000100a;then setenv fdtfile imx8mm-mito8mmini-cb100a.dtbelse echo Invalid CB ConfigID! Autoreset ... sleep 30 resetfi setenv bootfile Imagesetenv mmc_loadk 'fatload mmc ${sd_dev}:1 ${loadaddr} ${bootfile}'setenv mmc_loadfdt 'fatload mmc ${sd_dev}:1 ${fdt_addr} ${fdtfile}'setenv mmcboot 'run mmc_loadk; run mmc_loadfdt; run bootk'setenv bootargs 'console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200 root=/dev/mmcblk1p2'setenv bootk 'booti ${loadaddr} - ${fdt_addr}' echo Booting DESK-MX8M via mmcboot with ${fdtfile} as device tree run mmcboot echo mmcboot FAILURE </pre> and compile it using:<pre class="workstation-terminal">dvdk@vagrant:~$ mkimage -A ARM -T script -C none -n DESK-MX8M -d ~/desk-mx-l/desk-mx8m-l-4.0.0_bootscript.txt ~/desk-mx-l/boot.scrImage Name: DESK-MX8MCreated: Tue Jul 25 12:24:35 2023Image Type: ARM Linux Script (uncompressed)Data Size: 1371 Bytes = 1.34 KiB = 0balenaEtcher valid.00 MiBLoad Address: 00000000Entry Point: 00000000Contents: Image 0: 1363 Bytes = 1.33 KiB = 0.00 MiBdvdk@vagrant:~$</pre> In the case of you don't have some file on MVM, please download it from [https://mirror.dave.eu/desk-mx-l mirro.dave.eu].  We will copy them into <code>~/desk-mx-l/desk</code> directory. Needed binary files can be found on <code>MVM</code> in the following location: <pre class="workstation-terminal">dvdk@vagrant:~$ mkdir -p ~/desk-mx-l/deskdvdk@vagrant:~$ cd ~/desk-mx-l/deskdvdk@vagrant:~/desk-mx-l/desk$ ls /tftpboot/desk-mx8m-l/ -ltotal 34872-rw-r--r-- 1 dvdk root 31351296 Jul 24 08:50 desk-mx8m-l-4.0.0_Image-rw-r--r-- 1 dvdk root 1406688 Jul 24 08:48 desk-mx8m-l-4.0.0_imx8mm_flash.bin-rw-r--r-- 1 dvdk root 43034 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mm-mito8mmini-cb100a.dtb-rw-r--r-- 1 dvdk root 43022 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mm-mito8mmini.dtb-rw-r--r-- 1 dvdk root 1433040 Jul 24 08:48 desk-mx8m-l-4.0.0_imx8mp_flash.bin-rw-r--r-- 1 dvdk root 60443 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mp-mito8mplus-cb1001.dtb-rw-r--r-- 1 dvdk root 62520 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mp-mito8mplus-cb1004.dtb-rw-r--r-- 1 dvdk root 61258 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mp-mito8mplus-cb1005.dtb-rw-r--r-- 1 dvdk root 61299 Jul 24 08:50 desk-mx8m-l-4.0.0_imx8mp-mito8mplus-cb1008.dtblrwxrwxrwx 1 root root 49 Jul 24 09:42 Image -> /tftpboot/desk-mx8m-l/desk-mx8m-l-4.0.0_Imagelrwxrwxrwx 1 root root 60 Jul 24 09:42 imx8mm_flash.bin -> /tftpboot/desk-mx8m-l/desk-mx8m-l-4.0.0_imx8mm_flash.binlrwxrwxrwx 1 root root 72 Jul 24 09:42 imx8mm-mito8mmini-cb100a.dtb -> /tftpboot/desk-mx8m-l/desk-mx8m-l-4.0.0_imx8mm-mito8mmini-cb100a.dtblrwxrwxrwx 1 root root 60 Jul 24 09:42 imx8mp_flash.bin -> /tftpboot/desk-mx8m-l/desk-mx8m-l-4.0.0_imx8mp_flash.binlrwxrwxrwx 1 root root 72 Jul 24 09:42 imx8mp-mito8mplus-cb1008.dtb -> /tftpboot/desk-mx8m-l/desk-mx8m-l-4.0.0_imx8mp-mito8mplus-cb1008.dtb-rw-r--r-- 1 dvdk root 1152054 Jul 24 08:48 splash_image.bmpdvdk@vagrant:~/desk-mx-l/desk$ mkdir binariesdvdk@vagrant:~/desk-mx-l/desk$ cp /tftpboot/desk-mx8m-l/Image binaries/dvdk@vagrant:~/desk-mx-l/desk$ cp /tftpboot/desk-mx8m-l/imx8mp-mito8mplus-cb1008.dtb binaries/dvdk@vagrant:~/desk-mx-l/desk$ cp ~/desk-mx-l/boot.scr binaries/dvdk@vagrant:~/desk-mx-l/desk$ cp /tftpboot/desk-mx8m-l/imx8mp_flash.bin flash.bindvdk@vagrant:~/desk-mx-l/desk$ </pre>You can now run the script, by passing the following parameters:*Device file of the microSD card (<code>/dev/sdb</code> in the example)*Boot image*Path of the directory containing the bootscript file, the Linux kernel image, and the device tree blob files*Archive of the target's root file system (compressed as <code>.tar.bz2</code> file).<pre class="workstation-terminal">dvdk@vagrant:~/desk-mx-l/desk$ cd ~/desk-mx-l/dvdk@vagrant:~/desk-mx-l$ sudo umount /dev/sdb*umount: /dev/sdb: not mounted.umount: /dev/sdb1: not mounted.dvdk@vagrant:~/desk-mx-l$ sudo ./desk-mx8m-l-4.0.0_mksd.sh /dev/sdb desk/flash.bin desk/binaries/ rfs/desk-mx8m-l-4.0.0_desk-image-qt6-desk-mx8mp.tar.bz2 All data on /dev/sdb now will be destroyed! Continue? [y/npng|center|thumb|200x200px|Validating]y[Partitioning /dev/sdb...]1024+0 records in1024+0 records out1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.285905 s, 3.7 MB/sDISK SIZE - 31914983424 bytesChecking that no-one is using this disk right now ... OK Disk /dev/sdb: 29.74 GiB, 31914983424 bytes, 62333952 sectorsDisk model: Transcend Units: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes >>> Created a new DOS disklabel with disk identifier 0x688f6e07./dev/sdb1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 8 GiB./dev/sdb2: Created a new partition 2 of type 'Linux' and of size 21.7 GiB./dev/sdb3: Done.|}
New situation=== SD card structure ===The created SD card has the following structure:* raw sectors for the bootloader storage:tipically this is a 8MB raw part where storing the bootloader binaries (like <code>imx8mp_flash.bin</code>) for the bootrom startupDisklabel type* <code>FAT32</code> first partition: dosthis will be mapped to the <code>/dev/mmcblk1p1</code> device in Linux** usually this partition contains the Linux kernel binary and the device tree blobDisk identifier** the splash screen image is stored in this partition too for a splash image showing during U-Boot startup* <code>ext4</code> second partition: 0x688f6e07this will be mapped to the <code>/dev/mmcblk1p2</code> device in Linux** this partition contains the Linux ''root file system''
Device Boot Start End Sectors Size Id Type/dev/sdb1 * 32768 16777215 16744448 8G c W95 FAT32 (LBA)/dev/sdb2 16777216 62333951 45556736 21.7G 83 Linux=== Creating the SD card from binary artifacts ===
The partition table has Even if the overall binary artifacts have been altered.Calling ioctl() created by the Yocto build, it is highly discouraged to re-read partition table.Syncing disks.[Making filesystems..manually create the SD card starting from them.]mkfs.fat 4.1 (2017-01-24)mke2fs 1.45.5 (07-Jan-2020)Creating filesystem with 5694592 4k blocks and 1425408 inodesFilesystem UUID: 393fccfd-00af-487c-ae97-a255d18ab558Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Allocating group tables: done Writing inode tables: done Creating journal The Yocto build take care about the overall binary consistance (32768 blockslike kernel modules and so on): doneWriting superblocks and filesystem accounting information: done avoiding to mistmatch different version.
[Copying files...]'desk/binaries/boot.scr' -> '/mnt/boot.scr''desk/binaries/desk-mx8m-l-4.0.0_bootscript.txt' -> '/mnt/desk-mx8m-l-4.0.0_bootscript.txt''desk/binaries/Image' -> '/mnt/Image''desk/binaries/imx8mp-mito8mplus-cb1008.dtb' -> '/mnt/imx8mp-mito8mplus-cb1008.dtb'[Extracting rfs Moreover, the SD card is intended to be used during the development process and not for the production phase (this may take a while...where other deployment specifications and details have to be taken into account)][Programming flash.bin]1399+1 records in1399+1 records out1433040 bytes (1.4 MB, 1.4 MiB) copied, 0.30112 s, 4.8 MB/s[Done]dvdk@vagrant:~/desk-mx-l$</pre>
[1] In case you have a different size, you'll need to change the <code>sfdisk</code> parameters accordingly.
----
[[Category:ORCA]] [[Category:MITO 8M Mini]]
8,286
edits