Hello,

Hope this is the right list, otherwise please let me know where I can
get help on the following issue.

I'm trying to flash a ATSAM3X8E on an Arduino Due using OpenOCD via
ST-LINK adapter. Arduino Due exposes a 4-pin SWD interface they call the
"Debug" pins.

I have connected ST-Link's pins 1 (VCC), 3 (TRST), 7 (SWDIO), 9 (SWCLK)
and 20 (GND) to Arduino Due's IOREF, RESET, TMS, TCK and GND
respectively.

Then I run the following command to flash the program.

# openocd -f openocd-due.cfg -c "program a.elf verify reset exit"

When I run that, I get the following output:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Could not determine executable path, using configured BINDIR.
Info : The selected transport took over low-level target control. The
results might differ compared to plain JTAG/SWD
Info : clock speed 500 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.197910
Info : sam3.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for sam3.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0010004c msp: 0x20001000
** Programming Started **
flash
  flash bank bank_id driver_name base_address size_bytes
chip_width_bytes
            bus_width_bytes target [driver_options ...]
  flash banks
  flash init
  flash list
gdb_flash_program ('enable'|'disable')
nand
program <filename> [address] [pre-verify] [verify] [reset] [exit]
Error: invalid subcommand "write_image erase a.elf"
** Programming Failed **
shutdown command invoked
embedded:startup.tcl:583: Error:
at file "embedded:startup.tcl", line 583

The openocd-due.cfg contains the following config.

source [find interface/stlink.cfg]
transport select hla_swd
adapter speed 1800
set CPUTAPID 0x2ba01477
source [find target/at91sam3XXX.cfg]

If it's of use, the program is just a main.c containing the following
code.

#include <stdio.h>

int main(void)
{
        printf("hello, world!\n");
        return 0;
}

and is compiled using the following commands.

$ arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -o a.elf main.c
$ arm-none-eabi-objcopy -O ihex -j .text -j .data a.elf a.hex

Some additional information. If I run $ openocd -f openocd-due.cfg and
press the reset button on the board I see the following log. The "Error"
line is when I press the reset button.

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Could not determine executable path, using configured BINDIR.
Info : The selected transport took over low-level target control. The
results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 500 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.200000
Info : sam3.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for sam3.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error: jtag status contains invalid mode value - communication failure
Polling target sam3.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Polling target sam3.cpu failed, trying to reexamine
Info : sam3.cpu: hardware has 6 breakpoints, 4 watchpoints

-- 
Sadeep Madurange
PGP: 103BF9E3E750BF7E

Reply via email to