<Jonas[m]1>
I now have an Adafruit SWD breakout board, that I want to use to program an Adafruit nRF52840 feather express. I already have an Raspberry Pi Pico board that I used to program another Raspberry Pi Pico using probe-rs run. From the Pico I had three jumper wires to SWD: SWDIO, SWCLK and RESET. As how I have understood it now, I can use this Pico and connect the jumper wires to the SWD breakout board instead. But how should I connect
<Jonas[m]1>
the jumper wires? The breakout board has pins for SWIO, SWO, CLK, RESET, and I should probably also connect GND and Vcc. What pins do I need to connect on the breakout board and how? Perhaps I have totally misunderstood something? :D https://www.adafruit.com/product/2743
<dirbaio[m]>
Jonas[m]1: bare minimum is swdio, swclk, gnd
<dirbaio[m]>
dirbaio[m]: you only need reset if you want to do pin resets. probe-rs doesn't use it, it resets via swd instead
<dirbaio[m]>
dirbaio[m]: you only need vcc if you want to power the target from the probe.
<dirbaio[m]>
dirbaio[m]: if you're already powering the target independently you should *not* connect it
JonathanDickinso has joined #rust-embedded
<JonathanDickinso>
I noticed that the I2C is not resetting between write and read for write_read (it really should according to spec), or am I reading the code incorrectly?
<Jonas[m]1>
<dirbaio[m]> "if you're already powering the..." <- I clearly did something very wrong 🤣 When doing `cargo run` I got this message `Error: No loadable ELF sections were found.` and I could smell something burned, the nrf board become very hot, and I disconnected 😢
crabbedhaloablut has joined #rust-embedded
<Jonas[m]1>
<Jonas[m]1> "I clearly did something very..." <- I should probably not power the board over the breakout board. But it is hard to understand what I did so wrong so that it get very hot 🔥
<Jonas[m]1>
Jonas[m]1: Ah, maybe.... Pico VBUS is probably 5V, and I should probably power only with 3V over the SWD. My mistake. But now I understand.
<dirbaio[m]>
Jonas[m]1: oof
crabbedhaloablut has quit [Client Quit]
<Jonas[m]1>
dirbaio[m]: I now only changed to 3V ... things look Ok and no smoke. But I get the same error from probe-run. I need to double check my memory.x file, I think.
<Jonas[m]1>
Jonas[m]1: The board is blinking, because it runs what was loaded from factory. So the chip should have survived, I hope.
<Jonas[m]1>
This is my memory.x now: MEMORY { FLASH : ORIGIN = 0x26000, LENGTH = 796K RAM : ORIGIN = 0x20000008, LENGTH = 256K }
<Jonas[m]1>
dirbaio[m]: nope, I have never heard about that file. I have only done rp2040 work before.
<Jonas[m]1>
Jonas[m]1: What is `build.rs` is that some alternative to cargo?
<Jonas[m]1>
Jonas[m]1: My `.cargo/config.toml` only has "target" and "runner".
<Jonas[m]1>
Jonas[m]1: This is the initial tutorial that I followed, because there is not much tutorials/documentations for Rust + nRF52840.... and then I learned that the HAL was stale, so I tried the HAL in embassy that seem to have little to no documentation for non-async things. https://nitschinger.at/Getting-Started-with-the-nRF52840-in-Rust/
<Jonas[m]1>
<Jonas[m]1> "This is the initial tutorial..." <- By reading your link dirbaio it looks like I should create a `build.rs` file when working with Embassy. But from where should I get the files?
<dirbaio[m]>
Jonas[m]1: the `build.rs` way is not embassy-specific, it applies to all embedded rust
<dirbaio[m]>
dirbaio[m]: the generic cortex-m quickstart also uses it
<Jonas[m]1>
dirbaio[m]: that explains everything. Thanks!
<Jonas[m]1>
<Jonas[m]1> "that explains everything. Thanks..." <- I copy pasted the `build.rs` and put it outside the `src` directory. Then `cargo run` and now I get linking errors instead. So it is a step further.
<Jonas[m]1>
`note: rust-lld: warning: section type mismatch for .uninit.defmt-rtt.BUFFER`
<Jonas[m]1>
Jonas[m]1: Perhaps there are any docs or tutorials I can follow for this?
<Jonas[m]1>
Jonas[m]1: > <@jlpettersson:matrix.org> I copy pasted the `build.rs` and put it outside the `src` directory. Then `cargo run` and now I get linking errors instead. So it is a step further.
<Jonas[m]1>
> `note: rust-lld: warning: section type mismatch for .uninit.defmt-rtt.BUFFER`
<Jonas[m]1>
the linking error message is big. It is also about "critical-section thing".
<dirbaio[m]>
Jonas[m]1: > <@jlpettersson:matrix.org> I copy pasted the `build.rs` and put it outside the `src` directory. Then `cargo run` and now I get linking errors instead. So it is a step further.
<dirbaio[m]>
these are warnings, you can ignore them
<dirbaio[m]>
> `note: rust-lld: warning: section type mismatch for .uninit.defmt-rtt.BUFFER`
<dirbaio[m]>
dirbaio[m]: to fix the critical-section stuff, enable feature `critical-section-single-core` for `cortex-m` in your `Cargo.toml`
<Jonas[m]1>
dirbaio[m]: Thanks. Now it flashes the program!!
<Jonas[m]1>
But I have probably configured wrong address for RAM, I got (HOST) WARN no RAM region appears to contain the stack; probe-run can't determine if this was a stack overflow stack backtrace: 0: HardFaultTrampoline
<Jonas[m]1>
Jonas[m]1: but it does not blink, I need to check my source code 😀 Thanks a lot so far!
<Jonas[m]1>
Jonas[m]1: My program starts with ` defmt::info!("Hello, World!");` ....but I see no logs. Hmm.
<Jonas[m]1>
Jonas[m]1: I have this line in my program, but it does not seem to help: `use defmt_rtt as _; // global logger`
<Jonas[m]1>
Jonas[m]1: and two related deps `defmt = "0.3.5"
<Jonas[m]1>
defmt-rtt = "0.4.0"`
<Jonas[m]1>
<Jonas[m]1> "and two related deps `defmt = "0..." <- I now added `[env]
<Jonas[m]1>
DEFMT_LOG = "debug"` to my `.cargo/config.toml` but it did not help.
vancz has quit []
vancz has joined #rust-embedded
<dirbaio[m]>
<Jonas[m]1> "I now added `[env]..." <- > <@jlpettersson:matrix.org> I now added `[env]
<dirbaio[m]>
Cargo has a bug where `[env]` doesn't trigger rebuild when it should
<dirbaio[m]>
> DEFMT_LOG = "debug"` to my `.cargo/config.toml` but it did not help.
<dirbaio[m]>
dirbaio[m]: do `rm -rf target` and try AGAIN
<dirbaio[m]>
s/AGAIN/again/
<Jonas[m]1>
<dirbaio[m]> "do `rm -rf target` and try AGAIN" <- Thanks! That fixed it!! I now get logging when running! I am just missing the blinking, but I need to double check my pins, will do that tomorrow! Thanks a lot!
<Jonas[m]1>
<Jonas[m]1> "Thanks! That fixed it!! I now..." <- I changed the pin in my code to `p.P1_10` and now it is also blinking! So finally a successful blink-program :)
Guest7221 has left #rust-embedded [Error from remote client]