[personal profile] gdt

The Atmel-ICE in-circuit debugging hardware

The Atmel-ICE is an in-circuit debugger for the Atmel SAM and AVR systems-on-chip. Depending upon the device it uses the JTAG protoccol or its Serial Wire Debug extension.

I bought the Atmel-ICE offered by Northbound Networks as it included a pre-made ribbon cable matching their Zodiac FX OpenFlow switch.

Plugging the ICE into the ZodiacFX is is straightforward. The small keyed insulation displacement connector on the ribbon cable goes into the ICE's "SAM" port. It will only go one way. Power down the ICE and the ZodiacFX by unplugging their USB connectors. Plug the other end of the ribbon cable onto the header marked "JTAG". Note that Pin 1 on the board is furthest from the "JTAG" silkprinting and Pin 1 on the ribbon cable is marked with a different colour.

The OpenOCD software

OpenOCD is free software for on-chip debugging. Install at least version 0.9.0. This is available in Jessie Backports.

Allow non-root users to use the debugger. Add the following to /etc/udev/rules.d/77-northbound-networks.rules:

# Atmel-ICE JTAG/SWD in-circuit debugger
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2141", MODE="664", GROUP="plugdev"
$ sudo udevadm control --reload-rules

You might want to add yourself to the plugdev group with usermod -a -G plugdev vk5tu.

Attach Atmel-ICE to USB port. It will power up, lighting the middle red LED.

usb 1-1.5.3: new high-speed USB device number 12 using dwc_otg
usb 1-1.5.3: New USB device found, idVendor=03eb, idProduct=2141
usb 1-1.5.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.5.3: Product: Atmel-ICE CMSIS-DAP
usb 1-1.5.3: Manufacturer: Atmel Corp.
usb 1-1.5.3: SerialNumber: J12300012345
hid-generic 0003:03EB:2141.0004: hiddev0,hidraw2: USB HID v1.11 Device
[Atmel Corp. Atmel-ICE CMSIS-DAP] on usb-3f980000.usb-1.5.3/input0

Create openocd.cfg file in current directory containing:

# Atmel-ICE JTAG/SWD in-circuit debugger.
interface cmsis-dap
cmsis_dap_vid_pid 0x03eb 0x2141
cmsis_dap_serial J12300012345
# Northbound Networks Zodiac FX board
# contains Atmel SAM4E8C system-on-chip.
source /usr/share/openocd/scripts/target/at91sam4sXX.cfg

Plug in the Zodiac FX's USB port. It will start and light it's green LED.

If you were doing this as part of a development team you'd write a systemd unit to automatically start OpenOCD when the ICE is powered. But it's just us so we will start the daemon by hand:

$ openocd
Open On-Chip Debugger 0.9.0 (2016-05-04-19:11)
Licensed under GNU GPL v2
For bug reports, read
Info : only one transport option; autoselect 'swd'
adapter speed: 500 kHz
adapter_nsrst_delay: 100
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 01.16.0041
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 500 kHz
Info : SWD IDCODE 0x2ba01477
Info : SAM4E8C.cpu: hardware has 6 breakpoints, 4 watchpoints

The line "CMSIS-DAP: Interface ready" indicates the ICE has been reached. The line "SAM4E8C.cpu: hardware has…" indicates that the CPU has been reached. You'll have noticed that the green LED on the Atmel ICE is lit.

The command line is available via telnet to port 4444. The following shows a telnet connection, a test that the ICE is available, and a test that the ZodiacFX is available:

$ telnet localhost 4444
Open On-Chip Debugger
> cmsis-dap info
CMSIS-DAP: FW Version = 01.16.0041
SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 0 nTRST = 0 nRESET = 1
> targets
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* SAM4E8C.cpu        cortex_m   little SAM4E8C.cpu        running

Some other commands you might want to try:

> flash banks
#0 : SAM4E8C.flash (at91sam4) at 0x00400000, size 0x00000000, buswidth 1, chipwidth 1
> at91sam4 gpnvm
sam4-gpnvm0: 0
sam4-gpnvm1: 1
> reg

You can also use gdb to port 3333 for debugging. But remember that it has to be able to debug the architecture and the linkage of the SAM4 whilst being able to run on the architecture and linkage of your workstation. See if your machine can install ARM's port of GNU cc and related tools:

$ sudo apt-get install gcc-arm-none-eabi gdb-arm-eabi-none
$ arm-none-eabi-gdb --eval-command="target remote localhost:3333"

For gdb to be useful you will want the symbol table for the binary file running on the board, which you then pull into gdb using the symbol-file option or the -s parameter. You need to create the symbol file when you do the final linkage. There's ample discussion of this on the internet, such as at the StackExchange sites.

From: (Anonymous)
Hi Glen,

Thanks for the excellent guide. On Ubuntu 14.04 I needed a few extra steps because the repository version of openocd is v0.8.0 which lacks CMSIS-DAP. I cloned the github code and built openocd from source code (including installing libhidapi-dev which is needed for CMSIS-DAP). With this new version I was able to follow all steps successfully up to and including the "flash banks" command. However when I ran the "at91sam4 gpnvm" command I got an error message "sam4 - target not halted". I understand this means the ICE wasn't able to stop the ARM processor on ZodiacFX for some reason.

When I try to connect using gdb as you describe, I get the following:
accepting 'gdb' connection on tcp/3333
Target not halted
auto_probe failed
Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
attempted 'gdb' connection rejected

Some additional information in case this is of any help:
- the ICE is connected via USB to my laptop
- ZodiacFX is connected to my laptop via USB and there is an ethernet cable between port 4 (OF) and my laptop ethernet port
- The bus cable is connected to the SAM socket on the ICE and connected to jTAG on ZodiacFX
- There are three LEDs on the ICE, left is on (green), mid is on (red), right is off.
- All of the outputs you have are the same as those I saw, save for these differences:
- in the dmesg output, you have usb-1-1.5.3 whereas I have usb-2-1.1
- In the last line of dmesg output ("hid-generic") I have ""hiddev0, hidraw0" instead of "hiddev0, hidraw2" and the "usb-" string at the end is also different
- Of course the serial number is different and I copied my serial number into the openocd.conf file and updated the "source" path in this file to point to my github repository too
- ZodiacFX firmware version is 0.65

Can you think of anything that might be wrong in this setup? FYI in case this was something to do with the current snapshot of openocd, I tried using the earlier commit with v0.9.0 tag but got the same result.

From: [identity profile] vk5tu.livejournal.com
Hi Rory. JTAG programmers don't really write to flash, they just load RAM, set breakpoints and run programs. So to erase and write to the flash the programmer loads a short program to RAM and runs it. That's why the CPU has to be halted before flash can be programmed. The OpenOCD command you are looking for is "reset halt". You follow that up with " flash write_image erase ZodiacFX.bin 0x00400000 bin", "at91sam4 gpnvm set 1", "exit" and then power cycle the board.

There's an existing openocd.cfg I have committed to the ZodiacFX git which has a lot of helper functions to give a single-line programming command (which you can then put into a Makefile, see the one in the ZodiacFX github for an example).
From: [identity profile] vk5tu.livejournal.com
Oh, and if you are using gdb, see the "gdb-attach" hook. Use that to automate the halt of the CPU when GDB attaches. Put this into your openocd.cfg:

SAM4E8C.cpu configure -event gdb-attach { halt }
From: (Anonymous)
In the ZodiacFX repository I found an extended version of your own openocd.cfg with lots of useful additional comments which helped put your reply above in context for me.

As a result I have now completed the basic step of flashing a new binary onto ZodiacFX using this method, and setting a breakpoint. All of which worked as expected.

Many thanks -- Rory


Glen Turner

August 2017

27 28293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated 2017-10-20 23:30
Powered by Dreamwidth Studios