meta data for this page
AVR debugger
This post shows some possible debuggers for the ATMEL AVR MCU. Due to a more and more difficult handling with the debug server AVARICE under Linux the subject is no longer pursued.
Olimex JTAG-Debugger
Because it's hard to find a serial interface (RS232) on todays PC's the Olimex-Debugger must be connected with a serial to USB adapter like the PL2303 to a PC.
The Linux kernel should load the module usbserial and have an udev device entry /dev/ttyUSBx
created.
A new udev rule must be created:
~# vi /etc/udev/rules.d/z60_olimex.rules
The new rule should add a link from /dev/avrjtag
to /dev/usbx
while detecting the PL2303. Then the Olimex debugger is accessible under /dev/avrjtag
.
SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303" SYMLINK+="avrjtag"
idVendor
and idProduct
corresponds to the real values of the adapter figured out by lsusb
.
~# lsusb ............. Bus 004 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port .............
/dev/avrjtag
should be generated. After removing it should disappear.The Olimex JTAG debugger can be used both to flash or debug the ATMEL AVR MCU.
JTAG ICE MKI
The debugger is similar to an Atmel JTAG ICE MKI. It is also an equivalent and cheap replacement for the Olimex JTAG debugger.
The device is detected as a simple “USB to serial” adapter on /dev/ttyUSBx
. The entry in the udev rules is according to the rules of the Olimex debugger:
~# vi /etc/udev/rules.d/z60_jtagicemki.rules
The new rule should add a link from /dev/avrjtagicemki
to /dev/usbx
while detecting the debugger. The JTAG ICE MKI debugger is then accessible under /dev/avrjtagicemki
.
SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523" SYMLINK+="avrjtagicemki"
idVendor
and idProduct
corresponds to the real values of the adapter figured out by lsusb
.
~# lsusb ............. Bus 007 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter .............
/dev/avrjtagicemki
should be generated. After removing it should disappear.The JTAG ICE MKI debugger can be used both to flash or debug the ATMEL AVR MCU.
JTAGICE3 Debugger
The JTAGICE3 is more up-to-date than the devices describes before. It supports also the ATMEGA 644 MCU in contrast to the Olimex or JTAG ICE MKI.
When the device is connect to the PC's USB port, it appears as /dev/usb/hiddev0
. For having a distinct name a udev rule must create a link:
~# vi /etc/udev/rules.d/z61_jtagice3.rules
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2140" SYMLINK+="avrjtagice3" SUBSYSTEM=="usbmisc", KERNEL=="hiddev*", MODE="0664", GROUP="plugdev"
idVendor
and idProduct
corresponds to the real values of the adapter figured out by lsusb
.
~# lsusb ............. Bus 004 Device 005: ID 03eb:2140 Atmel Corp. .............
/dev/avrjtagice3
should be generated. After removing it should disappear.AVRDUDE
The tool AVRDUDE can be used on your PC to program the MCU attached local by one of the debugger.
In order to program flash of the ATMEGA by AVRDUDE with one of the debugger (/dev/avrjtag
, /dev/avrjtagicemki
or /dev/avrjtagice3
) over the network from one PC to another, the device must be made transparent by the tool ser2net
. The tool offers telnet or raw connections over TCP/IP to a local serial interface.
First install ser2net
:
~# apt-get install ser2net
The matching config file /etc/ser2net.conf
contains entries to make /dev/avrjtag
available as raw interface with 115200 Baud on port 4244 in IP based network:
4244:raw:0:/dev/avrjtag:115200 8DATABITS NONE 1STOPBIT
On the client PC the connection with AVRDUDE to /dev/avrjtag
on the server can be established by calling AVRDUDE with options -P net:<servername>:4244
. In Eclipse there is an entry needed in properties of menu AVR → AVRDUDE
, Tab Programmer → Edit, “Override Default Port (-P)”.
Calling AVRDUDE on command line:
guest:~$ avrdude -cjtagmkI -P/dev/avrjtag
AVARICE
AVARICE is a GDB-server which offers a AVR-GDB remote session over network.
Installation:
~# apt-get install avarice
AVARICE must be started as user in a shell. In this example it should listen on port 4242 for incoming GDB remote sessions. A JTAG-frequency of 250kHz is the default.
The MCU in our example is a ATMEGA16:
Olimex ''/dev/avrjtag''
guest:~$ avarice -1 --ignore-intr -d -l -j /dev/avrjtag -P atmega16 :4242
JTAG ICE MKI ''/dev/avrjtagicemki''
guest:~$ avarice -1 --ignore-intr -d -l -j /dev/avrjtagicemki -P atmega16 :4242
JTAGICE3 ''/dev/avrjtagice3''
guest:~$ avarice -4 -P atmega169 -d :4242
The last option is only possible with the latest version of avarice from the SVN repositories.
Because AVARICE refuses proper operation on a ATMEGA644, debugging is not possible. It seems the AVARICE development is orphaned. For a good working debug session ATMELStudio of Microchip is needed, but is running only on Windows systems.