Booting Linux from SD Card Print

 

Use the procedure documented below to install the U-Boot firmware, Linux kernel and filesystem images to an SD Card the STM32MP1 module will be bootable from. Having completed the installation, the STM32MP1 SOM will boot to Linux from the SD Card on next reset / power on.

Please note that the installation will erase files previously installed on your SD Card. The SD card size should be at least 2GB for the Linux kernel and filesystem images to fit on the card.

Here is the procedure:

  1. Insert SD card to the board.
  2. Follow the instructions in the Section 5 of https://wiki.st.com/stm32mpu/wiki/STM32MP15_Discovery_kits_-_Starter_Package#Installing_the_STM32CubeProgrammer_tool to install the STM32CubeProgrammer Tool to your host.
  3. Add STM32_Programmer_CLI to your PATH:
  4. $ export PATH=$PATH:/bin: $ STM32_Programmer_CLI [psl@sergmir programmer]$ STM32_Programmer_CLI ------------------------------------------------------------------- STM32CubeProgrammer v2.7.0 ------------------------------------------------------------------- Usage : STM32_Programmer_CLI.exe [command_1] [Arguments_1][[command_2] [Arguments_2]...] ...

  5. Power off the board and select the USB Serial Downloader mode (see in Selecting Boot Device).
  6. Check that the programming USB port appeared on the host (note the "Device Index" in the output):
  7. ------------------------------------------------------------------- STM32CubeProgrammer v2.7.0 ------------------------------------------------------------------- ===== DFU Interface ===== Total number of available STM32 device in DFU mode: 1 Device Index : USB1 USB Bus Number : 001 USB Address Number : 004 Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID
    /0x0000 Serial number : 003000193338511534383330 Firmware version : 0x0110 Device ID : 0x0500

  8. Download the Emcraft release images from Emcraft site and unpack them into the arbitrary directory. (If you are installing the images built by Yocto, navigate to builddir/tmp-glibc/deploy/images/stm32mp1-som directory):
  9. $ ls -l total 203344 -rw-rw-r-- 1 psl psl 208217109 Apr 27 13:52 images-stm32mp1-3.0.0.tar.bz2 $ tar xfj images-stm32mp1-3.0.0.tar.bz2 $ ls -l total 961696 drwxr-xr-x 3 psl psl 4096 Apr 16 21:53 arm-trusted-firmware drwxr-xr-x 2 psl psl 4096 Apr 16 20:55 bootloader -rw-r--r-- 1 psl psl 558419968 Apr 20 20:59 emcraft-rootfs-openstlinux- weston-stm32mp1-som.ext4 drwxrwxr-x 4 psl psl 4096 Apr 27 14:49 flashlayout_emcraft-rootfs -rw-rw-r-- 1 psl psl 208217109 Apr 27 13:52 images-stm32mp1-3.0.0.tar.bz2 drwxr-xr-x 2 psl psl 4096 Mar 8 20:46 scripts -rw-r--r-- 1 psl psl 67108864 Apr 20 20:57 st-image-bootfs-openstlinux- weston-stm32mp1-som.ext4 -rw-r--r-- 1 psl psl 134217728 Apr 20 18:31 st-image-userfs-openstlinux- weston-stm32mp1-som.ext4 -rw-r--r-- 1 psl psl 16777216 Apr 20 18:31 st-image-vendorfs-openstlinux- weston-stm32mp1-som.ext4 $

  10. Use the SD card Flash Layout file for programming the images to SD card:
  11. [psl@sergmir 3.0.0]$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_ emcraft-rootfs/trusted/FlashLayout_sdcard_stm32mp1-som-trusted.tsv ------------------------------------------------------------------- STM32CubeProgrammer v2.7.0 ------------------------------------------------------------------- USB speed : High Speed (480MBit/s) Manuf. ID : STMicroelectronics Product ID : DFU in HS Mode @Device ID /0x500, @Revision ID
    /0x0000 SN : 003000193338511534383330 FW version : 0x0110 Device ID : 0x0500 Device name : STM32MP1 Device type : MPU Device CPU : Cortex-A7 Start Embedded Flashing service Memory Programming ... Opening and parsing file: tf-a-stm32mp1-som-serialboot.stm32 File : tf-a-stm32mp1-som-serialboot.stm32 Size : 237896 Bytes Partition ID : 0x01 Download in Progress: [==================================================] 100% File download complete Time elapsed during download operation: 00:00:00.777 RUNNING Program ... PartID: :0x01 Start operation done successfully at partition 0x01 Flashlayout Programming ... [==================================================] 100% Running Flashlayout Partition ... Flashlayout partition started successfully Memory Programming ... Opening and parsing file: u-boot-stm32mp1-som-trusted.stm32 File : u-boot-stm32mp1-som-trusted.stm32 Size : 663332 Bytes Partition ID : 0x03 Download in Progress: [==================================================] 100% File download complete Time elapsed during download operation: 00:00:00.418 ... Download in Progress: [==================================================] 100% File download complete Time elapsed during download operation: 00:00:51.346 RUNNING Program ... PartID: :0x24 Start operation done successfully at partition 0x24 Flashing service completed successfully $

  12. Power off the board.
  13. Set S4 for booting from SD Card.
  14. Connect with a wire JP3.1 and JP2 (any pin) on the baseboard. This will provide initial 3.3V power to SD Card.
  15. Apply the power and check the system boots from SD card:
  16. NOTICE: CPU: STM32MP157AAA Rev.B NOTICE: Model: Emcraft STM32MP157 SOM rev 1A, https://emcraft.com INFO: Reset reason (0x15): INFO: Power-on Reset (rst_por) INFO: Using SDMMC INFO: Instance 1 INFO: Boot used partition fsbl1 NOTICE: BL2: v2.2-r2.0(debug):v2.2-stm32mp-r2-2-g7aca41fc2 NOTICE: BL2: Built : 18:25:18, Mar 31 2021 ...

  17. Alternatively, a bootable SD card could be prepared on the host:
    • In the images directory, run the command below:
    • $ ./scripts/create_sdcard_from_flashlayout.sh flashlayout_emcraft- rootfs/trusted/FlashLayout_sdcard_stm32mp1-som-trusted.tsv Create Raw empty image: flashlayout_emcraft-rootfs/trusted/../../ FlashLayout_sdcard_ stm32mp1-som-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.0 MiB] [CREATED] part 4: boot [partition size 64.0 MiB] [CREATED] part 5: vendorfs [partition size 16.0 MiB] [CREATED] part 6: rootfs [partition size sectors, 746.0 1.5 MiB] [CREATED] part 7: userfs [partition size 707.5 MiB] Partition table from flashlayout_emcraft-rootfs/trusted/../../ FlashLayout_sdcard_stm32mp1-som-trusted.raw Populate raw image with image content: [ FILLED ] part 1: fsbl1, image: arm-trusted-firmware/tf- a-stm32mp1-som-trusted.stm32 [ FILLED ] part 2: fsbl2, image: arm-trusted-firmware/tf- a-stm32mp1-som-trusted.stm32 [ FILLED ] part 3: ssbl, image: bootloader/u-boot-stm32mp1 -som-trusted.stm32 [ FILLED ] part 4: boot, image: st-image-bootfs-openstlinux- weston-stm32mp1-som.ext4 [ FILLED ] part 5: vendorfs, image: st-image-vendorfs-openstlinux -weston-stm32mp1-som.ext4 [ FILLED ] part 6: rootfs, image: emcraft-rootfs-openstlinux- weston-stm32mp1-som.ext4 [ FILLED ] part 7: userfs, image: st-image-userfs-openstlinux- weston-stm32mp1-som.ext4 ################################################################## ################################################################## RAW IMAGE generated: flashlayout_emcraft-rootfs/trusted/../../ FlashLayout_sdcard_stm32mp1-som-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_emcraft-rootfs/trusted/../../FlashLayout_ sdcard_stm32mp1-som-trusted.raw of=/dev/mmcblk0 bs=8M conv=fdatasync status=progress (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) ################################################################ ################################################################ [psl@sergmir 3.0.0]$

    • Insert SD card to the host and the run command above to program:
    • $ sudo dd if=flashlayout_emcraft-rootfs/trusted/../../FlashLayout_ sdcard_stm32mp1-som-trusted.raw of=/dev/ bs=8M conv= fdatasync status=progress ...