Using JTAG for AVR development with Ubuntu 18.04 (new OS releases)

The purpose of this tutorial is to enable the AVR toolchain based debugging using AVaRICE + AVR-GDB combination in newer debian based versions. The avarice version 2.13+svn which is installed using the apt repository seems to broke the debugging. So we would be using 2.12 version of Avarice for continuing the JTAG debugging in newer linux.

jtag_snap

Uninstall the avarice version first if already installed.

sudo apt-get remove avarice

Download the Avarice 2.12 version from

http://avarice.sourceforge.net/ — Home page

https://sourceforge.net/projects/avarice/files/avarice/avarice-2.12/

Compiling Avarice from source

Use the following command to compile and install avarice.

cd <path to avarice 2.12>

./configure

make

sudo make install

 

If there is issue in the compilation, please add the error log in the comment box. We will try to share our experience on this.

Using Avarice 2.12 for debugging

By default, the avarice program will be installed in /usr/local/bin folder

Make a symlink to /usr/bin/avarice with the following command

ln -s /usr/local/bin/avarice /usr/bin/avarice

Make sure you have the correct version in the path as

avarice –version

Compatible jtag can be purchased from our store.

https://www.elementzonline.com/avr-jtagice-mk1-debugger-v1-1-262

Now you can continue to use the avarice for debugging as normal

For quick testing use our previous blogs as reference.

https://elementztechblog.wordpress.com/2014/11/09/debugging-avr-ics-using-jtagice-and-eclipse-in-linux/

https://elementztechblog.wordpress.com/2016/03/21/elementz-avr-jtag-ice-for-avr-hardware-debugging/

Bonus:

Following command can be used if you are using AVR Dragon debugger instead of JTAGICE

avarice -d –ignore-intr –erase –program –file <filename>.elf -g -j usb :4242

7 thoughts on “Using JTAG for AVR development with Ubuntu 18.04 (new OS releases)

  1. Hi there, when I run ./configure the following error creeps up. I am using linux mint 18.

    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… /bin/mkdir -p
    checking for gawk… gawk
    checking whether make sets $(MAKE)… yes
    checking for g++… g++
    checking whether the C++ compiler works… yes
    checking for C++ compiler default output file name… a.out
    checking for suffix of executables…
    checking whether we are cross compiling… no
    checking for suffix of object files… o
    checking whether we are using the GNU C++ compiler… yes
    checking whether g++ accepts -g… yes
    checking for style of include used by make… GNU
    checking dependency style of g++… gcc3
    checking for gcc… gcc
    checking whether we are using the GNU C compiler… yes
    checking whether gcc accepts -g… yes
    checking for gcc option to accept ISO C89… none needed
    checking dependency style of gcc… gcc3
    checking for perl… /usr/bin/perl
    checking for library containing gethostbyname… none required
    checking for socket… yes
    checking for library containing inet_aton… none required
    checking for iconv_open in -liconv… no
    checking for libiconv_open in -liconv… no
    checking for dcgettext in -lintl… no
    checking for xmalloc in -liberty… no
    checking for bfd_init in -lbfd… no
    checking for usb_get_string_simple in -lusb… no
    configure: error: You need to install libbfd.a from binutils.

  2. Hi, when I run ‘make’ its showing the following error.

    Making all in scripts
    make[1]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/scripts’
    make[1]: Nothing to be done for ‘all’.
    make[1]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/scripts’
    Making all in src
    make[1]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    make all-am
    make[2]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    gcc -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT crc16.o -MD -MP -MF .deps/crc16.Tpo -c -o crc16.o crc16.c
    mv -f .deps/crc16.Tpo .deps/crc16.Po
    g++ -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT devdescr.o -MD -MP -MF .deps/devdescr.Tpo -c -o devdescr.o devdescr.cc
    devdescr.cc:36:51: error: _Pragma takes a parenthesized string literal
    PRAGMA_DIAG_IGNORED(“-Wmissing-field-initializers”)
    ^
    In file included from jtag.h:31:0,
    from devdescr.cc:29:
    pragma.h:33:38: error: ‘_Pragma’ does not name a type
    # define PRAGMA_DIAG_IGNORED(x) _Pragma(GCC diagnostic ignored x)
    ^
    devdescr.cc:36:1: note: in expansion of macro ‘PRAGMA_DIAG_IGNORED’
    PRAGMA_DIAG_IGNORED(“-Wmissing-field-initializers”)
    ^
    Makefile:363: recipe for target ‘devdescr.o’ failed
    make[2]: *** [devdescr.o] Error 1
    make[2]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    Makefile:227: recipe for target ‘all’ failed
    make[1]: *** [all] Error 2
    make[1]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    Makefile:267: recipe for target ‘all-recursive’ failed
    make: *** [all-recursive] Error 1

    • This is a really weird issue. Try changing the followwing in src/pragma.h

      # if __GNUC__ > 4
      # define PRAGMA_DIAG_PUSH _Pragma(GCC diagnostic push)
      # define PRAGMA_DIAG_POP _Pragma(GCC diagnostic pop)
      # define PRAGMA_DIAG_IGNORED(x) _Pragma(GCC diagnostic ignored x)

      to

      # if __GNUC__ > 4
      # define PRAGMA_DIAG_PUSH _Pragma(“GCC diagnostic push”)
      # define PRAGMA_DIAG_POP _Pragma(“GCC diagnostic pop”)
      # define PRAGMA_(x) _Pragma(#x)
      # define PRAGMA_DIAG_IGNORED(x) PRAGMA_(GCC diagnostic ignored x)

      and use the make command

      For installing to system path, use “sudo make install”. This will install to /usr/local/bin directory.

  3. Hi, I edited the src/pragma.h but Still having the follo error when running make.
    Making all in scripts
    make[1]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/scripts’
    make[1]: Nothing to be done for ‘all’.
    make[1]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/scripts’
    Making all in src
    make[1]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    make all-am
    make[2]: Entering directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    g++ -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT devdescr.o -MD -MP -MF .deps/devdescr.Tpo -c -o devdescr.o devdescr.cc
    mv -f .deps/devdescr.Tpo .deps/devdescr.Po
    g++ -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT ioreg.o -MD -MP -MF .deps/ioreg.Tpo -c -o ioreg.o ioreg.cc
    mv -f .deps/ioreg.Tpo .deps/ioreg.Po
    g++ -DHAVE_CONFIG_H -I. -Wall -Wextra -g -O2 -MT jtag2bp.o -MD -MP -MF .deps/jtag2bp.Tpo -c -o jtag2bp.o jtag2bp.cc
    jtag2bp.cc:324:1: error: _Pragma takes a parenthesized string literal
    PRAGMA_DIAG_PUSH
    ^
    jtag2bp.cc:324:1: error: stray ‘\200’ in program
    jtag2bp.cc:324:1: error: stray ‘\234’ in program
    jtag2bp.cc:324:1: error: stray ‘\342’ in program
    jtag2bp.cc:324:1: error: stray ‘\200’ in program
    jtag2bp.cc:324:1: error: stray ‘\235’ in program
    jtag2bp.cc:368:1: error: _Pragma takes a parenthesized string literal
    PRAGMA_DIAG_POP
    ^
    jtag2bp.cc:368:1: error: stray ‘\200’ in program
    jtag2bp.cc:368:1: error: stray ‘\234’ in program
    jtag2bp.cc:368:1: error: stray ‘\342’ in program
    jtag2bp.cc:368:1: error: stray ‘\200’ in program
    jtag2bp.cc:368:1: error: stray ‘\235’ in program
    In file included from jtag.h:31:0,
    from jtag2bp.cc:38:
    pragma.h:31:29: error: ‘_Pragma’ does not name a type
    # define PRAGMA_DIAG_PUSH _Pragma(“GCC diagnostic push”)
    ^
    jtag2bp.cc:324:1: note: in expansion of macro ‘PRAGMA_DIAG_PUSH’
    PRAGMA_DIAG_PUSH
    ^
    jtag2bp.cc:325:44: error: expected declaration before end of line
    Makefile:363: recipe for target ‘jtag2bp.o’ failed
    make[2]: *** [jtag2bp.o] Error 1
    make[2]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    Makefile:227: recipe for target ‘all’ failed
    make[1]: *** [all] Error 2
    make[1]: Leaving directory ‘/home/xxxx/xxxx/avarice-2.12/src’
    Makefile:267: recipe for target ‘all-recursive’ failed
    make: *** [all-recursive] Error 1

    • Please make sure when copying and pasting indentation is not changing. Otherwise the above error will occur. “_Pragma takes a parenthesized string literal” probably means indentation error.

Leave a comment