Skip to content

Instantly share code, notes, and snippets.

@todbot
Last active January 5, 2025 14:11
Show Gist options
  • Save todbot/0f284c45c38e7418bf7edbb0d1302f2f to your computer and use it in GitHub Desktop.
Save todbot/0f284c45c38e7418bf7edbb0d1302f2f to your computer and use it in GitHub Desktop.
Program a SAMD21 with OpenOCD and a JLINK
# Program a SAMD21 part with a bootloader using a JLINK / J-LINK
# 0a. Wire up your device with SWD & SWC pins to JLINK
# 0b. Also wire up Gnd and Power to Gnd & VTref on JLINK
# 0c. And separately supply power to device
# 0d. Iif you don't have openocd installed, then "brew install openocd"
#
# 1. Put this file in a directory
# 2. Get a samd21 bootloader file.bin and put it in this directory renamed as "bootloader.bin"
# 3. Unplug and replug in the JLINK (to reset it)
# 4. Then do "openocd -f ./openocd-sams21.cfg" and stand back
source [find interface/jlink.cfg]
transport select swd
source [find target/at91samdXX.cfg]
init
reset
halt
program bootloader.bin verify reset
shutdown
@celem
Copy link

celem commented Jan 5, 2025

Thanks. The link now works. Too bad that its content has an important dead link that points to https://roamingthings.de/posts/use-j-link-to-change-the-boot-loader-protection-of-a-sam-d21/. Fortunately, the relevant info of the now dead site was extracted and listed in the Hackaday site.

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