how to (almost) make (almost) anything


wildcard: advanced embedded programming


More is more, and this week I wanted to learn more tools for embedded programming, specifically the ability to program the SAMD ARM processors over a USB connection.

producing a hello world & blink board

Many [SAMD11C14As] died to bring us this information

The week started smoothly with the apparently successful installation of openOCD, which is an open tool for on-chip debugging and has been documented by Erik for his wildcard session.

In Terminal, I ran $ brew install openocd and the package installed locally.

I pulled the openOCD repository using $ git clone https://git.code.sf.net/p/openocd/code openocd-code.

Erik had provided a couple of Neil's hello.D11.USB boards, so I navigated to the SAMD11/bootloader directory containing the openocd.cfg and ran $ openocd. By default, it looks for the openocd.cfg file in the same directory, or a filename can be specified with the -f flag (like make).

The bootloader uploaded and gave the following message (a selection from a longer output):

** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
wrote 4096 bytes from file sam_ba_Generic_D11C14A_SAMD11C14A.bin in 0.712101s (5.617 KiB/s)
** Programming Finished **
** Verify Started **
verified 3904 bytes in 0.394687s (9.660 KiB/s)
** Verified OK **
shutdown command invoked

After the bootloader was uploaded, I switched to the Arduino IDE and programmed the board. It seemed to take, but somebody else could not program the board after I had done so. So that was suspicious.

To test the workflow for programming a SAM processor, I modified Neil's hello.D11.USB board and added two LEDs on free pins.

In an attempt to save time, I used Photoshop to add the LEDs, being now generally familiar with the requisite conenctions to do so. I did not do an expert job, however, and I left a few pixels that ended up fusing the traces together later, and caused another round of troubleshooting.

After I detected the short caused by the rogue pixels, I was able to load the bootloader from Open OCD. This time, however, I could not see the board on the port.

For some reason, the bootloader would take (or appear to) but then I could not program. I went back to Erik and we decided that I should replace the MCU.

After trying the sequence again, and again rendering the chip invisible to Arduino IDE, I tried again, this time bootloading from Erik's computer. That worked, and I was able to see the board on the ports. The full drama is played out here.