# How to flash binary code to the NUCLEO-F207ZG device?

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:

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


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


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


What am I doing wrong in this case?

• 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. – Chris Stratton Jul 14 at 19:22
• 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? – Justme Jul 14 at 19:58
• Based on the message, they'd have had to have plugged into the ST/Llink USB connector – Chris Stratton Jul 14 at 22:15
• 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? – Codo Jul 15 at 8:48
• @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. – mercury0114 Jul 15 at 8:54

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