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

Users can't upload to Uno WiFi Rev2 because of argument escaping problem #33

Closed
maxgerhardt opened this issue Nov 12, 2021 · 3 comments
Closed

Comments

@maxgerhardt
Copy link
Contributor

maxgerhardt commented Nov 12, 2021

Initially reported in the community forum.

With the platformio.ini

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino

Users with a space in their name experience a failure in uploading.

<lambda>(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
BeforeUpload(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
avrdude -v -p atmega4809 -C "C:\Users\Wong Zhi Wei\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c xplainedmini_updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x02:m -Ulock:w:0xC5:m "-Uflash:w:"C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i" -b 115200 -V -e -D -P usb -U flash:w:.pio\build\uno_wifi_rev2\firmware.hex:i
avrdude: invalid file format '\Users\Wong' in update specifier
avrdude: error parsing update operation 'flash:w:C:\Users\Wong'
*** [upload] Error 1

The problem looks to me like there's a double-qupting of the flashing argument for the bootloader

"-Uflash:w:"C:\Users\Wong Zhi Wei.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i"

Per this the argument should have been just

-Uflash:w:"C:\Users\Wong Zhi Wei.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i

I however don't see where those quotes for the complete command get added..

if board == "uno_wifi_rev2":
# uno_wifi_rev2 requires bootloader to be uploaded in any case
env.SConscript("bootloader.py", exports="env")
env.Append(UPLOADERFLAGS=env["FUSESFLAGS"])
env.Append(UPLOADERFLAGS=env["BOOTFLAGS"])

BOOTFLAGS=['-Uflash:w:"%s":i' % bootloader_path],

only add quotes for the bootloader path, which is correct. There must be some auto-escaping that is not in the platform code screwing things up here -- possible quoting any argument which has a space in it, although in this special case only a part of the argument is to be escaped.

@valeros
Copy link
Member

valeros commented Nov 16, 2021

Hi @maxgerhardt ! Thanks for pointing out. I believe SCons wraps upload flags containing whitespaces, so we can rely on this functionality.

@maxgerhardt
Copy link
Contributor Author

By using the platformio.ini

[env:uno_wifi_rev2]
platform = https://github.com/platformio/platform-atmelmegaavr.git
board = uno_wifi_rev2
framework = arduino

[platformio]
packages_dir = package with spaces

This has had the effect of changing the invocation from the form

"-Uflash:w:"C:\Users\Wong Zhi Wei.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i"

to

-U "flash:w:C:\Users\Max\temp\uno_wifi\package with spaces\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex:i"

I'm not sore of this is better or worse with the missing quotes in the path argument, but at least I don't get a

avrdude: error parsing update operation 'flash:w:C:\Users\Wong'

style error anymore, just that no device was found (since I don't have a Uno WiFi Rev2 connected).

Maybe the original user can test this.

@maxgerhardt
Copy link
Contributor Author

Confirmed fixed.

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

2 participants