From: Sadeep Madurange Subject: Re: OpenOCD 0.11.0 config example To: David Barrass Cc: ports@openbsd.org Date: Sun, 8 Sep 2024 09:30:41 +0800 On 2024-09-07 16:26:46, David Barrass wrote: > On 07/09/24 12:14, Sadeep Madurange wrote: > > I'm trying to flash a ATSAM3X8E chip using the OpenOCD package. > > OpenOCD version we have appears to be a bit old. So my openocd.cfg > > doesn't seem to work. > > > > Does anyone happen to have an example I could use? My current > > openocd.cfg is, > > > > source [find interface/stlink.cfg] > > transport select hla_swd > > adapter speed 1800 > > set CPUTAPID 0x2ba01477 > > source [find target/at91sam3XXX.cfg] > > > Hi Sadeep, > > There are many pieces to getting a successful debug session, so which > bit is broken? > > It is not very helpful to just say "doesn't seem to work" - a log of > the session would be helpful. So I can't assist further without more > information. > > You are using stlink - is this correct? stlinkv2 is the more recent > version. > > Are you sure that you have selected the correct transport? Your config > shows SWD - is this correct. (Very probably but JTAG is valid also.) > > Is the target at91sam3XXX actually present in the target directory? > > It is VERY unlikely that your problem is anything to do with the > OpenOCD version. STLINKv2 has been supported for a long time as has > the AT91SAM family. Does OpenOCD/OpenBSD actually detect the stlink > device? > > More detail is absolutely essential in order to diagnose and resolve > this issue. > > I can see at91sam3XXX in my 0.10 version of openocd and all the stlink > devices so your problem is not the version, just the device driver or > configuration. Apologies, I was checking with the OpenOCD list, and presumed the package version to be the case. You are right that this has nothing to do with the package version. When I run the following command with the config I posted, I get the following error. # openocd -f openocd-due.cfg -c "program a.hex verify reset exit" 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 [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 Then I changed the config to source [find interface/stlink.cfg] transport select hla_swd adapter speed 1800 set CPUTAPID 0x2ba01477 source [find target/at91sam3ax_8x.cfg] the error changes to 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 ** Warn : no flash bank found for address 0x0000800c Warn : no flash bank found for address 0x0000ad70 ** Programming Finished ** ** Verify Started ** Error: checksum mismatch - attempting binary compare ** Verify Failed ** shutdown command invoked I checked with the OpenOCD list and they confirmed that OpenOCD supports flashing my part, but that I may have to change the target file to align the addresses and sizes correctly. So, the problem is with my config not the package version, which I will work on. Apologies for the noise (if anyone has a config for this part, do share anyway :). -- Sadeep Madurange PGP: 103BF9E3E750BF7E