Skip to content

Commit

Permalink
added script for demonstrating how to flash with openocd
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge authored and AlkaMotors committed Sep 10, 2024
1 parent aeab1cb commit b5b73ca
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tools/scripts/flash_firmware.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# an openocd config file for flashing both bootloader and main firmware for AM32
# This assumes you have a bootloader image in bl.bin and a main firmware in fw.bin
# this script may be useful as part of a production line testing system

# first off uncomment for the type of debug adapter you have
source [find interface/stlink.cfg]
#source [find interface/cmsis-dap.cfg]
#source [find interface/jlink.cfg]

# now uncomment the right line for which MCU your ESC uses
#source [find target/stm32f0x.cfg] # for F031 or F051
#source [find target/at32f415xx.cfg]
#source [find target/at32f421xx.cfg]
#source [find target/gd32e23x.cfg] # for E230
#source [find target/stm32g0x.cfg]
source [find target/stm32l4x.cfg]

# initialise
init
halt

# now erase all of flash
echo "erasing"
flash erase_sector 0 0 last

# now flash the bootloader, just comment out these lines if you don't
# want to flash the bootloader
echo "Flashing bootloader"
flash write_bank 0 bl.bin 0x0
flash verify_bank 0 bl.bin 0x0

# now flash and verify the main firmware
echo "Flashing main firmware"
flash write_bank 0 fw.bin 0x1000
flash verify_bank 0 fw.bin 0x1000

echo "Success!"
exit

0 comments on commit b5b73ca

Please sign in to comment.