-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
flash-boot.ocd
41 lines (31 loc) · 1.36 KB
/
flash-boot.ocd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# This is an OpenOCD script that connects ST-Link or Raspberry Pi to the nRF52 and flashes the Bootloader ROM.
# Used by tasks.json for "Load Bootloader" command.
# Equivalent to "newt load -v nrf52_boot".
# From https://devzone.nordicsemi.com/f/nordic-q-a/42824/flashing-nrf5832-using-only-st-link-v2-and-openocd
gdb_flash_program enable
gdb_breakpoint_override hard
$_TARGETNAME configure -event reset-init {
# Arm Semihosting is used to show debug console output and may only be enabled after init event. We wait for the event and enable Arm Semihosting.
echo "Enabled ARM Semihosting to show debug output"
arm semihosting enable
}
# Connect to the device.
init
# Raspberry Pi fails with timeout when calling "reset halt" here, so we "reset" then "halt".
echo "Stopping..."
reset
halt
echo ""
# Bootloader address must sync with hw/bsp/nrf52/bsp.yml. For Stub Bootloader, select "bin/targets/nrf52_boot/app/apps/boot_stub/boot_stub.elf.bin"
echo "Flashing Bootloader..."
# For MCUBoot (debugging not supported):
program bin/targets/nrf52_boot/app/boot/mynewt/mynewt.elf.bin verify 0x00000000
# For Stub Bootloader (supports debugging):
# program bin/targets/nrf52_boot/app/apps/boot_stub/boot_stub.elf.bin verify 0x00000000
echo ""
# Restart the device and start the bootloader.
echo "Restarting..."
reset init
resume
echo ""
echo "**** Done! Press Ctrl-C to exit..."