ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
<re_irc> < (@antonok:antonok.com)> ok, I narrowed it down to a "UsbDeviceBuilder" call. In my case I'm resetting to bootloader past that point, but I think flashing onboard LEDs would work just as well. Works on stable but not nightly.
<re_irc> < (@antonok:antonok.com)> [dependencies]
<re_irc> embedded-hal = "^ 0.2.6"
<re_irc> stm32f4xx-hal = { version = "0.13", features = ["rt", "stm32f401", "usb_fs"] }
<re_irc> cortex-m = { version = "^ 0.7" }
<re_irc> < (@antonok:antonok.com)> aha, I'm not alone https://github.com/rust-embedded-community/usb-device/issues/110
<re_irc> < (@adamgreig:matrix.org)> weird, I wonder what's going on there then
<re_irc> < (@adamgreig:matrix.org)> btw, in cargo.toml the ^ is used by default if you don't specify anything else, so "0.13" is identical to "^0.13"
<re_irc> < (@adamgreig:matrix.org)> ah, sorry, threads somehow got turned off in my element settings?
<re_irc> < (@antonok:antonok.com)> hacknus seems to have narrowed it down to an issue with the AHB clock in "stm32f4xx-hal" in nightly, although I don't see any other reports
<re_irc> < (@adamgreig:matrix.org)> do you have a debugger attached? I wonder if you're also hanging on waiting for AHBIDL to be set
<re_irc> < (@antonok:antonok.com)> oh no there is one here https://github.com/stm32-rs/stm32f4xx-hal/issues/567
<re_irc> < (@antonok:antonok.com)> no debugger 😞
<re_irc> < (@antonok:antonok.com)> issue chain seems to end here: https://github.com/stm32-rs/synopsys-usb-otg/issues/33
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> < (@antonok:antonok.com)> ok I filed https://github.com/rust-lang/rust/issues/106830, let's see how that goes 🤞
<re_irc> < (@adamgreig:matrix.org)> I don't know that rust-lang will be able to do anything with it yet, there's no details on how this is a compiler regression as such
<re_irc> < (@adamgreig:matrix.org)> I've got it reproducing here exactly as you and hacknus describe, though
<re_irc> < (@adamgreig:matrix.org)> the bit it's trying to read is indeed set in memory so what's going on ...
<re_irc> < (@adamgreig:matrix.org)> looks like it's a bug in the synopsys-otg-usb crate rather than rust-lang, if you see any commits in the nightly range you're bisecting around struct (re)ordering that's probably it
<re_irc> <dngrs (spookyvision@{github,cohost})> Gnarly
<re_irc> <dngrs (spookyvision@{github,cohost})> nice find!
<re_irc> <dngrs (spookyvision@{github,cohost})> Next step: aggressively randomize layout wherever allowed to fuzz other crates
<re_irc> < (@adamgreig:matrix.org)> suspicious of https://github.com/rust-lang/rust/pull/102750
<re_irc> < (@antonok:antonok.com)> yeah that looks about right
<re_irc> < (@adamgreig:matrix.org)> I guess it's in the release notes and all
<re_irc> < (@adamgreig:matrix.org)> just pulling this out of the stm32 usb thread: https://github.com/rust-lang/rust/pull/102750 means rustc is finally changing around struct ordering, and if you look at all the linked issues you can see everyone having fun with this change, check yo crates for structs that should be "repr(C)"
<re_irc> < (@adamgreig:matrix.org)> -and if you look at all the linked issues you can see everyone having fun with this change,
<re_irc> < (@jamesmunns:beeper.com)> dngrs (spookyvision@{github,cohost}): Theres an unstable flag for this, let me find it
<re_irc> < (@jamesmunns:beeper.com)> https://github.com/rust-lang/rust/issues/106764
<re_irc> "-Z randomize-layout"
<re_irc> < (@jamesmunns:beeper.com)> (wouldn't have helped here, as adam reminded me, but would be good for testing or miri testing)
<re_irc> < (@adamgreig:matrix.org)> well, thanks for reporting ! good to get these things fixed, especially before it hits rust stable
<re_irc> < (@antonok:antonok.com)> likewise, thanks for your help identifying and fixing this 🚀
<re_irc> <dngrs (spookyvision@{github,cohost})> : ah yeah, now I remember
bjc has left #rust-embedded [ERC 5.4 (IRC client for GNU Emacs 28.2)]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> Great write up on doing Embedded graphics on an ESP32
<re_irc> < (@omar_u8:matrix.org)> thejpster: Great stuff, thanks for sharing!
IlPalazzo-ojiisa has joined #rust-embedded
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
jr-oss_ has quit [Ping timeout: 265 seconds]
jr-oss has joined #rust-embedded
richardeoin has quit [Ping timeout: 260 seconds]
dc740 has joined #rust-embedded
dc740 has quit [Remote host closed the connection]
dc740 has joined #rust-embedded
jr-oss has quit [Ping timeout: 260 seconds]
jr-oss has joined #rust-embedded
richardeoin has joined #rust-embedded
richardeoin has quit [Ping timeout: 252 seconds]
<re_irc> <Félix | Totem> Hey, this guy talks about an alternate way to matrix scan: https://summivox.wordpress.com/2016/06/03/keyboard-matrix-scanning-and-debouncing/ but I don't understand a thing. I wonder how hard it is to do what they talk about.
<re_irc> <Félix | Totem> Also, it uses a Direct memory access, not sure if it's handled by stm32-rs and RTIC
<re_irc> < (@k900:0upti.me)> This is extreme levels of overengineering tbh
<re_irc> < (@k900:0upti.me)> DMA is a very sharp tool
<re_irc> < (@k900:0upti.me)> This is not really a good use case for it
<re_irc> <Félix | Totem> Oh, alright, it's a hard pass, then. I sometimes like overengineering for the fun of it, but not in a field I'm new in 😛
richardeoin has joined #rust-embedded
crabbedhaloablut has quit [Write error: Connection reset by peer]
crabbedhaloablut has joined #rust-embedded
<re_irc> <Julia> Hello I am new to using Rust for embedded systems and am having trouble setting up a simple blinky program. I am working with an nrf51822 and have a st-link v2 programmer, however it seems that flashing doesn't work correctly. I hope this is the right place to ask for help 😅!
<re_irc> <thejpster> Which software are you using for flashing the nRF51?
<re_irc> <thejpster> I’m told that some ST Link programmers will only program ST Micro chips.
<re_irc> <Julia> So I'm not sure how it exactly works, but I just call "cargo embed --release".
<re_irc> <Julia> This contains my current attempt so far. However like I said it seems it might not actually flash correctly.
<re_irc> <henrik_alser> Julia: What output do you see?
<re_irc> <Julia> it clears and flashes, but then I get this:
<re_irc> - Make sure RTT is initialized on the target, AND that there are NO target breakpoints before RTT initalization.
<re_irc> Error Error attaching to RTT: RTT control block not found in target memory.
<re_irc> - For VSCode and probe-rs-debugger users, using `halt_after_reset:true` in your `launch.json` file will prevent RTT
<re_irc> < (@omar_u8:matrix.org)> Julia: I used to get this when the memory.x linker regions are not correct.
<re_irc> < (@omar_u8:matrix.org)> * "memory.x"
<re_irc> MEMORY
<re_irc> {
<re_irc> <Julia> So I took ones that were set by a TA of mine, which looks like this:
<re_irc> FLASH : ORIGIN = 0x18000, LENGTH = 0x28000
<re_irc> < (@omar_u8:matrix.org)> Yes you need to verify from the data sheet for the particular device you are using.
<re_irc> < (@omar_u8:matrix.org)> Flash region address looks odd though.
<re_irc> <Julia> I am _very_ new to reading these. I tried setting the flash origin to 0x0000_0000, but that didn't work - unless I made some other error of course.
<re_irc> < (@omar_u8:matrix.org)> According to this code starts at 0x00000000 but range is not specified.
<re_irc> <Julia> There should be 256kb memory and 16kb RAM
<re_irc> < (@omar_u8:matrix.org)> Took a quick look at the datasheet at it seems the size depends on the chip variant.
<re_irc> < (@omar_u8:matrix.org)> Well there is the option of 128K and 256K
<re_irc> < (@omar_u8:matrix.org)> Also with RAM theres 16kb and 32kb, again depending on chip variant.
<re_irc> < (@omar_u8:matrix.org)> If all checks out, it might be something else.
<re_irc> < (@omar_u8:matrix.org)> Well there is the option of 128K and 256K for flash.
<re_irc> <Julia> Yeah I checked that too, I have an xxAA variant
<re_irc> <Julia> so it should have 256kb and 16kb
<re_irc> < (@omar_u8:matrix.org)> Code region starts at 0x00000000 and RAM at 0x20000000
<re_irc> < (@omar_u8:matrix.org)> I think you have a different address for RAM
<re_irc> <Julia> The following setup gives me an error.
<re_irc> {
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 0x28000
<re_irc> MEMORY
<re_irc> < (@omar_u8:matrix.org)> Julia: Not sure, though by the way small tip I think you can do something like this if easier rather than using hex numbers: "LENGTH = 256K"
<re_irc> < (@omar_u8:matrix.org)> * way,
<re_irc> <henrik_alser> Julia: can you try erasing the whole flash with nrfutil?
<re_irc> MEMORY
<re_irc> <henrik_alser> I believe your memory.x should look like this if you’re not using softdevice
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 256K
<re_irc> {
<re_irc> <henrik_alser> Any difference if you try with probe-run?
<re_irc> <Julia> Okay this might stupid, but what are nrfutil and probe-run?
<re_irc> <Julia> +sound
<re_irc> <henrik_alser> Nrfutil is nrf’s cli tools for interacting with the chip, lets you do full chip erase etc
<re_irc> <henrik_alser> probe-run is https://github.com/knurling-rs/probe-run
<re_irc> <Julia> Would it be possible to enter voice chat possibly?
<re_irc> <henrik_alser> Btw the microbit v1 is the same chip, you could check the microbit crate for hints how to set it up
<re_irc> <Julia> MEMORY
<re_irc> {
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 256K
<re_irc> /* NOTE K = KiBi = 1024 bytes */
<re_irc> <Julia> MEMORY
<re_irc> /* NOTE K = KiBi = 1024 bytes */
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 256K
<re_irc> {
<re_irc> {
<re_irc> <Julia> MEMORY
<re_irc> /* NOTE K = KiBi = 1024 bytes */
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 256K
<re_irc> <Julia> I must be doing something wrong 😅.
<re_irc> <Félix | Totem> Julia: "./nrfutil"
<re_irc> <Félix | Totem> By default, the shell looked in the path to run a binary. "./" tells it's in the pwd.
<re_irc> <Félix | Totem> * looks
<re_irc> < (@dkhayes117:matrix.org)> What does your embed.toml look like?
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> <Julia> : [default.probe]
<re_irc> protocol = "Swd"
<re_irc> [default.flashing]
<re_irc> enabled = true
<re_irc> < (@omar_u8:matrix.org)> I'm running "bindgen" on C headers and for some reason certain defines are being skipped.
<re_irc> < (@omar_u8:matrix.org)> Like this one for example
<re_irc> < (@omar_u8:matrix.org)> "#define TIM10 ((TIM_TypeDef *) TIM10_BASE)"
<re_irc> < (@omar_u8:matrix.org)> Is there a way through the builder that I address that?
<re_irc> < (@omar_u8:matrix.org)> Also on a side note, what would that C code translate into in Rust?
<re_irc> < (@omar_u8:matrix.org)> Like this one for example:
<re_irc> < (@yatekii:matrix.org)> Julia: try adding
<re_irc> debug = true
<re_irc> to your `Cargo.toml``
<re_irc> [profile.release]
<re_irc> < (@yatekii:matrix.org)> * `Cargo.toml`
<re_irc> < (@yatekii:matrix.org)> * "Cargo.toml"
<re_irc> <Julia> : Same error as before.
<re_irc> < (@omar_u8:matrix.org)> Julia Reminds me of my early days trying to get the toolchain to work :) You might want to try with different tools until you get something going and then switch. One option I resort to typically is falling back on vendor setup/toolchain (nrf in your case) to flash the generated binary from elsewhere.
<re_irc> < (@omar_u8:matrix.org)> It gets easier at a certain point :-)
<re_irc> <Julia> It really sucks because I follow an embedded systems course, and instead of teaching us C/C++, they teach us Rust. However I haven't seen Rust actually run on any MCU so far :(.
<re_irc> < (@k900:0upti.me)> Does your course have a specific hardware target that it recommends?
<re_irc> <Julia> nrf51822
<re_irc> <Julia> We are supposed to make a control system for a drone using it next semester, which is why I wanted to get a headstart to see if I can get it working.
<re_irc> < (@k900:0upti.me)> That's just a chip, but any specific board?
<re_irc> <Julia> I don't know that yet.
<re_irc> < (@k900:0upti.me)> What board are you using right now?
<re_irc> <Julia> By board do you mean the thing I'm plugging it into? That'd be the BLE400.
<re_irc> < (@k900:0upti.me)> The nRF51822 is just the chip itself
<re_irc> < (@k900:0upti.me)> So presumably you have the official evaluation kit
<re_irc> <Julia> Yes.
<re_irc> < (@k900:0upti.me)> Does the debugger actually work? Can you verify it's connected correctly?
<re_irc> < (@adamgreig:matrix.org)> given as flash programming seems to have succeeded it seems like the stlink and connection is OK
<re_irc> <Julia> There are only 4 cables to connect and I checked multiple times that they are correct. Ubuntu also recognizes my programmer.
<re_irc> < (@adamgreig:matrix.org)> just something's wrong with what's being programmed that means it's not starting up (assuming it's not blinking as well as the RTT error)
<re_irc> < (@k900:0upti.me)> If the debugger works properly, you should be able to, well, debug your code
<re_irc> < (@k900:0upti.me)> As in step through it and see what it does
<re_irc> < (@k900:0upti.me)> And where (or if) it breaks
bjc has joined #rust-embedded
<re_irc> < (@dkhayes117:matrix.org)> Do you have a .cargo/config.toml file?
<re_irc> <Julia> Even the simplest program from https://github.com/rust-embedded/discovery (microbit/src/03-setup/) seems to break.
<re_irc> <Julia> : Yes.
<re_irc> < (@k900:0upti.me)> Julia: That's not really unexpected, the micro:bit hardware is slightly different
<re_irc> < (@dkhayes117:matrix.org)> Do have this flag set in config.toml
<re_irc> rustflags = [
<re_irc> ]
<re_irc> "-C", "link-arg=-Tlink.x",
<re_irc> < (@dkhayes117:matrix.org)> * "link-arg=--nmagic",
<re_irc> < (@dkhayes117:matrix.org)> sorry wrong flag, check for the nmagic one
<re_irc> <Julia> : Here is my current attempt, might save some time 😅.
<re_irc> <Julia> Also yes I did have that flag set, and it doesn't work with and without it.
<re_irc> < (@k900:0upti.me)> That memory layout does not look correct
<re_irc> FLASH : ORIGIN = 0x00000000, LENGTH = 256K
<re_irc> <Julia> Yeah I tried setting it to the following
<re_irc> RAM : ORIGIN = 0x20000000, LENGTH = 16K
<re_irc> < (@k900:0upti.me)> And what happened then?
<re_irc> <Julia> The same error.
<re_irc> < (@k900:0upti.me)> What exactly did you run and what exactly was the error?
<re_irc> <Julia> julia@julia-ubuntu:~/CLionProjects/nrf51822_blinky_rust$ cargo embed --release --target thumbv6m-none-eabi
<re_irc> Finished release [optimized] target(s) in 0.03s
<re_irc> Target /home/julia/CLionProjects/nrf51822_blinky_rust/target/thumbv6m-none-eabi/release/nrf51822_blinky_rust
<re_irc> Config default
<re_irc> < (@k900:0upti.me)> Try running it again with "RUST_LOG=debug"
<re_irc> <Julia> How do you do that?
<re_irc> < (@k900:0upti.me)> "RUST_LOG=debug cargo embed --release --target thumbv6m-none-eabi"
<re_irc> <Julia> holy crap
<re_irc> <Julia> that's a lot of output
<re_irc> <Julia> Caused by:
<re_irc> INFO cargo_embed > Metadata {
<re_irc> 0: Error while flashing
<re_irc> chip: Some(
<re_irc> < (@k900:0upti.me)> Please post the whole thing
<re_irc> <Julia> Okay
<re_irc> < (@k900:0upti.me)> As a pastebin
<re_irc> < (@k900:0upti.me)> Well that's not as much information as I hoped
<re_irc> < (@k900:0upti.me)> Might be a good time to file a bug on probe_rs tbh
<re_irc> < (@k900:0upti.me)> This definitely isn't normal
<re_irc> < (@k900:0upti.me)> It looks like the chip-side code is failing for whatever reason
<re_irc> <Julia> The first thing that comes to mind is that I did something wrong since this is the first time I'm doing this, not that the software I'm using is wrong. I think there is a server for probe-rs, maybe I should ask there first?
<re_irc> < (@k900:0upti.me)> I'd probably file an issue, because even if you _are_ doing something wrong, this is not a good failure mode
_whitelogger has joined #rust-embedded
<re_irc> <Julia> : It's the same, and we checked the sheets.
<re_irc> <Julia> * same error,
<re_irc> < (@yatekii:matrix.org)> no the datasheet says "256kB/128kB flash and 32kB/16kB RAM" and they use 256kb flash and 16kb RAM which sounds wrong to me
<re_irc> < (@k900:0upti.me)> https://www.waveshare.com/Core51822.htm
<re_irc> < (@k900:0upti.me)> The board comes with the higher end chip, supposedly
<re_irc> < (@adamgreig:matrix.org)> Would it matter though? The tiny blink firmware isn't going to write over 128k of flash and the ram is small enough to not be putting the stack in the wrong place anyway
<re_irc> < (@yatekii:matrix.org)> : the nRF51 standard algos do some stupid fucking checks and rease all flash and stuff like that. fgixed it for the nrf52's but not for the 51's I think
<re_irc> < (@yatekii:matrix.org)> so depending on what Is already on there etc it could be that.
<re_irc> < (@yatekii:matrix.org)> the flash algo error code is something we do not control and is from nordic.
<re_irc> < (@adamgreig:matrix.org)> Ah, annoying
<re_irc> < (@yatekii:matrix.org)> Julia: does "probe-rs-cli info" say something useful? What does "probe-rs-cli erase --allow-erase-all --chip nRF51822" do?
<re_irc> <Julia> Where do I get probe-rs-cli?
<re_irc> < (@dkhayes117:matrix.org)> cargo install probe-rs-cli
<re_irc> <Julia> Oh no it errors installing it.
<re_irc> < (@k900:0upti.me)> What's the error?
<re_irc> <Julia> ``error: failed to run custom build command for `openssl-sys v0.9.80```
<re_irc> <Julia> * v0.9.80````
<re_irc> < (@k900:0upti.me)> Post the full output
<re_irc> <Julia> error: failed to run custom build command for `openssl-sys v0.9.80`
<re_irc> Caused by:
<re_irc> process didn't exit successfully: `/tmp/cargo-installqVcACZ/release/build/openssl-sys-1284729946123246/build-script-main` (exit status: 101)
<re_irc> --- stdout
<re_irc> < (@yatekii:matrix.org)> you need to install openssl suggested by the output
<re_irc> <Julia> it is installed though, or atleast I can run it?
<re_irc> < (@tiwalun:matrix.org)> Julia: Have a look at https://github.com/probe-rs/probe-rs#building
<re_irc> < (@k900:0upti.me)> "sudo apt install libssl-dev"
<re_irc> < (@k900:0upti.me)> You need to install the development files
<re_irc> < (@k900:0upti.me)> To be able to build programs that use it
<re_irc> < (@tiwalun:matrix.org)> Hmm, just realised that libssl-dev is not mentioned in the readme 🙃
<re_irc> <Julia> Okay it seems to build now.
<re_irc> <Julia> : julia@julia-ubuntu:~/CLionProjects/nrf51822_blinky_rust$ probe-rs-cli info
<re_irc> Probing target via JTAG
<re_irc> Debug Port: Version 1, MINDP, DP Designer: ARM Ltd
<re_irc> └── 0 MemoryAP
<re_irc> < (@k900:0upti.me)> Well the good news is we have more proof the debugger works
<re_irc> <Julia> and for the other command:
<re_irc> julia@julia-ubuntu:~/CLionProjects/nrf51822_blinky_rust$ probe-rs-cli erase --allow-erase-all --chip nRF51822_xxAA
<re_irc> DEBUG probe_rs::flashing::flasher: content of PC 0xf: 0x20000020 should be: 0x20000021
<re_irc> DEBUG probe_rs::flashing::flasher: content of a1 0x0: 0x00000000 should be: 0x00000000
<re_irc> < (@k900:0upti.me)> Is that all the output?
<re_irc> <Julia> Yes
<re_irc> < (@korken89:matrix.org)> Has anyone else experienced that "cortex-m-semihosting" "v0.5.0" breaks in QEMU?
<re_irc> < (@korken89:matrix.org)> A lot of RTIC examples that are tested in CI now needs a "nop()" between an "hprinln!" and "debug::exit(..)" or the last "hprintln!" is not printed
<re_irc> < (@yatekii:matrix.org)> Julia: can you try flashing again?
<re_irc> < (@adamgreig:matrix.org)> : wonder if it's because it's now using inline asm and so there's not more instructions there anyway
<re_irc> < (@adamgreig:matrix.org)> and thus revealing some weird thing with qemu
<re_irc> <Julia> : Same error still.
<re_irc> < (@korken89:matrix.org)> Hmm
<re_irc> < (@korken89:matrix.org)> : Could be, I have not tested on hardware only that QEMU does not like it 😅
<re_irc> < (@korken89:matrix.org)> And it was a bit weird that a NOP fixes it, like there is a "delay" in "hprintln"
<re_irc> < (@korken89:matrix.org)> But it's based on breakpoints so it should not have a "delay" for printing
<re_irc> < (@yatekii:matrix.org)> Julia: do you have a commit to the current project setup?
<re_irc> < (@adamgreig:matrix.org)> there's a zip file ^
<re_irc> <Julia> I can make my github repository public, and share it here if you like.
<re_irc> <Julia> Otherwise yes there is a zip file like adam said.
<re_irc> < (@yatekii:matrix.org)> : I think it's outdated
<re_irc> < (@korken89:matrix.org)> We'll make an issue on "cortex-m-semihosting" and track it there
<re_irc> < (@yatekii:matrix.org)> the zip has
<re_irc> {
<re_irc> FLASH : ORIGIN = 0x18000, LENGTH = 0x28000
<re_irc> MEMORY
<re_irc> < (@yatekii:matrix.org)> Julia: that's preferrable
<re_irc> < (@adamgreig:matrix.org)> : could you possibly include a disassembly snippet around the final hprintln and debug::exit call to compare 0.4 to 0.5? i wonder if it's just ending up as literally bkpt, bkpt
<re_irc> < (@korken89:matrix.org)> : We updated from "0.3.3" to "0.5" so we're not really sure if "0.4" or "0.5" is the issue
<re_irc> < (@korken89:matrix.org)> But we'll include asm
<re_irc> < (@adamgreig:matrix.org)> might be some sort of bug in qemu
<re_irc> < (@adamgreig:matrix.org)> maybe debug::exit could have a preceding nop though
<re_irc> < (@korken89:matrix.org)> Could indeed be
<re_irc> < (@korken89:matrix.org)> Yeah, I think that should be fine
<re_irc> < (@yatekii:matrix.org)> Julia: are you able to read the markings on the chip?
<re_irc> <Julia> It only says NRF51822 sadly, no postfix.
<re_irc> < (@yatekii:matrix.org)> also not underneath? it must be there ...
<re_irc> < (@k900:0upti.me)> Can you post a picture of it?
<re_irc> <Julia> Not underneath either, but I will make a picture of both sides.
<re_irc> < (@yatekii:matrix.org)> The problem is that it's only the flash-algorithm failing. and the nRf51822 is chip-0 aka the thing we always tested with. so I doubt anything really bad
<re_irc> < (@yatekii:matrix.org)> lemme grab my microbit
<re_irc> < (@dkhayes117:matrix.org)> Probably won't help, but did you try it with 32K of RAM?
<re_irc> < (@yatekii:matrix.org)> Julia: I can flash perfectly fine. and get an RTT console. most likely your "nrf51822" is just bad. Looks very china china to me, no offense
<re_irc> < (@k900:0upti.me)> QFACA1 seems to be a 256K/32K model
<re_irc> < (@yatekii:matrix.org)> : yeah but coming from dubious places it could be crooked
<re_irc> < (@dkhayes117:matrix.org)> I looked in their user manual and it showed 32K
<re_irc> < (@yatekii:matrix.org)> but what could also be is that there is a softdevice on there already
<re_irc> < (@k900:0upti.me)> Definitely
<re_irc> < (@yatekii:matrix.org)> and then the flash algorithm of nordic will cry
<re_irc> < (@yatekii:matrix.org)> which is what I suspected and why I recommended an erase
<re_irc> < (@yatekii:matrix.org)> but the erase apparently did nothing
<re_irc> < (@k900:0upti.me)> Waveshare is generally not _very_ spooky in my experience
<re_irc> < (@dkhayes117:matrix.org)> Softdevice was mentioned in wiki page
<re_irc> < (@k900:0upti.me)> As in I'd be surprised if they actually used knockoff chips
<re_irc> < (@k900:0upti.me)> But it could just be a genuinely bad chip
<re_irc> < (@k900:0upti.me)> * genuine
<re_irc> < (@yatekii:matrix.org)> yeah, but I still suspect the softdevice
<re_irc> < (@yatekii:matrix.org)> I wonder why erase did not help
<re_irc> < (@yatekii:matrix.org)> lemme check
<re_irc> <Julia> Sorry for someone not in the know, what is a softdevice?
<re_irc> < (@yatekii:matrix.org)> it's the proprietary software blob for bluetooth
<re_irc> < (@k900:0upti.me)> It's basically a prebuilt firmware that Nordic can install on a chip
<re_irc> < (@k900:0upti.me)> But erasing should have removed it
<re_irc> < (@yatekii:matrix.org)> yap
<re_irc> < (@yatekii:matrix.org)> I am currently dumping all memory :D
<re_irc> < (@yatekii:matrix.org)> let's see
<re_irc> < (@yatekii:matrix.org)> maybe those chips can be locked too but do not fail when you access memory
<re_irc> < (@yatekii:matrix.org)> hmm
<re_irc> < (@yatekii:matrix.org)> (they are quite old)
<re_irc> < (@yatekii:matrix.org)> hmm yeah all erased for me
<re_irc> < (@yatekii:matrix.org)> yup, all looking fine
<re_irc> < (@yatekii:matrix.org)> hmm
<re_irc> < (@yatekii:matrix.org)> Julia: can you try the offical nordic CLI tool to check the status?
<re_irc> <Julia> I'll install it, what would you like like me to run?
<re_irc> < (@yatekii:matrix.org)> there should be a command that can tell you about the lock status of the chip
<re_irc> < (@yatekii:matrix.org)> and a command to unlock the chip
<re_irc> <Julia> I honestly don't know, this is all to new to me.
<re_irc> <Julia> * too
<re_irc> <Julia> Yes I installed that one.
<re_irc> <Julia> julia@julia-ubuntu:~/Downloads$ nrfjprog --eraseall
<re_irc> ERROR: No debuggers were discovered.
<re_irc> But stuff like this doesn't work.
<re_irc> NOTE: Any generated log error messages will be displayed.
<re_irc> NOTE: For additional output, try running again with logging enabled (--log).
<re_irc> <Julia> I don't have a segger debugger, which I think you need to use this.
<re_irc> < (@yatekii:matrix.org)> ah shoot didn't consider that
<re_irc> < (@dirbaio:matrix.org)> Julia: try disconnecting VDD from the stlink to the board, and powering the board independently over usb
<re_irc> < (@dirbaio:matrix.org)> the stlink's power regulator could be not powerful enough
<re_irc> < (@dirbaio:matrix.org)> flaky power can cause fun issues like this
<re_irc> <Julia> Okay let me grab an extra cable.
<re_irc> <Julia> It now shows a light on the board, but it still has the same error when I try to flash.
<re_irc> < (@afoht:matrix.org)> : Issue added, hopefully that covers the disassembly you were looking for, if not I have the files so can provide them if needed.
<re_irc> < (@adamgreig:matrix.org)> Thanks
<re_irc> <Julia> Any suggestions for how I could clear the flash using openocd then? I think that should be an alternative.
emerent_ has joined #rust-embedded
emerent is now known as Guest9807
Guest9807 has quit [Killed (platinum.libera.chat (Nickname regained by services))]
emerent_ is now known as emerent
<re_irc> < (@yatekii:matrix.org)> : how did u disassemble the flash algo?
<re_irc> < (@yatekii:matrix.org)> would be curious if the nrf51 one does the same crap
<re_irc> < (@yatekii:matrix.org)> we should check it
<re_irc> < (@dirbaio:matrix.org)> convert instructions to bin, put it in ghidra
<re_irc> < (@yatekii:matrix.org)> ok sounds fair
<re_irc> < (@dirbaio:matrix.org)> but in retrospect it's easier to rename the .flm to .elf and load that
<re_irc> < (@yatekii:matrix.org)> ah yeah that's absoilutely what I would do :)
<re_irc> < (@dirbaio:matrix.org)> anyway iirc there was a "softdevice-erase" algo variant that didn't
<re_irc> < (@dirbaio:matrix.org)> yeah there is, and it's marked as default in nrf51
<re_irc> < (@dirbaio:matrix.org)> (it wasn't on nrf52)
<re_irc> < (@dirbaio:matrix.org)> so it's probably already using the SDE algo
<re_irc> < (@dirbaio:matrix.org)> also
<re_irc> < (@dirbaio:matrix.org)> if this was the issue, it failed with "flash algorithm failed with code 103"
<re_irc> < (@dirbaio:matrix.org)> which is not the case here
<re_irc> < (@yatekii:matrix.org)> ok, I see
<re_irc> < (@dirbaio:matrix.org)> right?
<re_irc> < (@yatekii:matrix.org)> but code 1 would still be interesting to know
<re_irc> < (@yatekii:matrix.org)> the flash algo API sucks so bad
<re_irc> <Julia> I don't see a variant with 192kb flash, maybe I just don't understand though.
<re_irc> <Julia> oh nvm im blind
<re_irc> <Julia> I managed to get openocd running and it shows that 0x0000_0000 until 0x0001_4000 is 'protected'.
<re_irc> <Julia> What does that mean? Is this potentially the problem?
<re_irc> < (@yatekii:matrix.org)> Julia: yes, this is the problem :) I wonder why it does not complain when we erase ...
<re_irc> < (@yatekii:matrix.org)> we should be able to detect this
<re_irc> <Julia> I might log on over to my ubuntu so I can show you the output, brb.
<re_irc> < (@yatekii:matrix.org)> hmm do we have a good abstraction trait for writing bytes?
<re_irc> < (@yatekii:matrix.org)> Julia: oki :)
<re_irc> <Julia> > flash info 0
<re_irc> #0 : nrf51 at 0x00000000, size 0x00040000, buswidth 1, chipwidth 1
<re_irc> nRF51822-QFAC(build code: A1) 256kB Flash, 32kB RAM
<re_irc> # 0: 0x00000000 (0x400 1kB) protected
<re_irc> <Julia> and then this doesn't work
<re_irc> flash protect bank_id first_block [last_block|'last'] ('on'|'off')
<re_irc> > flash protect 0 0 79 'off'
<re_irc> <Julia> and then this doesn't work
<re_irc> > flash protect 0 0 79 off
<re_irc> Target not halted
<re_irc> failed setting protection for blocks 0 to 79
<re_irc> <Julia> and then this doesn't work
<re_irc> > flash protect 0 0 79 off
<re_irc> failed setting protection for blocks 0 to 79
<re_irc> Target not halted
<re_irc> <Julia> omfg i got it working
<re_irc> <Julia> no clue why it suddenly allowed me to remove the protection
<re_irc> <Julia> I think this might have done it
<re_irc> erased sectors 0 through 255 on flash bank 0 in 5.962760s
<re_irc> > flash erase_sector 0 0 last
<re_irc> < (@9names:matrix.org)> well the error message suggested that the target wasn't halted, maybe you do that?
<re_irc> < (@9names:matrix.org)> * did
<re_irc> <Julia> Yeah I halted, but that didn't allow me to remove the protection either... because
<re_irc> > flash protect 0 0 last off
<re_irc> You need to perform chip erase before changing the protection settings
<re_irc> failed setting protection for blocks 0 to 255
<re_irc> < (@9names:matrix.org)> yeah you can't lower the protection setting, only increase it.
<re_irc> an erase will remove it though.
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> <Julia> Is there a way to startup a RTT using cargo-embed without reflashing the chip?
<re_irc> < (@9names:matrix.org)> [default.flashing]
<re_irc> enabled = false
<re_irc> <Julia> So, how do I quickly switch between the two then? Like if I want to setup a task that includes flashing and one that just resets?
<re_irc> < (@yatekii:matrix.org)> Julia: default is just the profile name. you can make as many profiles as you want. and you can do "cargo embed profile"
<re_irc> < (@yatekii:matrix.org)> you do not need to set all fields of the profile. it will inherit from default.
<re_irc> < (@yatekii:matrix.org)> if you make more profiles you can also set the profile to inherit from
<re_irc> <Julia> so if i want a flashing profile, I could do something like:
<re_irc> enabled = true
<re_irc> and then call "cargo embed flash"?
<re_irc> [flash.flashing]
<re_irc> <Julia> Seems to work. Wow this is a nice workflow!
<re_irc> < (@yatekii:matrix.org)> Julia: yes
<re_irc> <Julia> So just out of curiosity then, why do you think probe-rs didnt delete those sectors?
<re_irc> < (@yatekii:matrix.org)> Julia: because they were protected?
<re_irc> <Julia> Shouldn't probe-rs do something about that? Like either give a warning or an option to erase them?
<re_irc> < (@yatekii:matrix.org)> Julia: every chip does locking mechanisms differently and probe-rs does not know about the one for this chip yet. also, the nordic provided flash algorithm here is just plain stupid ... it should error that it cannot erase because it's locked instead of saying the erase was successfull but then failing when writing ...
<re_irc> <Julia> Could probe-rs abstract over that error and add an additional possible cause? I feel like that could save a headache for future devs.
<re_irc> < (@yatekii:matrix.org)> Julia: well yes :) it's work ;)(
<re_irc> < (@yatekii:matrix.org)> those error codes are arbitrary
<re_irc> < (@yatekii:matrix.org)> and not documented
<re_irc> < (@yatekii:matrix.org)> don't get me wrong Julia this is a hard bug in my book, but it's tricky to solve, not particularly fun and we all do this in our sparetime :)
bvr has quit [Quit: Lost terminal]
<re_irc> <Julia> Oh yeah I'm not demanding anything, just maybe a suggestion haha. Anyways cheers for the help and all!
<re_irc> < (@yatekii:matrix.org)> No worries :)
dc740 has quit [Remote host closed the connection]
<re_irc> < (@yatekii:matrix.org)> If I can push myself to it I will do this full time soon then stuff like that will be fixed :) If not, welp :D