Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Command failed with status SwdApFault #362

Closed
MorganTechngs opened this issue Nov 9, 2022 · 2 comments
Closed

Command failed with status SwdApFault #362

MorganTechngs opened this issue Nov 9, 2022 · 2 comments
Labels
type: bug Something isn't working

Comments

@MorganTechngs
Copy link

MorganTechngs commented Nov 9, 2022

Describe the bug
Attempting to probe-run and flash a STM32WL55JC1 returns a variety of errors with the probe connection.

To Reproduce

$ probe-run --chip STM32WL55JCIx --verbose
$ # or
$ cargo-flash --chip STM32WL55JCIx

Example
This was run using standard stm32-hal quickstart main and files. Also tried empty main and that gave the same errors.

config.toml

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# Change this runner as required for your MCU.
runner = "probe-run --verbose --chip STM32WL55JCIx" # to list chips, run `probe-run --list-chips.`
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]
# Change this target as required for your MCU.
target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7a (eg F, L4, H7)
#target = "thumbv6m-none-eabi"    # Cortex-M0 and Cortex-M0+ (eg G)
# target = "thumbv8m.main-none-eabihf" # Cortex-M33F and Cortex-M35F (eg L5, U5)

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

Have also tried with and without flip-link, defmt, and nmagic but no difference.

cargo.toml

[package]
authors = ["Your name <your@em.ail>"]
name = "project_name"
edition = "2021"
version = "0.1.0"

[dependencies]
defmt = "0.3.0"
defmt-rtt = "0.3.0"
panic-probe = { version = "0.3.0", features = ["print-defmt"] }

cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"

# Change this import as required for your MCU.
stm32-hal2 = { version = "^1.4.5", features = ["wle5", "wlrt"]}
# stm32-hal2 = { version = "^1.3.3", features = ["h743v", "h7rt"]}

# Peripheral access crate
# stm32wl = { version = "0.15.1", optional = true }

# cargo build/run
[profile.dev]
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = 3 # <-
overflow-checks = true # <-

# cargo test
[profile.test]
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = 3 # <-
overflow-checks = true # <-

# cargo build/run --release
[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = 3 # <-
overflow-checks = false # <-

# cargo test --release
[profile.bench]
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = 3 # <-
overflow-checks = false # <-

────────────────────────────────────────────────────────────────────────────────
Response of probe-run:

warning: `project_name` (bin "project_name") generated 3 warnings
    Finished release [optimized + debuginfo] target(s) in 22.93s
     Running `probe-run --verbose --chip STM32WL55JCIx target/thumbv7em-none-eabihf/release/project_name`
(HOST) DEBUG vector table: VectorTable { initial_stack_pointer: 20008000, hard_fault: 8000525 }
└─ probe_run::elf @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/elf.rs:31
(HOST) DEBUG RAM region: 0x20000000-0x2000FFFF
└─ probe_run::target_info @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/target_info.rs:115
(HOST) DEBUG section `.bss` is in RAM at 0x20000000..=0x20000003
└─ probe_run::target_info @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/target_info.rs:153
(HOST) DEBUG valid SP range: 0x20000004..=0x20007FFC
└─ probe_run::target_info @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/target_info.rs:167
(HOST) DEBUG found 1 probes
└─ probe_run::probe @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/probe.rs:25
(HOST) DEBUG opened probe
└─ probe_run::probe @ /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-run-0.3.5/src/probe.rs:33
Error: An error with the usage of the probe occurred

Caused by:
    0: An error specific to a probe type occurred
    1: Command failed with status SwdApFault

Running using connect-under-reset gives the same error or occasionally SwdApWait status.

Problem was originally #27 but through some resets and restarts its now moved to SwdApWait or SwdApFault response each time.

$ RUST_LOG=probe_rs=debug probe-rs-cli info
 DEBUG probe_rs::probe::cmsisdap::tools > Searching for CMSIS-DAP probes using libusb
 DEBUG probe_rs::probe::cmsisdap::tools > Found 0 CMSIS-DAP probes using libusb, searching HID
 DEBUG probe_rs::probe::cmsisdap::tools > Found 0 CMSIS-DAP probes total
 DEBUG probe_rs::probe::cmsisdap::tools > Attempting to open 0483:3754 in CMSIS-DAP v1 mode
 DEBUG probe_rs::probe::stlink::usb_interface > Acquired libusb context.
 DEBUG probe_rs::probe::stlink::usb_interface > Aquired handle for probe
 DEBUG probe_rs::probe::stlink::usb_interface > Active config descriptor: ConfigDescriptor { bLength: 9, bDescriptorType: 2, wTotalLength: 105, bNumInterfaces: 3, bConfigurationValue: 1, iConfiguration: 4, bmAttributes: 128, bMaxPower: 250, extra: [] }
 DEBUG probe_rs::probe::stlink::usb_interface > Device descriptor: DeviceDescriptor { bLength: 18, bDescriptorType: 1, bcdUSB: 512, bDeviceClass: 239, bDeviceSubClass: 2, bDeviceProtocol: 1, bMaxPacketSize: 64, idVendor: 1155, idProduct: 14164, bcdDevice: 256, iManufacturer: 1, iProduct: 2, iSerialNumber: 3, bNumConfigurations: 1 }
 DEBUG probe_rs::probe::stlink::usb_interface > Claimed interface 0 of USB device.
 DEBUG probe_rs::probe::stlink::usb_interface > Succesfully attached to STLink.
 DEBUG probe_rs::probe::stlink                > Initializing STLink...
 DEBUG probe_rs::probe::stlink                > Current device mode: Jtag
 DEBUG probe_rs::probe::stlink                > STLink version: (3, 10)
 DEBUG probe_rs::probe::stlink                > attach(Jtag)
 DEBUG probe_rs::probe::stlink                > Current device mode: Jtag
 DEBUG probe_rs::probe::stlink                > Switching protocol to JTAG
 INFO  probe_rs::probe::stlink                > Target voltage (VAPP): 3.26 V
 DEBUG probe_rs::probe::stlink                > Successfully initialized SWD.
 DEBUG probe_rs::architecture::arm::ap        > Reading register IDR
 DEBUG probe_rs::probe::stlink                > Opening AP 0
 DEBUG probe_rs::architecture::arm::ap        > Read register    IDR, value=0x24770011
 DEBUG probe_rs::architecture::arm::ap        > Reading register IDR
 DEBUG probe_rs::probe::stlink                > Opening AP 1
 DEBUG probe_rs::architecture::arm::ap        > Read register    IDR, value=0x84770001
 DEBUG probe_rs::architecture::arm::ap        > Reading register IDR
 DEBUG probe_rs::probe::stlink                > Opening AP 2
 DEBUG probe_rs::architecture::arm::ap        > Read register    IDR, value=0x0
 DEBUG probe_rs::architecture::arm::ap        > Reading register IDR
 DEBUG probe_rs::architecture::arm::ap        > Read register    IDR, value=0x24770011
 DEBUG probe_rs::architecture::arm::ap        > Reading register BASE
 DEBUG probe_rs::architecture::arm::ap        > Read register    BASE, value=0xe00ff003
 DEBUG probe_rs::architecture::arm::ap        > Reading register BASE2
 DEBUG probe_rs::architecture::arm::ap        > Read register    BASE2, value=0x0
 DEBUG probe_rs::architecture::arm::ap        > Reading register CSW
 DEBUG probe_rs::architecture::arm::ap        > Read register    CSW, value=0x23000052
 DEBUG probe_rs::architecture::arm::ap        > Writing register CSW, value=CSW { DbgSwEnable: 1, HNONSEC: 1, PROT: 6, CACHE: 3, SPIDEN: 0, _RES0: 0, MTE: 0, Type: 0, Mode: 0, TrinProg: 0, DeviceEn: 0, AddrInc: Single, _RES1: 0, SIZE: U8 }
 DEBUG probe_rs::architecture::arm::ap        > Reading register CSW
 DEBUG probe_rs::architecture::arm::ap        > Read register    CSW, value=0x23000050
 DEBUG probe_rs::architecture::arm::ap        > Writing register CSW, value=CSW { DbgSwEnable: 0, HNONSEC: 0, PROT: 2, CACHE: 3, SPIDEN: 0, _RES0: 0, MTE: 0, Type: 0, Mode: 0, TrinProg: 0, DeviceEn: 1, AddrInc: Single, _RES1: 0, SIZE: U32 }
 DEBUG probe_rs::architecture::arm::communication_interface > HNONSEC supported: false
 DEBUG probe_rs::architecture::arm::ap                      > Reading register CFG
 DEBUG probe_rs::architecture::arm::ap                      > Read register    CFG, value=0x0
 DEBUG probe_rs::probe::stlink                              > AP ApAddress {
    dp: Default,
    ap: 0x0,
}: MemoryAp(MemoryApInformation { address: ApAddress { dp: Default, ap: 0 }, only_32bit_data_size: false, debug_base_address: 3759140864, supports_hnonsec: false, has_large_address_extension: false, has_large_data_extension: false })
 DEBUG probe_rs::architecture::arm::ap                      > Reading register IDR
 DEBUG probe_rs::architecture::arm::ap                      > Read register    IDR, value=0x84770001
 DEBUG probe_rs::architecture::arm::ap                      > Reading register BASE
 DEBUG probe_rs::architecture::arm::ap                      > Read register    BASE, value=0xf0000003
 DEBUG probe_rs::architecture::arm::ap                      > Reading register BASE2
 DEBUG probe_rs::architecture::arm::ap                      > Read register    BASE2, value=0x0
 DEBUG probe_rs::architecture::arm::ap                      > Reading register CSW
 DEBUG probe_rs::architecture::arm::ap                      > Read register    CSW, value=0x438000d2
 DEBUG probe_rs::architecture::arm::ap                      > Writing register CSW, value=CSW { DbgSwEnable: 1, HNONSEC: 1, PROT: 6, CACHE: 3, SPIDEN: 0, _RES0: 0, MTE: 0, Type: 0, Mode: 0, TrinProg: 0, DeviceEn: 0, AddrInc: Single, _RES1: 0, SIZE: U8 }
 DEBUG probe_rs::architecture::arm::ap                      > Reading register CSW
 WARN  probe_rs::probe::stlink                              > send_jtag_command 242 failed: SwdApFault
 DEBUG probe_rs::probe::stlink                              > Current device mode: Jtag
thread 'main' panicked at 'This should not be an unwrap...: Probe(ProbeSpecific(CommandFailed(SwdApFault)))', /Users/morgan/.cargo/registry/src/github.com-1ecc6299db9ec823/probe-rs-cli-0.13.0/src/info.rs:74:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is using STLinkV3 built into the development WL55JC1 board. Programming using STM32CUBE is possible and works fine.

morgan:stm32-nucleo/ (main*) $ probe-rs-cli list                     [16:46:07]
The following devices were found:
[0]: STLink V3 (VID: 0483, PID: 3754, Serial: 0009002E4D46501720383832, StLink)

Any help would be appreciated!

@Urhengulas
Copy link
Member

Urhengulas commented Dec 9, 2022

Thank you for your report. Since the issue also occurs with cargo-flash and probe-rs-cli I'd assume this is an issue in the probe-rs library.

Can you please report the issue there (https://github.com/probe-rs/probe-rs) and link to this is here?

@seanybaggins
Copy link

In your binary, does your main loop have asm::wfti(). I managed to get rid of this problem by commenting out that line. Hope that helps someone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants