Explorar o código

build: pc is set to _start after program load

Signed-off-by: Huaqi Fang <578567190@qq.com>
Huaqi Fang %!s(int64=3) %!d(string=hai) anos
pai
achega
3c0b6ca892
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      Build/Makefile.conf

+ 11 - 1
Build/Makefile.conf

@@ -62,9 +62,19 @@ GDB_UPLOAD_ARGS ?= --batch
 GDB_UPLOAD_CMDS += -ex "thread apply all monitor reset halt"
 # $$pc is for $pc in gdb, but need to do this in makefile
 # in command extra '\' is required
-GDB_UPLOAD_CMDS += -ex "thread apply all set \$$pc=_start"
+# please make sure the _start label is provided in your startup code
+# and is the entry of the startup of cpu
+GDB_UPLOAD_CMDS += -ex "thread apply all info reg pc"
 GDB_UPLOAD_CMDS += -ex "thread 1"
 GDB_UPLOAD_CMDS += -ex "load"
+# make sure pc is set to _start after load
+# when load program to flash, the cpu will do reset init
+# before flash erase and do reset halt after flash write end
+# so we need to manually set pc to _start
+# see https://openocd.org/doc/html/CPU-Configuration.html#Target-Events
+GDB_UPLOAD_CMDS += -ex "thread apply all set \$$pc=_start"
+GDB_UPLOAD_CMDS += -ex "thread apply all info reg pc"
+GDB_UPLOAD_CMDS += -ex "thread 1"
 GDB_UPLOAD_CMDS += -ex "monitor resume"
 GDB_UPLOAD_CMDS += -ex "quit"