Commit 2cf0a7da authored by Erik Strand's avatar Erik Strand

Improve bootloader documentation

parent c9bc71af
......@@ -8,15 +8,16 @@
Arduino compatible bootloaders for SAMD11 and SAMD21 can be found
[here](https://github.com/mattairtech/ArduinoCore-samd/tree/master/bootloaders/zero/binaries). The
SAMD11C14 bootloader is already in this directory for you.
SAMD11C14 bootloader is already in this directory for you. The docs are
[here](https://github.com/mattairtech/ArduinoCore-samd/blob/master/bootloaders/zero/README.md).
We need to write this file into the micro's memory. I have been using the `Serial Wire Debug`
interface, which is enabled by default on the D11 hardware. `SWCLK` is on `PA30` and `SWDIO` is on
`PA31`. JTAG is also available, but requires an enable pin pulled low somewhere *I think*. An Atmel
ICE debugger should be able to handle either.
From here on out there are two options for burning the bootloader to your board (documented here
anyway): OpenOCD, and Atmel Studio.
From here on out there are three options for burning the bootloader to your board (documented here
anyway): OpenOCD, the Arduino IDE, and Atmel Studio.
## OpenOCD
......@@ -29,46 +30,69 @@ configuration file here has all the relevant commands inside it. If all goes wel
something like this, and then `openocd` will immediately exit.
```
erik@strandbeest:~/Code/atsamd51/bootloader$ openocd
Open On-Chip Debugger 0.10.0+dev-00973-g80f1a92b (2019-12-01-17:19)
Eriks-MacBook-Pro-3:bootloader erik$ openocd
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 1.0
Info : CMSIS-DAP: Serial# = J41800095841
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 2000 kHz
Info : SWD DPIDR 0x2ba01477
Info : at91samd51j19.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd11c14a.cpu: hardware has 4 breakpoints, 2 watchpoints
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* at91samd11c14a.cpu cortex_m little at91samd11c14a.cpu running
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0000033c msp: 0x2000c020
xPSR: 0x81000000 pc: 0x000004a0 msp: 0x20000ffc
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0000033c msp: 0x2000c020
xPSR: 0x81000000 pc: 0x000004a0 msp: 0x20000ffc
** Programming Started **
Info : SAM MCU: SAMD51J19A (512KB Flash, 192KB RAM)
auto erase enabled
Info : SAMD MCU: SAMD11C14A (16KB Flash, 4KB RAM)
wrote 4096 bytes from file sam_ba_Generic_D11C14A_SAMD11C14A.bin in 0.703033s (5.690 KiB/s)
** Programming Finished **
** Verify Started **
verified 3904 bytes in 0.388889s (9.804 KiB/s)
** Verified OK **
shutdown command invoked
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
```
Note that once the bootloader is on your micro, you can't program it as discussed in
[blink-openocd](../blink-openocd). (It's harmless to try it; you'll just get an error.) This happens
because the bootloader is protected. To disable this protection, run `openocd -f
unprotect_bootloader.cfg`. Then the next time you program it, the bootloader will be overwritten.
Note that once the bootloader is on your board, OpenOCD will complain if you try to overwrite it
with something else. This happens because the bootloader is protected. To disable this protection,
run `openocd -f unprotect_bootloader.cfg`. Then you can overwrite it without any issues.
## Arduino IDE
See "Bootloader Firmware Installation"
[here](https://github.com/mattairtech/ArduinoCore-samd/blob/master/bootloaders/zero/README.md).
## Atmel Studio
To speak SWD, I just use the Atmel-Ice programmer, and Atmel Studio 7 (a windows application, sorry). Any programmer that speaks SWD should be capable of doing this. In Atmel Studio, go to `Tools -> Device Programming`, and select the Atmel-Ice Tool, the ATSAMD51xxxx device you'd like to program (the bootloader is written for the ATSAMD51J19A), and the SWD interface. You should be able to read the device signature. If this works, your SWD connection is all super-gucci (as they say). You can navigate to `Memories` - and write that bootloader in. OK. The device should now enumerate over USB as an Adafruit Feather M4 / FeatherBoot (or something similar).
I haven't tried this yet, but you should be able to do the same thing Jake did for the
[SAMD51](https://gitlab.cba.mit.edu/pub/hello-world/atsamd51/tree/master/bootloader).
# Programming with the Arduino IDE
You have to do a little setup to get the Arduino IDE to talk to your board.
1. Go to Arduino > Preferences, and click on the button next to "Additional Boards Manager URLs"
2. Add `https://www.mattairtech.com/software/arduino/package_MattairTech_index.json`
3. Go to Tools > Board > Boards Manager
4. Search for "Mattair", and install the "MattairTech SAM D|L|C Core for Arduino" package
That's all the installation necessary. To talk with your board, make sure you select the right board
from the boards menu (`GenericD11C14A`), and USBtinyISP for the programmer.
If you're interested, you can check out Adafruit's documentation of this process
[here](https://learn.adafruit.com/how-to-program-samd-bootloaders/programming-the-bootloader-with-atmel-studio).
The original documentation is available here
[source](https://github.com/mattairtech/ArduinoCore-samd/blob/master/README.md) (scroll way down, or
seearch for "Installation").
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment