Platformio-core: STM32F0 upload failing

Created on 20 May 2016  ยท  15Comments  ยท  Source: platformio/platformio-core

Solution

Please add to platformio.ini

[env:myenv]
board = ...
upload_protocol = stlink

$ pio run --target upload
[Fri May 20 12:05:58 2016] Processing disco_f051r8 (platform: ststm32, board: disco_f051r8, framework: mbed)
------------------------------------------------------------------------------------------------------------------------
MethodWrapper(["upload"], [".pioenvs/disco_f051r8/firmware.bin"])
scons: *** [upload] Explicit exit, status Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms this can be a USB flash drive (i.e. /media/<user>/<device name>)

Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms this can be a USB flash drive (i.e. /media/<user>/<device name>)

Port is /dev/stlinkv2_6 so let's follow advice in another approach:

$ pio run --target upload --upload-port /dev/stlinkv2_6 
.clang_complete  .gitignore       .pioenvs/        src/             
.gcc-flags.json  lib/             platformio.ini   .travis.yml      
jazg@JAZG-LENOVO:~/work/stm32_test $ pio run --target upload --upload-port /dev/stlinkv2_6 
[Fri May 20 12:06:22 2016] Processing disco_f051r8 (platform: ststm32, board: disco_f051r8, framework: mbed)
------------------------------------------------------------------------------------------------------------------------
MethodWrapper(["upload"], [".pioenvs/disco_f051r8/firmware.bin"])
scons: *** [upload] /dev/stlinkv2_6/firmware.bin: Not a directory

Port is accessible, of course:

$ ls -la /dev/stlinkv2_6 
lrwxrwxrwx 1 root root 15 maj 20 11:53 /dev/stlinkv2_6 -> bus/usb/003/003

Code builds without problems:

$ pio run
[Fri May 20 12:13:34 2016] Processing disco_f051r8 (platform: ststm32, board: disco_f051r8, framework: mbed)
------------------------------------------------------------------------------------------------------------------------
arm-none-eabi-g++ -o .pioenvs/disco_f051r8/src/main.o 

[ ... skipped for brevity ... ]

"arm-none-eabi-size" -B -d .pioenvs/disco_f051r8/firmware.elf
arm-none-eabi-objcopy -O binary .pioenvs/disco_f051r8/firmware.elf .pioenvs/disco_f051r8/firmware.bin
text       data     bss     dec     hex filename
12988       124     548   13660    355c .pioenvs/disco_f051r8/firmware.elf
============================================= [SUCCESS] Took 0.91 seconds =============================================
enhancement

Most helpful comment

Hi @zgoda
Looks like your kit only supports uploading over STlink.
Could you try upload_protocol = stlink option in your platformio.ini?

All 15 comments

Could you copy manually without root permissions?

cp .pioenvs/disco_f051r8/firmware.elf /dev/stlinkv2_6
$ LANG=C cp .pioenvs/disco_f051r8/firmware.elf /dev/stlinkv2_6
cp: error writing '/dev/stlinkv2_6': Invalid argument

Do you need any help?

I'd like to know where is the problem - my board, my environment or PlatformIO components. I can replace board if it's not supported or I can try to fix my environment.

This is this exact kit

Texane stlink tool works fine:

$ st-flash write .pioenvs/disco_f051r8/firmware.bin 0x8000000
2016-05-20T12:46:00 INFO src/common.c: Loading device parameters....
2016-05-20T12:46:00 INFO src/common.c: Device connected is: F0 device, id 0x20006440
2016-05-20T12:46:00 INFO src/common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
2016-05-20T12:46:00 INFO src/common.c: Attempting to write 13112 (0x3338) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08003000 erased
2016-05-20T12:46:00 INFO src/common.c: Finished erasing 13 pages of 1024 (0x400) bytes
2016-05-20T12:46:00 INFO src/common.c: Starting Flash write for VL/F0/F3 core id
2016-05-20T12:46:00 INFO src/common.c: Successfully loaded flash loader in sram
 12/12 pages written
2016-05-20T12:46:01 INFO src/common.c: Starting verification of write complete
2016-05-20T12:46:01 INFO src/common.c: Flash written and verified! jolly good!

Hi @zgoda
Looks like your kit only supports uploading over STlink.
Could you try upload_protocol = stlink option in your platformio.ini?

Thank you @valeros, this works fine.

@zgoda Please give PlatformIO repository a star โญ https://github.com/platformio/platformio/stargazers

Thanks a lot!

@valeros please specify stlink upload protocol for the boards without ARM mbed bootloader.

Thanks @valeros Adding upload_protocol = stlink to platform.ini solved the issue for me. I was using STM32F411 board with stlink.

@bfarayev it should work automatically since 2.9.2 release. What is your PlatformIO CLI version? Could you share here your platformio.ini?

@ivankravets well, I'm using 2.10.3. My platform.ini file was like this:

[env:nucleo_f411re]
platform = ststm32
framework = mbed
board = nucleo_f411re

I was suspecting if it's because I created this project long before. However, I initialized a new one and again, platform.ini file looks similar:

[env:disco_f407vg]
platform = ststm32
framework = mbed
board = disco_f407vg

@bfarayev Thanks, I got you now. The stlink protocol is set by default only for the disco_* boards where the mbed disk is used for nucleo_*.

In this case, you need manually force the upload_protocol as you do it.

This should probably be done on the Nucleo boards as well. Just ran into the same issue.

Texane stlink tool works fine:

$ st-flash write .pioenvs/disco_f051r8/firmware.bin 0x8000000
2016-05-20T12:46:00 INFO src/common.c: Loading device parameters....
2016-05-20T12:46:00 INFO src/common.c: Device connected is: F0 device, id 0x20006440
2016-05-20T12:46:00 INFO src/common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
2016-05-20T12:46:00 INFO src/common.c: Attempting to write 13112 (0x3338) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08003000 erased
2016-05-20T12:46:00 INFO src/common.c: Finished erasing 13 pages of 1024 (0x400) bytes
2016-05-20T12:46:00 INFO src/common.c: Starting Flash write for VL/F0/F3 core id
2016-05-20T12:46:00 INFO src/common.c: Successfully loaded flash loader in sram
 12/12 pages written
2016-05-20T12:46:01 INFO src/common.c: Starting verification of write complete
2016-05-20T12:46:01 INFO src/common.c: Flash written and verified! jolly good!

can you say that whats exactly in you ini file ?
I hace to save firmware.bin somewhere and flash it using st-flash in another terminal

Was this page helpful?
0 / 5 - 0 ratings

Related issues

424778940z picture 424778940z  ยท  5Comments

radut picture radut  ยท  5Comments

weberw picture weberw  ยท  4Comments

Navis-Raven picture Navis-Raven  ยท  3Comments

shiohiyoko picture shiohiyoko  ยท  3Comments