From 2f4200a01b39af20d05c62aa3aad926963aa51ca Mon Sep 17 00:00:00 2001 From: Jacques Supcik Date: Wed, 30 Dec 2020 00:19:41 -0800 Subject: [PATCH] Add support for additional openocd commands (#1492) main: add ability to define specific OpenOCD commands to be executed for a target. --- compileopts/config.go | 3 +++ compileopts/target.go | 1 + targets/bluepill-clone.json | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 targets/bluepill-clone.json diff --git a/compileopts/config.go b/compileopts/config.go index 25b3ad1d..2803d164 100644 --- a/compileopts/config.go +++ b/compileopts/config.go @@ -303,6 +303,9 @@ func (c *Config) OpenOCDConfiguration() (args []string, err error) { return nil, fmt.Errorf("unknown OpenOCD transport: %#v", c.Target.OpenOCDTransport) } args = []string{"-f", "interface/" + openocdInterface + ".cfg"} + for _, cmd := range c.Target.OpenOCDCommands { + args = append(args, "-c", cmd) + } if c.Target.OpenOCDTransport != "" { args = append(args, "-c", "transport select "+c.Target.OpenOCDTransport) } diff --git a/compileopts/target.go b/compileopts/target.go index 8b3c68fc..6ca0a0fc 100644 --- a/compileopts/target.go +++ b/compileopts/target.go @@ -52,6 +52,7 @@ type TargetSpec struct { OpenOCDInterface string `json:"openocd-interface"` OpenOCDTarget string `json:"openocd-target"` OpenOCDTransport string `json:"openocd-transport"` + OpenOCDCommands []string `json:"openocd-commands"` JLinkDevice string `json:"jlink-device"` CodeModel string `json:"code-model"` RelocationModel string `json:"relocation-model"` diff --git a/targets/bluepill-clone.json b/targets/bluepill-clone.json new file mode 100644 index 00000000..843a2127 --- /dev/null +++ b/targets/bluepill-clone.json @@ -0,0 +1,4 @@ +{ + "inherits": ["bluepill"], + "openocd-commands": ["set CPUTAPID 0x2ba01477"] +}