Problem with workspace_dir

Hello and congratulation to 4.0!

I’ve a small problem:

If i use “workspace_dir” in combination with “upload_protocol = dfu” and “upload_port = anything”
platformio 4.0.0 concatenates the working directory with the “workspace_dir” when try to upload the binary.

Example:

working directory:
“/Users/user/Documents/PlatformIO/Projects/190711-160535-arduino-blink” and
“workspace_dir = /tmp/pio-build/$PROJECT_HASH”

creates:

“/Users/user/Documents/PlatformIO/Projects/190711-160535-arduino-blink//private/tmp/pio-build/190711-160535-arduino-blink-6ada3aa29f/build/bluepill_f103c8_128k/firmware.bin”

which should be only the last part:

“/private/tmp/pio-build/190711-160535-arduino-blink-6ada3aa29f/build/bluepill_f103c8_128k/firmware.bin”

This does not happen when i remove “workspace_dir = …”

To reproduce open stm32-arduino-blink example,
set platformio.ini to:

[platformio]
workspace_dir = /tmp/pio-build/$PROJECT_HASH

[env:bluepill_f103c8_128k]
platform = ststm32
framework = arduino
board = bluepill_f103c8_128k
upload_protocol = dfu
upload_port = anything

run “pio run -t upload”

I use the same configuration every day! :slight_smile:
However, workspace directory is set as environment variable

PLATFORMIO_WORKSPACE_DIR=/tmp/pio-workspaces/$PROJECT_HASH

I’ll re-test your case. Thanks!

Sorry, I can’t reproduce this issue. See

[platformio]
workspace_dir = /tmp/robert-walli/$PROJECT_HASH

[env:uno]
platform = atmelavr
framework = arduino
board = uno

------

Indexing /private/tmp/robert-walli/wiring-blink-0bc8cae264/build/uno/libFrameworkArduino.a
Linking /private/tmp/robert-walli/wiring-blink-0bc8cae264/build/uno/firmware.elf
Checking size /private/tmp/robert-walli/wiring-blink-0bc8cae264/build/uno/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   0.4% (used 9 bytes from 2048 bytes)
PROGRAM: [          ]   2.9% (used 930 bytes from 32256 bytes)
Building /private/tmp/robert-walli/wiring-blink-0bc8cae264/build/uno/firmware.hex

As mentioned in the first lines it only happens when I use:

upload_protocol = dfu
upload_port = anything

No matter if workspace_dir is in platformio.ini or in environment variable.
Did you test with my platformio.ini

I had to add -v to that to get it to show up… without that, it doesn’t show the concatonated path. I just used your platformio.io against an empty project, on a Ubuntu VM. I got exactly the same behaviour on Windows also.

ubuntu: pio run -t upload
Processing bluepill_f103c8_128k (platform: ststm32; board: bluepill_f103c8_128k; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8_128k.html
PLATFORM: ST STM32 5.4.3 > BluePill F103C8 (128k)
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 128KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: tool-stm32duino 1.0.1, framework-arduinoststm32 3.10500.190327 (1.5.0), toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), tool-openocd 2.1000.190422 (10.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
No dependencies
Checking size /tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   4.5% (used 912 bytes from 20480 bytes)
PROGRAM: [=         ]   8.3% (used 10916 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, dfu, jlink, stlink
CURRENT: upload_protocol = dfu
Looking for upload port...
Use manually specified: anything
Uploading /tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.bin
/home/pfeerick/.platformio/packages/tool-stm32duino/maple_upload: line 29: /home/pfeerick/.platformio/packages/tool-stm32duino/upload-reset: No such file or directory
No DFU capable USB device found
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1eaf product = 0x0003
Waiting for /dev/anything serial...Done
======================================================== [SUCCESS] Took 6.97 seconds ========================================================

vs

ubuntu: pio run -t upload -v
Processing bluepill_f103c8_128k (upload_protocol: dfu; platform: ststm32; upload_port: anything; board: bluepill_f103c8_128k; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8_128k.html
PLATFORM: ST STM32 5.4.3 > BluePill F103C8 (128k)
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 128KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: tool-stm32duino 1.0.1, framework-arduinoststm32 3.10500.190327 (1.5.0), toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), tool-openocd 2.1000.190422 (10.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
No dependencies
MethodWrapper(["checkprogsize"], ["/tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.elf"])
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   4.5% (used 912 bytes from 20480 bytes)
PROGRAM: [=         ]   8.3% (used 10916 bytes from 131072 bytes)
/tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.elf  :
section              size        addr
.isr_vector           268   134217728
.text               10088   134217996
.rodata               792   134228084
.init_array            16   134228876
.fini_array             4   134228892
.data                  36   536870912
.bss                  876   536870948
._user_heap_stack    1536   536871824
.ARM.attributes        41           0
.comment              126           0
.debug_frame          116           0
Total               13899
<lambda>(["upload"], ["/tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.bin"])
AVAILABLE: blackmagic, dfu, jlink, stlink
CURRENT: upload_protocol = dfu
MethodWrapper(["upload"], ["/tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.bin"])
Use manually specified: anything
maple_upload anything 2 1EAF:0003 "/home/pfeerick/Documents/PlatformIO/Projects/arduino-blink//tmp/pio-build/arduino-blink-ac05cfc543/build/bluepill_f103c8_128k/firmware.bin"
/home/pfeerick/.platformio/packages/tool-stm32duino/maple_upload: line 29: /home/pfeerick/.platformio/packages/tool-stm32duino/upload-reset: No such file or directory
No DFU capable USB device found
dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x1eaf product = 0x0003
Waiting for /dev/anything serial...Done
======================================================== [SUCCESS] Took 7.23 seconds ========================================================

On Windows, with a suitable workspace_dir path

[platformio]
workspace_dir = D:/Temp/pio-build/$PROJECT_HASH
windows: pio run -t upload -v
> Executing task: C:\platformio\stable\Scripts\platformio.exe run --verbose --target upload --environment bluepill_f103c8_128k <

Processing bluepill_f103c8_128k (upload_protocol: dfu; platform: ststm32; upload_port: anything; board: bluepill_f103c8_128k; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------- 
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8_128k.html
PLATFORM: ST STM32 5.4.3 > BluePill F103C8 (128k)
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 128KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES: tool-stm32duino 1.0.1, framework-arduinoststm32 3.10500.190327 (1.5.0), toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), tool-openocd 2.1000.190422 (10.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
No dependencies
MethodWrapper(["checkprogsize"], ["D:\Temp\pio-build\blinky-889dfa309b\build\bluepill_f103c8_128k\firmware.elf"])
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   4.5% (used 912 bytes from 20480 bytes)
PROGRAM: [=         ]   8.3% (used 10916 bytes from 131072 bytes)
D:\Temp\pio-build\blinky-889dfa309b\build\bluepill_f103c8_128k\firmware.elf  :
section              size        addr
.isr_vector           268   134217728
.text               10088   134217996
.rodata               792   134228084
.init_array            16   134228876
.fini_array             4   134228892
.data                  36   536870912
.bss                  876   536870948
._user_heap_stack    1536   536871824
.ARM.attributes        41           0
.comment              126           0
.debug_frame          116           0
Total               13899
<lambda>(["upload"], ["D:\Temp\pio-build\blinky-889dfa309b\build\bluepill_f103c8_128k\firmware.bin"])
AVAILABLE: blackmagic, dfu, jlink, stlink
CURRENT: upload_protocol = dfu
MethodWrapper(["upload"], ["D:\Temp\pio-build\blinky-889dfa309b\build\bluepill_f103c8_128k\firmware.bin"])
Use manually specified: anything
maple_upload anything 2 1EAF:0003 "c:\Users\Peter\Documents\PlatformIO\Projects\forum\blinky/D:\Temp\pio-build\blinky-889dfa309b\build\bluepill_f103c8_128k\firmware.bin"
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
Reset via USB Serial Failed! Did you select the right serial port?
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

dCfu-util - (C) 2007-2008 by OpenMoko Inc.
ouldn't find the DFU device: [1EAF:0003]
This program is Free Software and has ABSOLUTELY NO WARRANTY


timeout waiting for anything serial
=============================================================== [SUCCESS] Took 38.58 seconds ===============================================================

Is it this line that’s the culprit?

1 Like

@pfeerick wow! Great research! :blush:

@Robert_Walli could you report this issue to Issues · platformio/platform-ststm32 · GitHub?