STM32CubeProgrammer

Installing STM32CubeProgrammer [1]

Tip

The CubeProgrammer is just one (slow) way to flash our STM32 based modules. Since kirkstone release version you can also use UUU - Universal Update Utility (fastboot protocol) to flash a module.

Of cousre you first have to update the bootloader with CubeProgrammer to latest version, for our patched fastboot support enabled.

For more read Fastboot Support.

STM32CubeProgrammer requires 1.8 version of the Java platform.

sudo apt install openjdk-8-jre
sudo update-alternatives --config java

Select the java-8-openjdk configuration.

Create a directory on your computer:

mkdir $HOME/STM32MPU_workspace/STM32MPU-Tools
mkdir $HOME/STM32MPU_workspace/STM32MPU-Tools/STM32CubeProgrammer-2.4.0

Download the STM32CubeProgrammer v2.4.0 to your computer.

Uncompress the archive file to get the STM32CubeProgrammer installers:

unzip SetupSTM32CubeProgrammer.zip

Execute the Linux installer, which guides you through the installation process. Select “$HOME/STM32MPU-Tools/STM32CubeProgrammer-2.4.0” as the installation directory, when it’s requested by the installer.

./SetupSTM32CubeProgrammer-2.4.0.linux

Add the STM32CubeProgrammer binary path to your PATH environment variable. So append the ~/.bashrc with:

export PATH=$HOME/STM32MPU_workspace/STM32MPU-Tools/STM32CubeProgrammer-2.4.0/bin:$PATH

After this re-source ~/.bashrc:

source ~/.bashrc

Check that the STM32CubeProgrammer tool is properly installed and accessible:

STM32_Programmer_CLI --h
-------------------------------------------------------------------
                  STM32CubeProgrammer v2.4.0
-------------------------------------------------------------------

Flash the eMMC

  1. Enable the bootmode on your Development Kit. If you need help see Enabling USB-Bootmode.
  2. Plug-in the Development Kit to power it up.
  3. Press the reset button.
  4. Go to the directory where your Images have been deployed to, or you downloaded our precompiled images to.

The following directory is an example, in this case its from a Yocto deploy.

cd $HOME/yocto/karo-bsp/tmp/deploy/images/<machine-name>
  1. Get the device port location for the USB link.
STM32_Programmer_CLI -l usb
-------------------------------------------------------------------
                  STM32CubeProgrammer v2.4.0
-------------------------------------------------------------------

=====  DFU Interface   =====

Total number of available STM32 device in DFU mode: 1

Device Index           : USB1 <--- see this
USB Bus Number         : 001
USB Address Number     : 005
Product ID             : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
Serial number          : 0042001E3438511438333630
Firmware version       : 0x0110
Device ID              : 0x0500
  1. Program the eMMC with the images in flashlayout_<image-name>/ folder.
STM32_Programmer_CLI -c port=usb1 -w flashlayout_karo-image-weston/FlashLayout_emmc_stm32mp157c-qsmp-1570-basic.tsv

Tip

After the setup has run you can disable bootmode and reset your board. You eventually have to fit your u-boot environment to let the image boot. See below.

Note

The .tsv flashlayout documentation is available at https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer_flashlayout

[1]From https://wiki.st.com/stm32mpu/index.php/Getting_started/STM32MP1_boards/STM32MP157C-DK2/Let%27s_start/Populate_the_target_and_boot_the_image

U-Boot Environment

Since we are not able to program the U-Boot environment with the STM32_Programmer_CLI, you will have to change it to boot your module.

With UUU - Universal Update Utility you can do this via the script, and can ignore further steps.

  1. Resetting the environment to default.
env default -a
saveenv
  1. Resetting the board to get the uuid of the RootFS automatically loaded.
reset

Break into U-Boot prompt again by hitting any key.

  1. Set correct init for systemd images:
setenv append_bootargs init=/sbin/init
saveenv
  1. Boot the module:
boot

Fastboot Support

Flashing to eMMC is done via Fastboot protocol using UUU.

If you are not familiar with UUU follow UUU - Universal Update Utility.

Hint

For flashing STM32MP1 boards with UUU it’s not necessary to put the board into Serial Download Bootmode. You have to start fastboot from U-Boot by hand.

Yocto generated images and our precompiled images contain the uuu.auto script.

When UUU is installed on your host and ready to use, simply run:

cd <image-directory>
uuu -v

Now enter the U-Boot prompt on your target via serial terminal and type:

fastboot usb 0

Now UUU partitions your board and flashes the filesystem.

Tip

After flashing with UUU has finished, the desired Linux image will boot.