Skip to content
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

"sh: stm32flash: command not found" after fresh install of PIO #269

Closed
steffentrumpf opened this issue Aug 4, 2019 · 6 comments
Closed
Assignees

Comments

@steffentrumpf
Copy link

steffentrumpf commented Aug 4, 2019

While trying to upload to a "Generic STM32F103C8" via serial I get the following error: "sh: stm32flash: command not found".

It has been working flawlessly before. After messing around with an F4 core, it doesn't work anymore. I tried removing VS code and PIO including, what I think, all background files. After a fresh install I get the same error.

When not having a device plugged in I get the following message:
"Error: Please specify upload_port for environment or use global --upload-port option.
For some development platforms it can be a USB flash drive (i.e. /media//)
*** [upload] Explicit exit, status 1"

I tried a complete reinstall of macOS and it is still not working.

Any Idea why stm32flash is not installed/working?

OS: macOS 10.14.6
PIO Core: 4.0.0
VS code: 1.36.1

@kinosang
Copy link

kinosang commented Aug 6, 2019

Same here

And after install stm32flash via Homebrew, it still not work.

Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = serial
Looking for upload port...
Auto-detected: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/genericSTM32F103C8/firmware.bin
Error probing interface "serial_posix"
stm32flash 0.5
Cannot handle device "cu.SLAB_USBtoUART"

http://stm32flash.sourceforge.net/
Failed to open port: cu.SLAB_USBtoUART

Using Parser : Raw BINARY

*** [upload] Error 1

ref #138

@pfeerick
Copy link

pfeerick commented Aug 8, 2019

Having the same issue on Linux, using the STM32F103C8/B and bluepill_f103c8/_128k board variants. A quick which stm32flash from the VSCode terminal doesn't find executable either, although that may be unrelated. The file is present in /home/pfeerick/.platformio/packages/tool-stm32duino/stm32flash/stm32flash and will execute if run run manually.

Platform ST STM32
--------
Checking ststm32                         @ 5.5.0          [Up-to-date]
Checking toolchain-gccarmnoneeabi        @ 1.70201.0      [Up-to-date]
Checking framework-arduinoststm32-maple  @ 1.10000.190719 [Up-to-date]
Checking tool-stm32duino                 @ 1.0.1          [Up-to-date]
Checking tool-openocd                    @ 2.1000.190422  [Up-to-date]
Checking tool-dfuutil                    @ 1.9.190708     [Up-to-date]

Edit: After copying, /home/pfeerick/.platformio/packages/tool-stm32duino/stm32flash/stm32flash to /home/pfeerick/.platformio/penv (as that directory is in the path), stm32flash was found.

I then ran into #138 as mentioned above... resulting in needing to add /dev/to line 241 of platforms/ststm32/builder/main.py. I'm guessing an update to stm32flash is responsible for that issue.

@steffentrumpf
Copy link
Author

Thanks a lot!
I did the things you mentioned and they worked.

@rmaia3d
Copy link

rmaia3d commented Sep 13, 2019

Having the same issue on Linux, using the STM32F103C8/B and bluepill_f103c8/_128k board variants. A quick which stm32flash from the VSCode terminal doesn't find executable either, although that may be unrelated. The file is present in /home/pfeerick/.platformio/packages/tool-stm32duino/stm32flash/stm32flash and will execute if run run manually.

Platform ST STM32
--------
Checking ststm32                         @ 5.5.0          [Up-to-date]
Checking toolchain-gccarmnoneeabi        @ 1.70201.0      [Up-to-date]
Checking framework-arduinoststm32-maple  @ 1.10000.190719 [Up-to-date]
Checking tool-stm32duino                 @ 1.0.1          [Up-to-date]
Checking tool-openocd                    @ 2.1000.190422  [Up-to-date]
Checking tool-dfuutil                    @ 1.9.190708     [Up-to-date]

Edit: After copying, /home/pfeerick/.platformio/packages/tool-stm32duino/stm32flash/stm32flash to /home/pfeerick/.platformio/penv (as that directory is in the path), stm32flash was found.

I then ran into #138 as mentioned above... resulting in needing to add /dev/to line 241 of platforms/ststm32/builder/main.py. I'm guessing an update to stm32flash is responsible for that issue.

BTW: On macOS 10.14 here.

Confirm having the same issue, and following these steps (including the addition to line 241) could solve it and be able to upload to the board normally. Thanks a lot!

@sanyi
Copy link

sanyi commented Oct 21, 2019

I would add that on linux the error is:

Uploading .pio/build/bluepill_f103c8/firmware.bin
sh: 1: stm32flash: Permission denied
*** [upload] Error 127

somewhat misleading. But replacing UPLOADER to full path and removing the basename trimming of the UPLOAD_PORT works:

elif upload_protocol == "serial":
    env.Replace(
        UPLOADER="/home/atti/.platformio/packages/tool-stm32duino/stm32flash/stm32flash",
        UPLOADERFLAGS=[
            "-g", board.get("upload.offset_address", "0x08000000"),
            "-b", "115200", "-w"
        ],
        UPLOADCMD='$UPLOADER $UPLOADERFLAGS "$SOURCE" "$UPLOAD_PORT"'
    )
....

@valeros
Copy link
Member

valeros commented Oct 22, 2019

Thanks for reporting! Should be fixed in the upstream version:

[env:upstream_develop]
platform = https://github.com/platformio/platform-ststm32.git
board = ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants