When I want to upload a binary file executable.bin to the STM32F407G device, I connect it to the PC using the mini-USB cable and execute the command

sudo st-flash write executable.bin 0x08000000

Now I want to upload the binary file in a similar way to the NUCLEO-F207ZG device:

enter image description here

but this time sudo st-flash write executable.bin 0x08000000 throws an error

st-flash 1.6.1
2020-07-14T18:42:02 WARN common.c: unknown chip id! 0x374b
Failed to connect to target

What am I doing wrong?

I also installed pyocd command to flash the code. pyocd list returns the following information about the device:

Probe          Unique ID                 
STM32 STLink   066DFF485550755187123543

On the physical device, I see a number F207ZG and one target in the pyocd list --target is stm32f207zg, thus I try to flash the code with the following command:

pyocd flash --target stm32f207zg -0connect_mode=under-reset --base-address 0x08000000 executable.bin

but receive an error:

pyocd.core.exceptions.ProbeError: STLink error (9): Get IDCODE error

What am I doing wrong in this case?

  • \$\begingroup\$ This is very odd.. 0x374b is the USB PID of an ST/LINK V2-1 as found on the Nucleo boards. It is not the target ID for an F2 chip which is what that line from common.c should be printing. Perhaps you have a buggy build which is somehow mixing up the USB ID of the interface with the chip id of the target. Try a another tool such as OpenOCD or PyOCD or even for the moment use the silly drag-and-drop fake mass storage mechanism which the Nucleo boards support. \$\endgroup\$ – Chris Stratton Jul 14 at 19:22
  • \$\begingroup\$ Which USB connectors on the boards are you using? The USB for ST-LINK, or the USB for target MCU? Also, what is st-flash program? Does CubeProg from ST work for you? \$\endgroup\$ – Justme Jul 14 at 19:58
  • \$\begingroup\$ Based on the message, they'd have had to have plugged into the ST/Llink USB connector \$\endgroup\$ – Chris Stratton Jul 14 at 22:15
  • \$\begingroup\$ Just to be on the safe side: you have built the firmware / binary file specifically for the STM32F207ZG and are not trying to upload the binary file built for STM32F407G? \$\endgroup\$ – Codo Jul 15 at 8:48
  • \$\begingroup\$ @Codo for both cases I compile the code using the make CROSS_COMPILE=arm-none-eabi- command. But the problem is that I can't even flash the code to the STM32F207G device, let alone running it. \$\endgroup\$ – mercury0114 Jul 15 at 8:54

Make sure that on the device, ST-LINK pins are connected:

enter image description here

then sudo st-flash write executable.bin 0x08000000 should succeed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.