Close

openocd flash script

A project log for SAMD V2 Fusee Payload Injector

A mini SAMD21 board with CR2032 backpack. Can be used for fusee gelee or other DIY projects

electronrancherelectronrancher 08/11/2018 at 03:532 Comments

Turns out, openocd is hard for people to use!   It's true that it has a billion obscure options, but once you've gone through the pain of using it on a few chips, it just makes sense!

I wanted to add my flashing script (openocd.cfg) here to show an example of a working setup using openocd 0.10 and an STM32 Blue Pill flashed to the CMSIS-DAP firmware.  This is what I use to do the initial flash on my boards. 

My bin file contains both the UF2 bootloader as well as a fimware, but it's really only necessary to use openocd to flash the bootloader on a fresh chip.  After UF2 is on there, you can use USB to drag and drop firmware on very easily.  However, it saves a step for me if I flash both of them at once so that's the way I do it. 

As for how you merge the bootloader and firmware into a single bin file?  Don't ask, it's a bit messy.  If you want this bin file just PM me.  Cheers!

interface cmsis-dap
transport select swd
#Target
set CHIPNAME at91samd21e18
source [find target/at91samdXX2.cfg]
#source [find target/stm32f1x.cfg]

init
targets
reset halt
at91samd chip-erase
reset halt
at91samd bootloader 0
program D:/projects/SAMD_Loader/Firmware/all.bin verify
at91samd bootloader 8192
reset
shutdown

Discussions

electronrancher wrote 06/29/2019 at 11:17 point

if you dont want to use UF2 life is even easier - just flash the chip with firmware, no need to splice or to even use a bootloader at all!  Bootloader is just to make reprogramming easy.

  Are you sure? yes | no

Amos Manneschmidt wrote 06/29/2019 at 04:23 point

What if I didn’t want to use UF2 because my board has no USB port on it? Do you think the firmware + boot loader splicing technique would work for other bootloaders?

  Are you sure? yes | no