Binaries created for Nucleo L432KC with Mbed do not flash successfully

I am trying to use PlatformIO Core on Linux to program my STM32 Nucleo32 L432KC boards, using Mbed. I took the following steps, in order:

  1. Installed PlatformIO using pip (python2.7) on Ubuntu 16.04.
  2. Created new directory, cd’d into it, and ran platformio --init --board nucleo_l432kc; command completed without errors.
  3. Copied a simple LED blinker program from my Mbed account, which I have previously downloaded and run successfully using their online compiler, and placed it in the ./src directory under the name “main.cpp”.
  4. Ran platformio run; command downloaded required Mbed libraries, compiled, and completed without errors.
  5. Plugged in my Nucleo L432KC board to my computer using a USB cable, and mounted it using my system’s GUI auto-mounter (creating a directory named NODE_L432KC under /media/username)
  6. Ran platformio run --target upload; command downloaded tools-stm32duino and tools-stlink, and completed without errors, declaring that the firmware had been successfully uploaded. A firmware.bin file appeared in the mounted NODE_L432KC directory.

Expected results:
The programmer/debugger status light on the Nucleo board should flash between red and green as the MCU is programmed, and the code should begin running and cause the user LED (LD3) to flash regularly.

Actual results:
The programmer/debugger status light did not respond in any way, and remained solid red (indicating active but idle USB connection). The code compiled by PlatformIO did not begin running on the board, which continued to run the code I had previously installed on it using Mbed’s online compiler, both immediately and after being reset multiple times (I verified this by opening a serial terminal on /dev/ttyACM0 and seeing debugging output from the previous program each time the board was reset).

As far as I can tell, PlatformIO successfully downloads the required libraries, compiles my simple LED blinker program, and transfers the firmware.bin file to the board’s STLink over the USB mass storage interface, but after that, nothing happens. As far as I can tell, this is consistent with the behavior of the STLink upon receiving invalid firmware; I tested uploading a randomly-generated binary file and saw the same result.
The board consistently works fine (e.g. promptly accepts and runs code) when given firmware compiled by Mbed’s online compiler, or compiled locally using a Makefile and gcc in an exported Mbed project. However, I have had no success with giving it code produced by PlatformIO, which is consistently not flashed by the programmer when uploaded.

I am confused as to how PlatformIO could be producing totally invalid code, and can only conclude that I missed an important step in the basic setup procedures, but I also have had no luck figuring out what step that would be. Any help would be greatly appreciated.

Could you try manually drag&drop firmware to that mbed disk? The firmware is located in cd’d into it/.pioenvs/nucleo_l432kc/firmware.bin. Does it work?

Copying the firmware manually produces the same result. The file is transferred to the STLink, but the STLink does not flash the firmware to the MCU or apparently respond in any way.

Please file an issue here Issues · platformio/platform-ststm32 · GitHub.
Our embedded engineers will help you.