The only difference between the platformio and arduino ide avrdude command is the missing -D option.
Is there a reason platformio is disabling auto erase for flash memory by adding -D to the avrdude command?
Second strange thing is:
After executing the avrdude command without -D manually, uploads with PlatformIO work again.
So it seems it only works if the last upload is not done by Arduino IDE. Does this make any sense?
[env:uno_prog]
platform = https://github.com/platformio/platform-atmelavr.git
board = uno
framework = arduino
upload_protocol = stk500v2
upload_flags = -Pusb
upload_port = usb
Tried compiling, but it gave me this error:
Submodule 'examples/arduino-external-libs/lib/OneWire' (https://github.com/PaulStoffregen/OneWire.git) registered for path 'examples/arduino-external-libs/lib/OneWire'
Cloning into 'C:/Users/michi/.platformio/platforms/_tmp_installing-r1k8sb-package/examples/arduino-external-libs/lib/OneWire'...
error: no such remote ref b1ef6b994fe005aec9e6b23e05010ce88a93fac3
Fetched in submodule path 'examples/arduino-external-libs/lib/OneWire', but it did not contain b1ef6b994fe005aec9e6b23e05010ce88a93fac3. Direct fetching of that commit failed.
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/platformio/platform-atmelavr.git', 'C:\\Users\\michi\\.platformio\\platforms\\_tmp_installing-r1k8sb-package']
Not sure how this can be resolved since i never used submodules yet.
Manually checking them out with:
git clone https://github.com/platformio/platform-atmelavr.git
cd platform-atmelavr
git submodule update --init --recursive
works thought. Also git clone --recursive https://github.com/platformio/platform-atmelavr.git without --depth 1 checks out both the main repo and submodule successfully.
Edit:
This seemed to be a git issue. Updating git resolved that issue.
Still i am not able to resolve my initial issue.
Things i have done:
updated my ini platform to develop
removed .platformio/platforms/atmelavr
runnning pio platform update
pio run -e uno_prog --target upload -v still results in avrdude -v -p atmega328p -C /home/michi/.platformio/packages/tool-avrdude/avrdude.conf -c stk500v2 usb -Pusb -D -U flash:w:.pioenvs/uno_prog/firmware.hex:i. -D is still there.
Configuring upload protocol...
Available: stk500v2
Configured: upload_protocol = stk500v2
BeforeUpload(["upload"], [".pioenvs/uno_prog/firmware.hex"])
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/<user>/<device name>)
*** [upload] Explicit exit, status 1
Adding a upload_port = usb results in this error:
Configuring upload protocol...
Available: stk500v2
Configured: upload_protocol = stk500v2
BeforeUpload(["upload"], [".pioenvs/uno_prog/firmware.hex"])
Use manually specified: usb
*** [upload] could not open port usb: [Errno 2] No such file or directory: 'usb'
I am able to workaround that issue by adding usb to upload_protocol leading to my final solution
[env:uno_prog]
platform = https://github.com/platformio/platform-atmelavr.git
board = uno
framework = arduino
; http://docs.platformio.org/en/latest/platforms/atmelavr.html?highlight=mkii#upload-using-programmer
upload_protocol = stk500v2 usb
upload_flags = -Pusb
This is acually a workaround, so that the if in this builder.py-L38 line gets triggered.