From 13e6bded6fbf02ad4e73a54fbfb196d3168a90d1 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Mon, 25 Mar 2024 00:46:38 +0000 Subject: [PATCH] cargo embed doesn't like lpc1114 or tigard, just use openocd --- flake.nix | 3 +- rust-embedded/lpc1114-test/.cargo/config.toml | 2 +- rust-embedded/lpc1114-test/Embed.toml | 82 ------------------- rust-embedded/lpc1114-test/openocd.cfg | 6 ++ rust-embedded/lpc1114-test/openocd.gdb | 14 ++++ 5 files changed, 23 insertions(+), 84 deletions(-) delete mode 100644 rust-embedded/lpc1114-test/Embed.toml create mode 100644 rust-embedded/lpc1114-test/openocd.cfg create mode 100644 rust-embedded/lpc1114-test/openocd.gdb diff --git a/flake.nix b/flake.nix index 24c2a41..67c9f6d 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,8 @@ }; in with pkgs; mkShell { - packages = [ rust cargo-binutils probe-rs cargo-generate gdb ]; + packages = + [ rust cargo-binutils probe-rs cargo-generate gdb openocd ]; RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library"; }; diff --git a/rust-embedded/lpc1114-test/.cargo/config.toml b/rust-embedded/lpc1114-test/.cargo/config.toml index 996b04a..dcff259 100644 --- a/rust-embedded/lpc1114-test/.cargo/config.toml +++ b/rust-embedded/lpc1114-test/.cargo/config.toml @@ -1,5 +1,5 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = "probe-rs run --chip Cortex-M0" +runner = "gdb -x openocd.gdb" rustflags = [ "-C", "link-arg=-Tlink.x", diff --git a/rust-embedded/lpc1114-test/Embed.toml b/rust-embedded/lpc1114-test/Embed.toml deleted file mode 100644 index e8d3632..0000000 --- a/rust-embedded/lpc1114-test/Embed.toml +++ /dev/null @@ -1,82 +0,0 @@ -[default.probe] -# USB vendor ID -# usb_vid = "1337" -# USB product ID -# usb_pid = "1337" -# Serial number -# serial = "12345678" -# The protocol to be used for communicating with the target. -protocol = "Swd" -# The speed in kHz of the data link to the target. -# speed = 1337 - -[default.flashing] -# Whether or not the target should be flashed. -enabled = true -# Whether or not the target should be halted after reset. -# DEPRECATED, moved to reset section -halt_afterwards = false -# Whether or not bytes erased but not rewritten with data from the ELF -# should be restored with their contents before erasing. -restore_unwritten_bytes = false -# The path where an SVG of the assembled flash layout should be written to. -# flash_layout_output_path = "out.svg" -# Triggers a full chip erase instead of a page by page erase. -do_chip_erase = false - -[default.reset] -# Whether or not the target should be reset. -# When flashing is enabled as well, the target will be reset after flashing. -enabled = true -# Whether or not the target should be halted after reset. -halt_afterwards = false - -[default.general] -# The chip name of the chip to be debugged. -chip = "Cortex-M0" -# A list of chip descriptions to be loaded during runtime. -chip_descriptions = [] -# The default log level to be used. Possible values are one of: -# "OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" -log_level = "WARN" -# Use this flag to assert the nreset & ntrst pins during attaching the probe to the chip. -connect_under_reset = false - -[default.rtt] -# Whether or not an RTTUI should be opened after flashing. -enabled = false -# How the target handles RTT outputs that won't fit in the buffer. This can be -# overridden per-channel. If left unset, the firmware will determine the default -# for each RTT up channel. -# NoBlockSkip - Skip writing the data completely if it doesn't fit in its -# entirety. -# NoBlockTrim - Write as much as possible of the data and ignore the rest. -# BlockIfFull - Spin until the host reads data. Can result in app freezing. -# -# up_mode = "BlockIfFull" - -# A list of channel associations to be displayed. If left empty, all channels are displayed. -# up, down (Optional) - RTT channel numbers -# name (Optional) - String to be displayed in the RTTUI tab -# up_mode (Optional) - RTT channel specific as described above -# format (Required) - How to interpret data from target firmware. One of: -# String - Directly show output from the target -# Defmt - Format output on the host, see https://defmt.ferrous-systems.com/ -# BinaryLE - Display as raw hex -channels = [ - # { up = 0, down = 0, name = "name", up_mode = "BlockIfFull", format = "Defmt" }, -] -# The duration in ms for which the logger should retry to attach to RTT. -timeout = 3000 -# Whether timestamps in the RTTUI are enabled -show_timestamps = true -# Whether to save rtt history buffer on exit. -log_enabled = false -# Where to save rtt history buffer relative to manifest path. -log_path = "./logs" - -[default.gdb] -# Whether or not a GDB server should be opened after flashing. -enabled = false -# The connection string in host:port format wher the GDB server will open a socket. -gdb_connection_string = "127.0.0.1:1337" diff --git a/rust-embedded/lpc1114-test/openocd.cfg b/rust-embedded/lpc1114-test/openocd.cfg new file mode 100644 index 0000000..c58820f --- /dev/null +++ b/rust-embedded/lpc1114-test/openocd.cfg @@ -0,0 +1,6 @@ +source [find interface/ftdi/tigard.cfg] +source [find interface/ftdi/swd-resistor-hack.cfg] +source [find target/lpc11xx.cfg] + +adapter speed 2000 +adapter_khz 13500 diff --git a/rust-embedded/lpc1114-test/openocd.gdb b/rust-embedded/lpc1114-test/openocd.gdb new file mode 100644 index 0000000..0422dfa --- /dev/null +++ b/rust-embedded/lpc1114-test/openocd.gdb @@ -0,0 +1,14 @@ +target extended-remote :3333 + +# print demangled symbols +set print asm-demangle on + +# detect unhandled exceptions, hard faults and panics +break DefaultHandler +break HardFault +break rust_begin_unwind + +monitor arm semihosting enable + +load +monitor reset