Difference between revisions of "Template:How to create a bootable SD card"
Line 18: | Line 18: | ||
|} | |} | ||
<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== |
Revision as of 09:33, 27 October 2020
History | |||
---|---|---|---|
Version | Issue Date | Notes | |
X.Y.Z | Month Year | TBD | |
[TBD_link X.Y.Z] | Month Year | TBD |
How to create a bootable SD card[edit source]
The procedure described here was tested with a physical machine. In case of a virtual machine such as the MVM, it might not work properly. Also, it is worth remembering that USB controller of the MVM is disabled by default. See also this section. |
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.
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.
The procedure has been tested on a Linux PC running Ubuntu LTS (>=TBD) distribution with
- a 16 GB microSD card [1]
- the binary files delivered along with the DESK{{{kit-code}}}-L 1.x.x.
The resulting card is partitioned as depicted here.
The script - named mksd.sh
- looks like this:
TBD : cat of mksd.sh script
Here is an example that shows how to use this script. Let's assume that the binary files were downloaded in the desk
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:
boot.scr
- Linux kernel:
uImage
- Device tree blob:
carrier.dtb
.
This is the list of the binary files that will be used by the script:
dvdk@vagrant:~/desk-{{{kit}}}$ ls -la ... TBD directory listing ...
You can now run the script, by passing the following parameters:
- Device file of the microSD card (
/dev/sdc
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
.tar.bz2
file).
dvdk@vagrant:~/desk-{{{kit}}}$ ./mksd.sh /dev/sd<x> <u-boot.img> <SPL> <binaries_dir>/ <rfs_filename> ... ... TBD ... ...
[1] In case you have a different size, you'll need to change the sfdisk
parameters accordingly.
bootscr[edit source]
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 boot.scr u-boot bootscript.
Here below there is an example on how to create a boot.scr
file from the bootscript.txt for booting from SD card:
TBD: bootscript.txt dump
echo 'bootscript generated with command "mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX -d bootscript.txt boot.scr"' setenv desk_release 'desk-mx6-l-1.0.0' if test 0x${cb_configid#} = 0x00000012; then if test ${cpu} = 6DL; then setenv fdtfile ${desk_release}_imx6dl-sbcx-cb0012.dtb else setenv fdtfile ${desk_release}_imx6q-sbcx-cb0012.dtb fi elif 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 fi elif 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 fi else echo Invalid CB! Autoreset ... sleep 30 reset fi 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-DESK-SBCX via mmcboot with ${fdtfile} as device tree run mmcboot echo mmcboot FAILURE
and compile it using:
mkimage -A ARM -T script -C none -n AXEL-Lite-DESK-SBCX -d bootscript.txt boot.scr
Then copy the boot.scr into the <binaries_dir>
directories used by the script to create the SD card.
[[Category:{{{nome-som}}}]]