Open main menu

DAVE Developer's Wiki β

Changes

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

2,208 bytes added, 08:57, 16 February 2022
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"|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"|X1.Y0.Z0|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 YearFeb 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"|[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; borderFirst DESK-right:solid 2px #73B2C7;borderMX8M-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBDL release
|-
|}
'''Note:''' Starting from this release the support for the SPL has been introduced in Uboot. Previous versions of this script will no longer produce a fully functional and bootable microSD card. <br>
The procedure has been tested on a Linux PC running Ubuntu LTS (>=''TBD''16.04) distribution with
*a 16 GB microSD card [1]
*the binary files delivered along with the [[Axel_Embedded_Linux_Kit_(XELK)DESK-MX8M-L/General/Release_Notes#Downloadable_binary_images|DESKMX8M-L ''12.x0.x''0-rc2]].The resulting card is partitioned as depicted [[Axel_Embedded_Linux_Kit_(XELK)ORCA_SOM/ORCA_Evaluation_Kit/Getting_started/Unboxing#XELK_microSD_LayoutmicroSD_Layout|here]].
The script - named <code>mksd.sh</code> - can be realized with the following code:
#!/bin/bash
if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 ]]
then
echo "$0 Usage:"
echo " $0 <device> <u-bootflash.img> <SPLbin> <binaries directory> <rootfs tar.bz2>" echo " Example: $0 /dev/sdc u-bootflash.img SPL bin binaries/ rootfs.tar.bz2"
exit
fi
if ! [[ -e $2 ]]
then
echo "Incorrect u-bootflash.img bin location!"
exit
fi
if ! [[ -e d $3 ]]then echo "Incorrect SPL location!" exitfi if ! [[ -d $4 ]]
then
echo "Incorrect Binaries location!"
fi
if ! [[ -f $5 4 ]]
then
echo "Incorrect rootfs location!"
PART=""
fi
UBOOTBOOT=$2SPLBINARIES=$3BINARIESRFS=$4RFS=$5
echo "All data on "$DRIVE" now will be destroyed! Continue? [y/n]"
umount "$DRIVE$PART"2
echo "[Programming SPL]"dd if=$SPL of=$DRIVE bs=512 seek=2 conv=fsync echo "[Programming u-bootflash.imgbin]"dd if=$UBOOT BOOT of=$DRIVE bs=1k seek=69 32 conv=fsync
echo "[Done]"
</pre>
Here is an example that shows how to use this script. Let's assume that the binary files were downloaded in the <code>desksdcard</code> subdirectory of the working directory. 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>uImageImage</code>* Device tree blob: <code>''carrier''imx8mp-mito8mplus-cb1001.dtb</code>or <code>imx8mm-mito8mmini.dtb</code>
This is the list of the binary files that will be used by the script:
<pre>
dvdk@vagrant:~/desk-{{{kit}}}mx-l/sdcard$ ls -lalaR.:total 734040drwxrwxr-x 3 dvdk dvdk 4096 Feb 16 09:41 .drwxr-xr-x 7 dvdk dvdk 4096 Feb 16 09:21 ..drwxrwxr-x 2 dvdk dvdk 4096 Feb 16 09:41 binaries-rwxrwxr-x 1 dvdk dvdk 743273295 Feb 16 09:34 dave-image-devel-desk-mx8mp.tar.bz2-rw-r--r-- 1 root root 8355840 Feb 16 09:32 flash.bin-rwxrwxr-x 1 dvdk dvdk 1908 Feb 16 09:22 mksd.sh ./binaries:total 27604drwxrwxr-x 2 dvdk dvdk 4096 Feb 16 09:41 .TBD directory listingdrwxrwxr-x 3 dvdk dvdk 4096 Feb 16 09:41 ..-rw-rw-r-- 1 dvdk dvdk 695 Feb 16 09:41 boot.scr-rw-r--r-- 1 dvdk dvdk 28150272 Feb 16 09:35 Image-rw-r--r-- 1 dvdk dvdk 40521 Feb 16 09:35 imx8mm-mito8mmini.dtb-rw-r--r-- 1 dvdk dvdk 58111 Feb 16 09:35 imx8mp-mito8mplus-cb1001.dtbdvdk@vagrant:~/desk-mx-l/sdcard$
</pre>
You can now run the script, by passing the following parameters:
*Device file of the microSD card (<code>/dev/sdcsdb</code> in the example)*U-Boot image*SPL
*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>
dvdk@vagrant:~/desk-{{{kit}}}mx-l/sdcard$ sudo ./mksd.sh /dev/sd<x> <usdb flash.bin binaries/ dave-image-devel-desk-mx8mp.tar.bz2All data on /dev/sdb now will be destroyed! Continue? [y/n]y[Partitioning /dev/sdb...]1024+0 records in1024+0 records out1048576 bytes (1.0 MB, 1.0 MiB) copied, 3.03198 s, 346 kB/sDISK SIZE - 15931539456 bytesChecking that no-bootone is using this disk right now ... OK Disk /dev/sdb: 14.img9 GiB, 15931539456 bytes, 31116288 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes > <SPL> <binaries_dir>Created a new DOS disklabel with disk identifier 0xcd2d3b4e.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 6.9 GiB./dev/sdb3: New situation: Device Boot Start End Sectors Size Id Type/dev/sdb1 * 32768 16777215 16744448 8G c W95 FAT32 (LBA)/dev/ <rfs_filename>sdb2 16777216 31116287 14339072 6.9G 83 Linux The partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.[Making filesystems...]mkfs.fat 3.0.28 (2015-05-16)mke2fs 1.42.13 (17-May-2015)Creating filesystem with 1792384 4k blocks and 448800 inodesFilesystem UUID: ce8daece-3f58-4b43-bd11-7bafd10bba73Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done  [Copying files...]'binaries/boot.scr' -> '/mnt/boot.scr''binaries/Image' -> '/mnt/Image''binaries/imx8mm-mito8mmini.dtb' -> '/mnt/imx8mm-mito8mmini.dtb'TBD 'binaries/imx8mp-mito8mplus-cb1001.dtb' -> '/mnt/imx8mp-mito8mplus-cb1001.dtb'[Extracting rfs (this may take a while...)][Programming flash.bin]8160+0 records in8160+0 records out8355840 bytes (8.4 MB, 8.0 MiB) copied, 24.2775 s, 344 kB/s[Done]dvdk@vagrant:~/desk-mx-l/sdcard$
</pre>
 
[1] In case you have a different size, you'll need to change the <code>sfdisk</code> parameters accordingly.
===bootscr boot.scr ===
Once you got the new binaries compiled from your modified sources, they have to be installed on the first SD partition preserving the original file names used into <i>boot.scr</i> u-boot bootscript.
Here below there is an example on how to create a <code>boot.scr</code> file from the '''bootscript.txt''' for booting from SD card:
* for [[ORCA SOM | ORCA SOM]]<pre>echo ''TBD: bootscript generated with command "mkimage -A ARM -T script -C none -n DESK-MX8M -d bootscript.txt dump'boot.scr"'
<pre>setenv fdtfile imx8mp-mito8mplus-cb1001.dtbecho setenv bootfile Imagesetenv mmc_loadk 'bootscript generated with command "mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX 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} -d bootscript.txt boot.scr"${fdt_addr}'
setenv desk_release 'deskecho Booting DESK-mx6-l-1.0.0'MX8M via mmcboot with ${fdtfile} as device tree
if test 0x${cb_configid#} = 0x00000012;run mmcbootthen if test ${cpu} = 6DL; then setenv fdtfile ${desk_release}_imx6dl-sbcx-cb0012.dtb else setenv fdtfile ${desk_release}_imx6q-sbcx-cb0012.dtb fielif test 0x${cb_configid#} = 0x00000013;then if test ${cpu} = 6DL; then setenv fdtfile ${desk_release}_imx6dl-sbcx-cb0013.dtb else setenv fdtfile ${desk_release}_imx6q-sbcx-cb0013.dtb fielif test 0x${cb_configid#} = 0xffffffff;then if test ${cpu} = 6DL; then setenv fdtfile ${desk_release}_imx6dl-desk-l-2.0.0.dtb else setenv fdtfile ${desk_release}_imx6q-desk-l-2.0.0.dtb fielse echo Invalid CB! Autoreset ... sleep 30 resetmmcboot FAILUREfi</pre>
setenv bootfile ${desk_release}_uImage* for [[MITO 8M Mini SOM | MITO 8M Mini SOM]]<pre>echo 'bootscript generated with command "mkimage -A ARM -T script -C none -n DESK-MX8M -d bootscript.txt boot.scr"'
setenv fdtfile imx8mm-mito8mmini.dtbsetenv bootfile Imagesetenv mmc_loadk 'fatload mmc ${mmcdevsd_dev}:1 ${loadaddr} ${bootfile}'setenv mmc_loadfdt 'fatload mmc ${mmcdevsd_dev}:1 ${fdtaddrfdt_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 AxelLite-DESK-SBCX MX8M via mmcboot with ${fdtfile} as device tree
run mmcboot
<pre>
mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX MX8M -d bootscript.txt boot.scr
</pre>
----
[[Category:ORCA]] [[Category:MITO 8M Mini]]
8,256
edits