platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
138 stars 105 forks source link

upload_protocol inconsistency in behaviour depending on board #173

Open pfeerick opened 4 years ago

pfeerick commented 4 years ago

Depending on what board you use, it seems platformio's logic expects upload_port to be set, and be a port it can access (on linux, at least).

i.e. With the following, the uno env will insist on upload_port being set, but the attiny85 env won't. If upload_port = custom is set for the uno, it will fail with ** [upload] could not open port custom: [Errno 2] No such file or directory: 'custom' but the attiny85 env will ignore it completely.

[env:uno]
platform = atmelavr
board = uno
framework = arduino
upload_protocol = stk500v2
upload_flags = -Pusb
;upload_port = custom

[env:attiny85]
platform = atmelavr
board = attiny85
framework = arduino
upload_protocol = stk500v2
upload_flags = -Pusb
theamk commented 1 year ago

I knew that attiny84 works fine, while attiny2313 had the problem, so I checked what the difference:

diff -u ~/.platformio/platforms/atmelavr/boards/{attiny84,attiny2313}.json

This showed a bunch of changes, but one was most promising: + "require_upload_port": true

And indeed, I've added this to my platformio.ini and things now work:

board_upload.require_upload_port = False

Agree that board definition could be fixed, but this workaround is pretty simple