Open main menu

DAVE Developer's Wiki β

Changes

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

3,369 bytes removed, 18:17, 27 December 2023
no edit summary
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
|-
!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"|Version
!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"|X.Y.Z{{oldid|16139|2022/02/17}}|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; borderFirst DESK-bottom:solid 2px #73B2C7; backgroundMX8M-color:#edf8fb; padding:5px; color:#000000"|TBDL 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|2023/02/24}}
| 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:#edf8fbededed; padding:5px; color:#000000"|[TBD_link X.Y.Z]2023/08/23|! style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fbededed; padding:5px; color:#000000"|Month Year|style="borderDESK-left:solid 2px #73B2C7; borderMX8M-right:solid 2px #73B2C7;borderL-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBD4.0.0 release
|-
|}
==How to create a bootable SD card==
{{ImportantMessage|text=The procedure described here was tested with a physical machine. In case of a virtual machine such as the [[Managed_Virtual_Machine_This article shows how to (MVMre)|MVM]]create the bootable SD card, it might not work properly. Also, it is worth remembering that USB controller of from the MVM is disabled binary images produced by default. See also the DESK-MX-L Yocto build, using a standard SD image flasher like [[MVM_FAQs#Qhttps:_How_to_use_the_USB_devices_connected_to_the_host_machine//etcher.balena.3F|this section]io/ balenaEtcher].}}
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 use ''balenaEtcher'' on a 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 [https://mirror.dave.eu/desk-mx-l/ mirror binary server] selecting the proper [[DESK-MX8M-L | DESK-MX8M-L]] release
**among the binaries made available in the [[mirror:desk-mp1-l/| mirror]] there are several <code>*.wic.bz2</code> files for the available releases. In particular, there is the <code>dave-image-devel-desk-mx8mp.wic.bz2</code> (for ORCA) or <code>dave-image-devel-desk-mx8mm.wic.bz2</code> (for MITO8M Mini) files. This image is the one used to program the microSD card delivered along with the evaluation kit.
* connect the microSD card to the PC Host
* open balenaEtcher tool
* once the tool is open:
** select the binary to flash by clicking on "Flash from file"
** select the microSD to flash by clicking on "Select target"
** flash the uSD by clicking o "Flash".
This article shows how to create a bootable microSD for the [[DESK-MX8M-L/General/Release_Notes_(DESK-MX8M-L){|DESK-MX8M-L Release Notes] kit by using a simple bash script. <br>'''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 (>class=''TBD'') distribution with *a 16 GB microSD card [1]*the binary files delivered along with the [[Axel_Embedded_Linux_Kit_(XELK)#Downloadable_binary_images|DESKMX8M-L ''1.x.x'']].The resulting card is partitioned as depicted [[Axel_Embedded_Linux_Kit_(XELK)#XELK_microSD_Layout|here]]. The script - named <code>mksd.sh</code> - can be realized with the following code:<pre>#!/bin/bash if [[ -z $1 || -z $2 || -z $3 || -z $4 || -z $5 ]]then echo "$0 Usage:wikitable" echo style=" $0 <device> <utext-boot.img> <SPL> <binaries directory> <rootfs tar.bz2>" echo " Examplealign: $0 /dev/sdc u-boot.img SPL binaries/ rootfs.tar.bz2center" exitfi if [ "$(whoami)" != "root" ]then echo "you must be root to run this script!" exitfi if ! |[[ File:DESK-b $1 ]]then echo "$1 is not a valid block device!" exitfi if ! [[ MP1-e $2 ]]then echo "Incorrect u-boot.img location!" exitfi if ! [[ -e $3 ]]then echo "Incorrect SPL location!" exitfi if ! [[ -d $4 ]]then echo "Incorrect Binaries location!" exitfi if ! [[ L-f $5 ]]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=""fiUBOOT=$2SPL=$3BINARIES=$4RFS=$5 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 -F 32 -n BOOT "$DRIVE$PART"1 #> /dev/nullmkfs.ext3 [File:DESK-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.0 balenaEtcher flash.)png|center|thumb|200x200px|Flashing]"mount "$DRIVE$PART"2 /mnttar jxf $RFS -C /mnt > /dev/nullchmod 755 /mntumount "$DRIVE$PART"2 echo "[Programming SPL]"dd if=$SPL of=$DRIVE bs=512 seek=2 conv=fsync echo "[Programming u-boot.img]"dd if=$UBOOT of=$DRIVE bs=1k seek=69 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>desk</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>uImage</code>* Device tree blob: <code>''carrier''.dtb</code>. This is the list of the binary files that will be used by the script:<pre>dvdk@vagrant:~/desk-{{{kit}}}$ ls -la...TBD directory listing...</pre>You can now run the script, by passing the following parameters:*Device file of the microSD card (<code>/dev/sdc</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}}}$ ./mksd.sh /dev/sd<x> <u-boot.img> <SPL> <binaries_dir>/ <rfs_filename>......TBD ......</pre>  [1] In case you have a different size, you'll need to change the <code>sfdisk</code> parameters accordingly. ===bootscr === Once you got the new binaries compiled from your modified sources, they have to be installed on 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: ''TBDFile: bootscript.txt dump'' <pre>echo 'bootscript generated with command "mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX MP1-d bootscript.txt boot.scr"' setenv desk_release 'desk-mx6-lL-1.0.0' if test 0x${cb_configid#} = 0x00000012;then if test ${cpu} = 6DL; then setenv fdtfile ${desk_release}_imx6dl-sbcx-cb0012balenaEtcher valid.dtbpng|center|thumb|200x200px|Validating]] 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 resetfi setenv bootfile ${desk_release}_uImage setenv mmc_loadk 'fatload mmc ${mmcdev}:1 ${loadaddr} ${bootfile}'setenv mmc_loadfdt 'fatload mmc ${mmcdev}:1 ${fdtaddr} ${fdtfile|}'
echo Booting AxelLite=== 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 startup* <code>FAT32</code> first partition: this will be mapped to the <code>/dev/mmcblk1p1</code> device in Linux** usually this partition contains the Linux kernel binary and the device tree blob** the splash screen image is stored in this partition too for a splash image showing during U-DESK-SBCX via mmcboot with ${fdtfile} as Boot startup* <code>ext4</code> second partition: this will be mapped to the <code>/dev/mmcblk1p2</code> device treein Linux** this partition contains the Linux ''root file system''
run mmcboot=== Creating the SD card from binary artifacts ===
echo mmcboot FAILURE</pre>Even if the overall binary artifacts have been created by the Yocto build, it is highly discouraged to manually create the SD card starting from them.
The Yocto build take care about the overall binary consistance (like kernel modules and compile it using:so on) avoiding to mistmatch different version.
<pre>mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX -d bootscriptMoreover, the SD card is intended to be used during the development process and not for the production phase (where other deployment specifications and details have to be taken into account).txt boot.scr</pre>
Then copy the ''boot.scr'' into the <code><binaries_dir></code> directories used by the script to create the SD card.
----
[[Category:ORCA]] [[Category:MITO 8M Mini]]
8,226
edits