2

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

guitou
  • 121
  • 2
  • 7
  • Maybe you have to use the command `sync` to tell Linux to immediately write all files to the drives instead of keeping them in internal buffers. – Martin Rosenau Jul 21 '20 at 10:43
  • it is not a programming question. – 0___________ Jul 21 '20 at 20:55
  • Hi P__J__. Maybe it's not a pure programming question, but maybe my way to copy the binary to the the USB driver (STLINK) is not perfect, and there is a method to do a better copy. With Windows it works very well. With Linux and my method it doesn't work perfectly. – guitou Jul 23 '20 at 19:39

1 Answers1

6

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.

guitou
  • 121
  • 2
  • 7