Skip to content

Instantly share code, notes, and snippets.

@cfillion
Last active December 12, 2023 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfillion/cec50994905203a429f276f7a56822a3 to your computer and use it in GitHub Desktop.
Save cfillion/cec50994905203a429f276f7a56822a3 to your computer and use it in GitHub Desktop.
OpenOCD script for LPC546xx via MCU-Link2 (w/o flash support)
set CHIPNAME LPC546xx
set CPUTAPID 0x10CAA02B
adapter driver cmsis-dap
transport select swd
adapter speed 3000
# gdb_memory_map enable
# gdb_flash_program enable
swd newdap $CHIPNAME cpu -irlen 4 -expected-id $CPUTAPID
dap create $CHIPNAME.dap -chain-position $CHIPNAME.cpu
target create $CHIPNAME.cpu cortex_m -dap $CHIPNAME.dap
cortex_m reset_config sysresetreq
$CHIPNAME.cpu configure -rtos auto -work-area-backup 1 \
-work-area-phys 0x04000000 -work-area-size 0x8000
# Un-remap the first 512 bytes from the boot ROM to the flash
# The first register in the SYSCON space is SYSMEMREMAP (undocumented).
# It is described in the manuals of other LPC chips such as the LPC845.
# 0x0 = Boot ROM, 0x1 = User RAM, User Flash = 0x2
$CHIPNAME.cpu configure -event reset-init {
mww 0x40000000 0x2
}
init
# program file.elf preverify verify reset exit
# dump_image filename address size
# profile
# reset halt
# reset init
# reset run
# https://github.com/pyocd/pyOCD/blob/5ab5c327987c4c3ba5a37928cac25263d4db7586/pyocd/target/builtin/target_LPC54608J512ET180.py
# https://community.nxp.com/t5/LPC-Microcontrollers/What-s-the-role-of-the-memory-address-0x4000-0000-on-the/m-p/960635
# https://dlbeer.co.nz/articles/lpc54113_openocd/index.html
# https://visualgdb.com/tutorials/arm/imxrt/flash/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment