Description
While working with some ATMEL ATtiny 214 chips, I discovered a bug that makes it impossible to set the fuses of the Microcontroller, when using a SerialUPDI programmer. The problem appears to be an incorrectly created avrdude command.
The generate command looks like this:
avrdude -p attiny214 -C /home/felix-wurm/.platformio/packages/tool-avrdude/avrdude.conf -v -P "/dev/ttyUSB0" -c jtag2updi --tool uart --device attiny214 --uart /dev/ttyUSB0 --clk 115200 -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x02:m -Ufuse4:w:0x00:m -Ufuse5:w:0xC5:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m
which results in an error that boils down to:
avrdude: invalid option -- '-'
A correct avrduide command with the same functionality would look like this:
avrdude -p attiny214 -C /home/felix-wurm/.platformio/packages/tool-avrdude/avrdude.conf -v -P "/dev/ttyUSB0" -c jtag2updi -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x02:m -Ufuse4:w:0x00:m -Ufuse5:w:0xC5:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m -c serialupdi
This is because all the options beginning with '--' are invalid, and most of them are duplicate anyway (apart from the -c serialupdi ).
My platformio.ini file looks like the following:
[common]
platform = atmelavr
build_flags = -DLIGHT_WS2812_AVR -Os -Wall -Wextra -Wl,-Map,foo.map
lib_deps = https://github.com/FelixWurm/light_ws2812.git
upload_port = /dev/cuaU0
[env:ATtiny214]
platform = atmelmegaavr
board = ATtiny214
lib_deps = ${common.lib_deps}
build_flags = ${common.build_flags}
upload_port = /dev/ttyUSB0
upload_flags =
--tool
uart
--device
attiny214
--uart
$UPLOAD_PORT
--clk
$UPLOAD_SPEED
board_build.f_cpu = 20000000L
upload_command = pymcuprog write --erase $UPLOAD_FLAGS --filename $SOURCE
avrdude and PlatformIO are the latest version (PlatformIO Core, version 6.1.18
, avrdude version 7.1
) I fixed the problem manly for now, but maybe someone can fix this more permanently or tell me were I made a mistake. Thanks!