Difference between revisions of "Template:How to create a bootable SD card"

From DAVE Developer's Wiki
Jump to: navigation, search
Template>U0007
 
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 
!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"|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:#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
+
|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|xxxx|Year/Month/Day}}
|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; 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
 
|-
 
|-
 
|-
 
|-
|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:#ededed; padding:5px; color:#000000"|Year/Month/Day
|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; border-bottom:solid 2px #73B2C7; background-color:#ededed; 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
 
 
|-
 
|-
 
|}
 
|}
 
<section end=History/>
 
<section end=History/>
 +
__FORCETOC__
 
<section begin=Body/>
 
<section begin=Body/>
  
 
==How to create a bootable SD card==
 
==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_(MVM)|MVM]], it might not work properly. Also, it is worth remembering that USB controller of the MVM is disabled by default. See also [[MVM_FAQs#Q:_How_to_use_the_USB_devices_connected_to_the_host_machine.3F|this section]].}}
+
This article shows how to (re)create the bootable SD card, from the binary images produced by the DESK-MX-L Yocto build, using a standard SD image flasher like [https://etcher.balena.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-{{{kit-code}}}-L | DESK-{{{kit-code}}}-L]] release
 +
**among the binaries made available in the [[mirror:{{{kit-repo}}}/| mirror]] there are several <code>*.wic.bz2</code> files for the available releases. In particular, there is the <code>dave-image-devel-desk-{{{kit}}}.wic.bz2</code> (for {{{nome-som}}}) file. 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 <code>Flash from file</code>
 +
** select the microSD to flash by clicking on <code>Select target</code>
 +
** flash the uSD by clicking o <code>Flash</code>
  
This article shows how to create a bootable microSD for the [[DESK-{{{kit-code}}}-L/General/Release_Notes_(DESK-{{{kit-code}}}-L)|DESK-{{{kit-code}}}-L Release Notes] kit by using a simple bash script. <br>
+
{| class="wikitable" style="text-align: center"
'''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>
+
|[[File:DESK-MP1-L-1.0.0 balenaEtcher unpack.png|center|thumb|200x200px|Unpacking]]
+
|[[File:DESK-MP1-L-1.0.0 balenaEtcher flash.png|center|thumb|200x200px|Flashing]]
The procedure has been tested on a Linux PC running Ubuntu LTS (>=''TBD'') distribution with
+
|[[File:DESK-MP1-L-1.0.0 balenaEtcher valid.png|center|thumb|200x200px|Validating]]
*a 16 GB microSD card [1]
+
|}
*the binary files delivered along with the [[Axel_Embedded_Linux_Kit_(XELK)#Downloadable_binary_images|DESK{{{kit-code}}}-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> - looks like this:
 
<pre>
 
TBD : cat of mksd.sh script
 
</pre>
 
  
 +
=== SD card structure ===
 +
The created SD card has the following structure:
 +
* raw sectors for the bootloader storage: typically this is an 8MB raw part that stores the bootloader binaries (like <code>i{{{kit}}}_flash.bin</code>) for the bootrom startup
 +
* <code>FAT32</code> first partition: this will be mapped to the <code>/dev/mmcblkXp1</code> device in Linux
 +
** usually this partition contains the Linux kernel binary and the device tree blob
 +
** splash screen image is stored in this partition too for a splash image showing during U-Boot startup
 +
* <code>ext4</code> second partition: this will be mapped to the <code>/dev/mmcblkXp2</code> device in Linux
 +
** this partition contains the Linux ''root file system''
  
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:
+
=== Creating the SD card from binary artifacts ===
* 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:
+
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.
<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>
 
  
 +
The Yocto build takes care of the overall binary consistency (like kernel modules and so on) avoiding mismatching different versions.
  
[1] In case you have a different size, you'll need to change the <code>sfdisk</code> parameters accordingly.
+
Moreover, 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).
  
----
+
<section end=Body/>
  
 
[[Category:{{{nome-som}}}]]
 
[[Category:{{{nome-som}}}]]

Latest revision as of 09:08, 17 January 2024

History
Issue Date Notes

Year/Month/Day

TBD
Year/Month/Day TBD



How to create a bootable SD card[edit source]

This article shows how to (re)create the bootable SD card, from the binary images produced by the DESK-MX-L Yocto build, using a standard SD image flasher like 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 (*.wic or *.wic.bz2) from the mirror binary server selecting the proper [[DESK-{{{kit-code}}}-L | DESK-{{{kit-code}}}-L]] release
    • among the binaries made available in the [[mirror:{{{kit-repo}}}/| mirror]] there are several *.wic.bz2 files for the available releases. In particular, there is the dave-image-devel-desk-{{{kit}}}.wic.bz2 (for {{{nome-som}}}) file. 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
Unpacking
Flashing
Validating

SD card structure[edit source]

The created SD card has the following structure:

  • raw sectors for the bootloader storage: typically this is an 8MB raw part that stores the bootloader binaries (like i{{{kit}}}_flash.bin) for the bootrom startup
  • FAT32 first partition: this will be mapped to the /dev/mmcblkXp1 device in Linux
    • usually this partition contains the Linux kernel binary and the device tree blob
    • splash screen image is stored in this partition too for a splash image showing during U-Boot startup
  • ext4 second partition: this will be mapped to the /dev/mmcblkXp2 device in Linux
    • this partition contains the Linux root file system

Creating the SD card from binary artifacts[edit source]

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 takes care of the overall binary consistency (like kernel modules and so on) avoiding mismatching different versions.

Moreover, 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).


[[Category:{{{nome-som}}}]]