knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
646 stars 75 forks source link

Add support for EFM32TG11B family #376

Open n8tlarsen opened 1 year ago

n8tlarsen commented 1 year ago

Describe the bug I'm trying to add support for the EFM32TG11B family of MCUs, and have successfully built a local version on probe-rs and probe-run which include the yaml configurations. However, when connecting to the target device using probe-run I get errors after flashing the code completes. I'm able to flash the code using cargo-flash, then connect to the device using openOCD and GDB and debug without issue. I've also reported this on probe-rs/probe-rs.

To Reproduce Compile probe-run v0.3.6 patched with probe-rs v0.14.2 and the attached EFM32TG11B_Series.yaml.txt. Enter the project directory and execute cargo run while the debug probe and target device are connected and powered.

Expected and observed behavior I expected to see a backtrace but instead, the cargo run command produced the following error:

    Finished dev [optimized + debuginfo] target(s) in 0.04s
     Running `probe-run --chip EFM32TG11B120F128GM64 target/thumbv6m-none-eabi/debug/un200`
(HOST) INFO  flashing program (8 pages / 8.00 KiB)
(HOST) INFO  success!
Error: Error communicating with probe: A ARM specific error occured.

Caused by:
    0: A ARM specific error occured.
    1: Error using access port
    2: Failed to write register CSW at address 0x00000000
    3: An error occured in the communication with an access port or debug port.
    4: Target device responded with a FAULT response to the request.

config.toml

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-run --chip EFM32TG11B120F128GM64"
# runner = "arm-none-eabi-gdb -x openocd.gdb"
rustflags = [
  "-C", "linker=flip-link",
  "-C", "link-arg=-Tlink.x",
  "-C", "link-arg=-Tdefmt.x",
  # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
  # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
  "-C", "link-arg=--nmagic",
]

[build]
target = "thumbv6m-none-eabi"    # Cortex-M0 and Cortex-M0+
# target = "thumbv7m-none-eabi"    # Cortex-M3
# target = "thumbv7em-none-eabi"   # Cortex-M4 and Cortex-M7 (no FPU)
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

[alias]
rb = "run --bin"
rrb = "run --release --bin"

Probe details

$ probe-rs-cli list
The following devices were found:
[0]: J-Link (J-Link) (VID: 1366, PID: 0101, Serial: 000051013408, JLink)

Operating System: Ubuntu 22.04.1 LTS on WSL2 in Windows 11

Additional context My target device is an EFM32TG11B120F128GM64 deployed on a custom PCB which I have previously tested extensively with C code, J-Link tools, openOCD and GDB.

Urhengulas commented 1 year ago

Hi @n8tlarsen, Thank you for your report. I don't think we can do anything about this on the probe-run side, but I think that this needs to be fixed in probe-rs.