1. Introduction[edit | edit source]
STMicroelectronics delivers also a script runing on Linux host PC to populate ONLY the microSD card device.
This script is located here : build-<DISTRO>-<MACHINE>/tmp-glibc/deploy/images/<MACHINE>/scripts/
This script is also located in the Starter Package/<VERSION>/ images/stm32mp1/scripts.
This script as STM32CubeProgrammer tool is using Flashlayout.tsv file in input parameter
This script creates a raw file <FlashLayoutName>.raw and a txt file <FlashLayoutName>.how_to_update.txt
Then you can use this raw file to populate your microSD card inserted on your HOST PC
2. Usage[edit | edit source]
PC $> cd build-<DISTRO>-<MACHINE>/tmp-glibc/deploy/images/<MACHINE>/scripts
PC $> ./create_sdcard_from_flashlayout.sh ../flashlayout_<built-image>/<FlashLayout file>
Example :
PC $> cd build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/stm32mp1/scripts/ PC $> ./create_sdcard_from_flashlayout.sh ../flashlayout_st-image-weston/FlashLayout_sdcard_stm32mp157c-ev1-trusted.tsv Create Raw empty image: ../flashlayout_st-image-weston/../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw of 1536MB Create partition table: [CREATED] part 1: fsbl1 [partition size 256.0 KiB] [CREATED] part 2: fsbl2 [partition size 256.0 KiB] [CREATED] part 3: ssbl [partition size 2.5 MiB] [CREATED] part 4: bootfs [partition size 64.0 MiB] [CREATED] part 5: vendorfs [partition size 16.0 MiB] [CREATED] part 6: rootfs [partition size 750.4 MiB] [CREATED] part 7: userfs [partition size 702.5 MiB] Partition table from ../flashlayout_st-image-weston/../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw Disk ../flashlayout_st-image-weston/../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw: 3145728 sectors, 1.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8E3FE74B-3B58-4617-B71B-5EC498875478 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 3145694 Partitions will be aligned on 2-sector boundaries Total free space is 0 sectors (0 bytes) Number Start (sector) End (sector) Size Code Name 1 34 545 256.0 KiB 8300 fsbl1 2 546 1057 256.0 KiB 8300 fsbl2 3 1058 6177 2.5 MiB 8300 ssbl 4 6178 137249 64.0 MiB 8300 bootfs 5 137250 170017 16.0 MiB 8300 vendorfs 6 170018 1706881 750.4 MiB 8300 rootfs 7 1706882 3145694 702.5 MiB 8300 userfs Populate raw image with image content: [ FILLED ] part 1: fsbl1, image: tf-a-stm32mp157c-ev1-trusted.stm32 [ FILLED ] part 2: fsbl2, image: tf-a-stm32mp157c-ev1-trusted.stm32 [ FILLED ] part 3: ssbl, image: u-boot-stm32mp157c-ev1-trusted.stm32 [ FILLED ] part 4: bootfs, image: st-image-bootfs-openstlinux-weston-stm32mp1.ext4 [ FILLED ] part 5: vendorfs, image: st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 [ FILLED ] part 6: rootfs, image: st-image-weston-openstlinux-weston-stm32mp1.ext4 [ FILLED ] part 7: userfs, image: st-image-userfs-openstlinux-weston-stm32mp1.ext4 ########################################################################### ########################################################################### RAW IMAGE generated: ../flashlayout_st-image-weston/../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw WARNING: before to use the command dd, please umount all the partitions associated to SDCARD. sudo umount `lsblk --list | grep mmcblk0 | grep part | gawk '{ print $7 }' | tr '\n' ' '` To put this raw image on sdcard: sudo dd if=../flashlayout_st-image-weston/../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw of=/dev/mmcblk0 bs=8M conv=fdatasync (mmcblk0 can be replaced by: sdX if it's a device dedicated to receive the raw image (where X can be a, b, c, d, e) ########################################################################### ###########################################################################
3. Populate the microSD card inserted on your linux host PC with the created raw file[edit | edit source]
You need first to retrieve the volume name of your drive (USB Key or MMC card)
To connect a USB device to the virtual machine manually, select VM > Removable Devices > Device Name > Connect (Disconnect from host)
More explanations for this specific case here
Insert your drive then use the following command :
- In this example, the volume name is sdd (microSD card is inserted with USB key)
PC $> cat /proc/partitions major minor #blocks name 8 0 488386584 sda 8 1 999424 sda1 8 2 1 sda2 8 5 487384064 sda5 11 0 1048575 sr0 252 0 487382016 dm-0 252 1 19996672 dm-1 252 2 8335360 dm-2 252 3 459046912 dm-3 8 48 1921024 sdd
- In this example, the volume name is mmcblk0 (microSD card is inserted directly with microSD card adapter)
PC $> cat /proc/partitions major minor #blocks name 8 0 488386584 sda 8 1 999424 sda1 8 2 1 sda2 8 5 487384064 sda5 11 0 1048575 sr0 252 0 487382016 dm-0 252 1 19996672 dm-1 252 2 8335360 dm-2 252 3 459046912 dm-3 8 48 1921024 mmcblk0
mmcblk0 can be replaced by: sdX if it's a device dedicated to receive the raw image (where X can be a, b, c, d, e) |
- Before using the command dd, please umount all the partitions associated to microSD card.
PC $> sudo umount `lsblk --list | grep mmcblk0 | grep part | gawk '{ print $7 }' | tr '\n' ' '`
- Populate microSD card with dd command:
PC $> cd build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/stm32mp1/scripts/
PC $> sudo dd if=../flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.raw of=/dev/mmcblk0 bs=8M conv=fdatasync status=progress
The dd command takes few minutes (depending mainly of your rootfs size)
4. Update manually some partitions with dd command[edit | edit source]
Once you have populated your microSD card with the raw file, it is possible to update manually some partitions as explained in txt file.
Example :
PC $> cat flashlayout_st-image-weston_FlashLayout_sdcard_stm32mp157c-ev1-trusted.how_to_update.txt This file describes how to update manually the partition of SDCARD: 1. SDCARD schema of partition 2. How to populate each partition 3. How to update the kernel/devicetree 1. SDCARD schema of partition: ------------------------------ ============================================================================================ = = = = = = = = = fsbl1 = fsbl2 = ssbl = bootfs = vendorfs = rootfs = userfs = = = = = = = = = = mmcblk0p1 = mmcblk0p2 = mmcblk0p3 = mmcblk0p4 = mmcblk0p5 = mmcblk0p6 = mmcblk0p7 = = (1 ) = (2 ) = (3 ) = (4 ) = (5 ) = (6 ) = (7 ) = = = = = = = = = ============================================================================================ (1): Device: /dev/mmcblk0p1 Label: fsbl1 Image: tf-a-stm32mp157c-ev1-trusted.stm32 (2): Device: /dev/mmcblk0p2 Label: fsbl2 Image: tf-a-stm32mp157c-ev1-trusted.stm32 (3): Device: /dev/mmcblk0p3 Label: ssbl Image: u-boot-stm32mp157c-ev1-trusted.stm32 (4): Device: /dev/mmcblk0p4 Label: bootfs Image: st-image-bootfs-openstlinux-weston-stm32mp1.ext4 (5): Device: /dev/mmcblk0p5 Label: vendorfs Image: st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 (6): Device: /dev/mmcblk0p6 Label: rootfs Image: st-image-weston-openstlinux-weston-stm32mp1.ext4 (7): Device: /dev/mmcblk0p7 Label: userfs Image: st-image-userfs-openstlinux-weston-stm32mp1.ext4 2. How to populate each partition --------------------------------- - Populate partition fsbl1 (/dev/mmcblk0p1) dd if=tf-a-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk0p1 bs=1M conv=fdatasync - Populate partition fsbl2 (/dev/mmcblk0p2) dd if=tf-a-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk0p2 bs=1M conv=fdatasync - Populate partition ssbl (/dev/mmcblk0p3) dd if=u-boot-stm32mp157c-ev1-trusted.stm32 of=/dev/mmcblk0p3 bs=1M conv=fdatasync - Populate partition bootfs (/dev/mmcblk0p4) dd if=st-image-bootfs-openstlinux-weston-stm32mp1.ext4 of=/dev/mmcblk0p4 bs=1M conv=fdatasync - Populate partition vendorfs (/dev/mmcblk0p5) dd if=st-image-vendorfs-openstlinux-weston-stm32mp1.ext4 of=/dev/mmcblk0p5 bs=1M conv=fdatasync - Populate partition rootfs (/dev/mmcblk0p6) dd if=st-image-weston-openstlinux-weston-stm32mp1.ext4 of=/dev/mmcblk0p6 bs=1M conv=fdatasync - Populate partition userfs (/dev/mmcblk0p7) dd if=st-image-userfs-openstlinux-weston-stm32mp1.ext4 of=/dev/mmcblk0p7 bs=1M conv=fdatasync 3. How to update the kernel/devicetree -------------------------------------- The kernel and devicetree are present on "bootfs" partition. To change kernel and devicetree, you can copy the file on this partition: - plug SDCARD on your PC - copy kernel uImage on SDCARD sudo cp uImage /media/$USER/bootfs/ - copy devicetree uImage on SDCARD sudo cp stm32mp1*.dtb /media/$USER/bootfs/ - umount partitions of SDCARD sudo umount /media/$USER/bootfs/ (dont't forget to umount the other partitions of SDCARD: sudo umount `lsblk --list | grep mmcblk0 | grep part | gawk '{ print $7 }' | tr '\n' ' '` )