flash a ST board with STLINK and Linux

11.9k views Asked by At

I am trying to flash a board of ST (STM32 discovery Kit STM32L072) via the STLINK connector, from a Linux, in command line.

To flash with the STLINK, you just have to copy-past the binary to flash into the USB reader (associated to the STLINK);

For that, with dmesg, I find the /dev/sdx. Then I mount the /dev/sdx:

mkdir /mnt/board
sudo mount /dev/sdx /mnt/board

With a ls command I can read the folder of the ST board:

$ ls /mnt/board/
DETAILS.TXT  MBED.HTM

==> I can read the ST board.

Now I can copy the binary to the ST board. The flash should be automatically done after the copy:

sudo cp mybinarytoflash.bin /mnt/board

We can see the LED of the STLINK blinks, in green. The binary is flashing.

But I have 2 mains problems:

  • Sometimes, after the copy of the binary into the /mnt/board, the flash of the binary to the ST board is not been immediatly. Sometimes we have to wait more of 30 seconds.

  • My second problem, it's that after the flashing, there is not RESET of the ST board. When I do this process with a computer with Windows, the ST board is reseted after the flashing. Do I need to do something with the /dev/sdx or something else?

thank you very much, Guillaume

1

There are 1 answers

2
guitou On

I find a new solution using a tool to drive the STLINK as a probe:

install the STLINK tools with: sudo apt-get install stlink-tools

  • FLASH : sudo st-flash write <file_to_flash>.bin 0x08000000
  • RESET : sudo st-flash reset

This solution works perfectly and the flashing is quick.