Skip to content

Instantly share code, notes, and snippets.

@yotann
Last active December 5, 2019 00:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yotann/377d7a66a879ae6fc2cd19030f19f2e3 to your computer and use it in GitHub Desktop.
Save yotann/377d7a66a879ae6fc2cd19030f19f2e3 to your computer and use it in GitHub Desktop.
Prototype HARP reprogramming guide
This guide explains how to load custom code on the SparkFun Prototype HARP
(https://www.sparkfun.com/products/14379). Now, you're *supposed* to reset the
board after solving it and give it to a friend, so they can experience the
puzzle too. But maybe your friends are too busy fighting a rogue AI, or maybe
friendship is expensive where you live. In that case, it's possible to make the
board Arduino-compatible with some effort.
You should have gotten access to the board's development files when you solved
the puzzle. Note that the design is similar to the "SparkFun 9DoF Razor IMU M0"
and the "SparkFun SAMD21 Mini Breakout", but with different peripherals. All
these boards are based around the same Atmel ATSAMD21G18 ARM chip as the
Arduino Zero and Arduino M0.
Unfortunately, the Prototype HARP is programmed without the Arduino bootloader,
so there's no way to reprogram it using the USB port. Instead, we can reprogram
it using the Cortex Debug Connector to connect directly to the debugging
hardware on the chip. Once we've installed the Arduino bootloader over the
debug connector, we can load programs over USB using the Arduino IDE.
## 1. Find the Cortex Debug Connector
The debug connector is a 2x5 grid of tiny holes towards the edge of the board,
above the black blob which hides the microcontroller. There's a white vertical
line next to one of the holes. The holes are laid out like this:
SWDIO SWDCLK NC NC nRESET
white line ---> | 3.3V GND GND NC NC
## 2. Reprogram the board
The proper way to use the debug connector is to solder a 0.05" 2x5 header into
it, and then connect it to an official ARM Cortex programmer. I'm impatient, so
I just jammed some hookup wires into the holes and connected them to a
Raspberry Pi. Adafruit has a guide for this:
https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi/overview
You should only need to connect SWDIO and SWDCLK with wires, and then connect
the Prototype HARP to the Pi with a USB cable in order to provide power and
ground. nRESET doesn't need to be connected. Follow the Adafruit guide up
through the first run of openocd. It should print "target halted due to
debug-request", similar to their example.
Now, instead of the binary file Adafruit uses, you'll want to download this:
https://raw.githubusercontent.com/sparkfun/9DOF_Razor_IMU/master/Firmware/Bootloader/SparkFun_9DoF_Razor_M0.hex
That's the bootloader for the SparkFun 9DoF board, but it will also work on the
Prototype HARP. Put these commands at the bottom of your openocd.cfg file:
init
targets
reset halt
# Save the original firmware in case you change your mind later.
dump_image original_firmware.bin 0 0x40000
# Erase the flash.
at91samd chip-erase
# Wait for the chip erase to finish (is this necessary?)
sleep 10000
# Program the new bootloader.
program SparkFun_9DoF_Razor_M0.hex verify
# Protect the bootloader so it isn't accidentally overwritten.
at91samd bootloader 8192
reset
shutdown
Run "sudo openocd" and wait for it to finish. The Prototype HARP is
now ready to act like an Arduino!
## 3. Set up Arduino IDE
Set up the IDE using this guide:
https://learn.sparkfun.com/tutorials/samd21-minidev-breakout-hookup-guide/setting-up-arduino
The blink example won't work, since all three of the pins it uses are
disconnected on the Prototype HARP. Instead, you can install the Adafruit
NeoPixel library, and control the HARP's RGB LED using this example:
#include <Adafruit_NeoPixel.h>
#define DIGITAL_RGB_PIN 12
Adafruit_NeoPixel led = Adafruit_NeoPixel(1, DIGITAL_RGB_PIN, NEO_GRB);
void setup() {
led.begin();
}
void loop() {
led.setPixelColor(0, led.Color(random(0, 30), random(0, 30), random(0, 30)));
led.show();
delay(333);
}
@christophorum
Copy link

Do you still have the password for mfgDocs.7z?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment