New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32F0 upload failing #665

Closed
zgoda opened this Issue May 20, 2016 · 15 comments

Comments

Projects
None yet
6 participants
@zgoda

zgoda commented May 20, 2016

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 =============================================
@ivankravets

This comment has been minimized.

Member

ivankravets commented May 20, 2016

Could you copy manually without root permissions?

cp .pioenvs/disco_f051r8/firmware.elf /dev/stlinkv2_6
@zgoda

This comment has been minimized.

zgoda commented May 20, 2016

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

This comment has been minimized.

Member

ivankravets commented May 20, 2016

Do you need any help?

@zgoda

This comment has been minimized.

zgoda commented May 20, 2016

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

@zgoda

This comment has been minimized.

zgoda commented May 20, 2016

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!
@valeros

This comment has been minimized.

Member

valeros commented May 20, 2016

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

@zgoda

This comment has been minimized.

zgoda commented May 20, 2016

Thank you @valeros, this works fine.

@ivankravets

This comment has been minimized.

Member

ivankravets commented May 20, 2016

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

Thanks a lot!

@ivankravets

This comment has been minimized.

Member

ivankravets commented May 20, 2016

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

@valeros valeros modified the milestone: 2.9.2 May 24, 2016

valeros added a commit that referenced this issue May 25, 2016

ivankravets added a commit that referenced this issue May 28, 2016

Merge branch 'develop' into feature/platformio-30
* develop:
  Install tox manually
  Simplified documentation for Continuous integration with AppVeyor // Resolve #671
  Fix broken links to project examples
  Add stlink as the default uploader for disco boards // Issue #665
  Specify supported types of library repository

ivankravets added a commit that referenced this issue Jun 2, 2016

ivankravets added a commit that referenced this issue Jun 2, 2016

Merge branch 'develop' into feature/platformio-30
* develop:
  Version bump to 2.9.2 (issues #641, #645, #648, #652, #664, #665, #666, #671, #674)
  Fix issue with ARM mbed framework when abstract class breaks compile for LPC1768 // Resolve #666
  Fix issue with ARM mbed framework and multiple definition errors   on FRDM-KL46Z board // Resolve #641
  List embedded boards in docs
  Fix multiple definition in mbed framework when using abstract class // Issue #641, #666
  Add "stlink" as the default uploader for STM32 Discovery boards // Resolve #665
  Implement grep serial ports for Windows
  Remove unused imports
  Minor improvements
  Fix PyLint's "misplaced-comparison-constant"
  Use $PROGNAME instead static name when looking for the firmware
  Update title of the article
  Add new articles
  Link Community Forums FAQ with Docs FAQ
  Grep for "/dev/cu.*" on OS X
  Skip grep search for serial ports on Windows machines
  Improve firmware uploading to Arduino Leonardo based boards
  Add MinGW to the PATH

# Conflicts:
#	docs/index.rst
#	docs/platforms/creating_board.rst
#	docs/projectconf.rst
#	docs/userguide/platforms/cmd_install.rst
#	platformio/__init__.py
#	platformio/builder/scripts/atmelavr.py
#	platformio/builder/scripts/atmelsam.py
#	platformio/builder/scripts/frameworks/mbed.py
@bfarayev

This comment has been minimized.

bfarayev commented Jun 28, 2016

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

@ivankravets

This comment has been minimized.

Member

ivankravets commented Jun 28, 2016

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

@bfarayev

This comment has been minimized.

bfarayev commented Jun 28, 2016

@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
@ivankravets

This comment has been minimized.

Member

ivankravets commented Jun 28, 2016

@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.

@TravisJoe

This comment has been minimized.

TravisJoe commented May 3, 2017

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

@Goldenstarc

This comment has been minimized.

Goldenstarc commented Nov 16, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment