Programing the CW308 ATSAML11 target

Hi,

I’m trying to use the CW308T-ATSAML11 target (for setup details, see below, though I don’t think they’re super relevant). As it cannot be flashed by the ChipWhisperer directly, I have to use another tool. The datasheet PDF mentions having to use “an external programmer (such as Atmel ICE or OpenOCD)”. However, when I try to use OpenOCD, I get the following error log (the same error appears on v0.11.0, v0.12.0, and the current latest commit, 1173473f6):

Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64 (2024-10-03-18:26)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
none separate

Info : FTDI SWD mode enabled
swd
Warn : Transport "swd" was already selected
cortex_m reset_config sysresetreq

Info : clock speed 500 kHz
Info : SWD DPIDR 0x0bf11477
Info : SWD DPIDR 0x0bf11477
Error: Failed to read memory at 0xe000ed00
Warn : target saml1x.cpu examination failed
Info : starting gdb server for saml1x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error: Target not examined yet

This is slightly weird, as OpenOCD has tcl scripts for the SAML11 (tcl/target/atsaml1x.cfg) which would indicate some level of support. Similarly, the 0.11.0 changelog entry lists added support for a SAML11 devboard. Has anyone tested using OpenOCD to program the ATSAML11 before? Is there a commit that does work? Or should I get myself an Atmel-ICE instead?


Setup details: I’m using a Husky and CW313 board, and have connected the CW308T-ATSAML11 by using one of those CW313-CW308 adapter boards. I have added two jumpers to JP3 to connect TMS/SWDIO and TCK/SWCLK with PDID and SCK, respectively (and use --no-user-io/enable_MPSSE(1)) so the SWD connection goes over the standard 20-pin ChipWhisperer connector. I’m using the ./openocd/run_openocd.sh -p $FILE_TO_PROG --no-user-io husky swd -- -f target/atsaml1x.cfg command to call OpenOCD.

The debugging implementation for ChipWhisperers is pretty hacky (it’s a bitbang’d version of FTDI’s MPSSE), so it’s probably something to do with that. I’ll update our documentation so that it’s clear that some targets may not work.

Well, after some more experimentation and looking things up, I’m still getting the same error with an FT4232-56Q Mini Module. Similarly, OpenOCD using the Husky is able to read the SWD IDR (Info : SWD DPIDR 0x0bf11477 in the log), so I’d think the SWD connection itself is working.

Reading the ATSAML11 datasheet chapters 14 and 16, it seems that the debugger first has to put the chip into a “CPU park mode” state which needs some magic MMIO pokes to be done first. Meanwhile, OpenOCD source (latest-as-of-writing) only has flash routines for the SAML2x, not L1x. So it looks like it doesn’t actually have support. Oh well.

probe-rs also doesn’t seem to support the ATSAML11, as it has no builtin support for it, and the public CMSIS Pack file for it doesn’t have a binary containing the flashing algorithms. pyOCD has the same issue, except there’s a stale PR that doesn’t work with the latest upstream anymore. UrJTAG and Blackmagic Debug don’t have any support at all (and don’t support CMSIS Pack files).

So yeah, I guess I’ll need an Atmel ICE…

Oh, and on a quick note: the CW308T-ATSAML11 RTFM page mentions a serial bootloader (AN2699), but the issue is that it’s not factory-programmed, hence not really being suitable here.