Program Microcontroller
We can write to the microcontroller memory spaces using the UPDI interface. It is recommended to use the pymcuprog
tool, from Microchip itself, with a Serial port UPDI adapter, that can be easily built using a TTL serial adapter and a resistor, as described in the link. This was NOT tested with the AVR128DB48 Curiosity Nano or similar evaluation boards.
With the adapter connected to the UPDI port in the db-synth PCB, and configured as described in the pymcuprog
documentation, run (assuming that the microcontroller is AVR128DB28
(AVR64DB28
is also supported), that serial adapter is available at /dev/ttyUSB0
and that it supports a baudrate of 230400
):
$ pymcuprog --tool uart --device avr128db28 --uart /dev/ttyUSB0 \
--clk 230400 write --filename db-synth-fuse.hex
$ pymcuprog --tool uart --device avr128db28 --uart /dev/ttyUSB0 \
--clk 230400 write --filename db-synth.hex --erase
The first command will write fuses, and the second command will write the firmware to flash.
Troubleshooting
If the pymcuprog
command fails on Linux with some permission problem, make sure to add the user to the group that owns the device /dev/ttyUSB0
(from the example commands). It is possible to check which group is it, by running:
$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 3 Aug 29 00:06 /dev/ttyUSB0
In this example, the group is dialout
. To add current user to the group:
$ sudo gpasswd -a $USER dialout