<re_irc> <@d​khayes117:m​atrix.org> If anyone can, I need a code review of a pull request (in draft) for the rust-embedded/riscv crate. I've fully implemented methods and functions for the pmpcfg0 module. It is a matter of simple copy/paste for pmpcfg1-3, but I want to cut out as much duplication as possible. I don't understand macros enough...
<re_irc> ... to use them. Any insight/pointers are appreciated! disasm is pretty busy, so I didn't want to bother him until the PR is in a more reviewable state. https://github.com/dkhayes117/riscv/blob/master/src/register/pmpcfgx.rs
GenTooMan has quit [Ping timeout: 255 seconds]
GenTooMan has joined #rust-embedded
emerent has quit [Ping timeout: 255 seconds]
emerent has joined #rust-embedded
connorw has quit [Quit: Lost terminal]
starblue1 has joined #rust-embedded
starblue has quit [Ping timeout: 258 seconds]
rjframe has quit [Ping timeout: 258 seconds]
fabic has quit [Ping timeout: 252 seconds]
fabic has joined #rust-embedded
<re_irc> <@u​bik:m​atrix.org> therealprof: Ah cool
mikehcox has joined #rust-embedded
<re_irc> <@n​ewam:m​atrix.org> ub|k: I'm the guy working on that, let me know if you have any questions
dcz_ has joined #rust-embedded
dcz has joined #rust-embedded
dcz_ has quit [Ping timeout: 258 seconds]
fabic has quit [Ping timeout: 255 seconds]
mikehcox has quit [Quit: Client closed]
<re_irc> <@u​bik:m​atrix.org> newam I assume running LoRaWAN is out of the question for now? 😆
GenTooMan has quit [Ping timeout: 255 seconds]
GenTooMan has joined #rust-embedded
neceve has joined #rust-embedded
tokomak has joined #rust-embedded
rjframe has joined #rust-embedded
fabic has joined #rust-embedded
<re_irc> <@n​ewam:m​atrix.org> ub|k: LoRa works; but no code for LoRaWAN yet.
rjframe has quit [Remote host closed the connection]
<re_irc> <@d​khayes117:m​atrix.org> Is TravisCI still working for projects on github that was setup for auto checks? I have pull request that showing that `Some checks haven't completed yet` I'm wondering if that will actually ever complete or not.
fabic has quit [Remote host closed the connection]
fabic has joined #rust-embedded
<re_irc> <@d​khayes117:m​atrix.org> Doesn't look like it's available anymore from the looks of it.
<re_irc> <@d​khayes117:m​atrix.org> at least for free
<re_irc> <@n​ewam:m​atrix.org> Travis CI got sold to a not so great company and implemented some sort of limit. Github actions is the better option for open source these days
<re_irc> <@d​khayes117:m​atrix.org> Thanks for the info
<re_irc> <@n​ewam:m​atrix.org> Also I would not recommend paying; the quality of service went downhill after they got acquired; and paying does not change that.
<re_irc> <@d​khayes117:m​atrix.org> Bummer
<re_irc> <@n​ewam:m​atrix.org> Yeah ☹️
<re_irc> <@u​bik:m​atrix.org> newam: how complex is LoRaWAN?
<re_irc> <@n​ewam:m​atrix.org> ub|k: The protocol itself is not that complex; but I have not ever implemented any radio protocols since my degree, so I could be missing something 😀
<re_irc> <@u​bik:m​atrix.org> how much is that from 0 to WebDAV?
<re_irc> <@n​ewam:m​atrix.org> with LoRaWAN they wanted something simple like MQTT, you can see its roots there, but radios are inherently complex... so it grew from there.
<re_irc> <@n​ewam:m​atrix.org> I have only looked at the basics; but it looks like it would be MQTT + radio complexity + open channel complexity (encryption + signing)
<re_irc> <@n​ewam:m​atrix.org> That being said, you asked earlier if you could skip C entirely. You can; but it will take effort since I still consider embedded-rust to be in an early adopter phase.
<re_irc> <@n​ewam:m​atrix.org> C is the faster option, simply because there is already code provided by ST and samtech.
<re_irc> <@n​ewam:m​atrix.org> I could have been done my project already if I used C; I am using rust because I want to grow the ecosystem, and I find I spend more time coding and less time debugging with rust (more enjoyable for me).
<re_irc> <@n​ewam:m​atrix.org> I do not want to discourage you from choosing rust, just want to be realistic about the maturity.
fabic has quit [Ping timeout: 255 seconds]
<re_irc> <@u​bik:m​atrix.org> Sure, and thanks for being honest about it :)
<re_irc> <@u​bik:m​atrix.org> BTW, I see st-link doesn't detect STM32WLx yet
<re_irc> <@n​ewam:m​atrix.org> I have been using the Nucleo's onboard st-link and probe run which has worked out for me (though only up to 64k flash for reasons I have yet to investigate)
<re_irc> <@u​bik:m​atrix.org> sorry, I meant the linux tool, not the programmer
<re_irc> <@n​ewam:m​atrix.org> ahhh, yeah, I have not been using that tool
<re_irc> <@u​bik:m​atrix.org> using probe-rs? openocd?
starblue1 has quit [Ping timeout: 252 seconds]
<re_irc> <@n​ewam:m​atrix.org> I have it working with both, I have a small template project here if you want to try it out: https://github.com/newAM/nucleo-wl55jc2-rs
<re_irc> <@u​bik:m​atrix.org> neat! thanks a bunch
<re_irc> <@u​bik:m​atrix.org> yay
<re_irc> <@u​bik:m​atrix.org> BTW, if you're interested, I also managed to configure Cortex-Debug integration in VSCode
<re_irc> <@n​ewam:m​atrix.org> ooo yes that does interest me, I have not explored debug options very much yet
<re_irc> <@u​bik:m​atrix.org> that seems to work
<re_irc> <@u​bik:m​atrix.org> a pity cortex-debug doesn't seem to support RTT yet
<re_irc> <@n​ewam:m​atrix.org> I think cargo-embed supports a simultaneous RTT + GDB server; though I have not tried it myself
<re_irc> <@t​halesfragoso:m​atrix.org> Openocd added support for RTT in the last version too
<re_irc> <@t​halesfragoso:m​atrix.org> Although cargo embed seems more integrated with rust environments
tokomak has quit [Ping timeout: 240 seconds]
<re_irc> <@f​irefrommoonlight:m​atrix.org> Thanks for the Lora/STM32WL work
<re_irc> <@f​irefrommoonlight:m​atrix.org> It's interesting seeing the contrast how ST handles bluetooth etc vice lora etc: The latter, you implement yourself. The former, you use a core-interaction mailbox system, and the radio code is proprietary and provided for you for the whole RF core. (If I understand correctly)
starblue1 has joined #rust-embedded
neceve has quit [Ping timeout: 240 seconds]
<re_irc> <@f​reckly-sunbeam:m​atrix.org> Hello 👋 I'm having some difficulty getting `cross` to work. I'm trying to build an executable for raspberry pi from aarch64 macOS. Running `cross build --target armv7-unknown-linux-gnueabihf` tries to use an on-host `armv7-unknown-linux-gnueabihf` target instead of using the docker images, and I can't...
<re_irc> ... seem to get the toolchains set up correctly for armv7. Is there a way to force `cross` to use docker for compiling?
neceve has joined #rust-embedded
<re_irc> <@n​ewam:m​atrix.org> Never used cross myself, last time I cross compiled for the pi I just had to set the linker in `.cargo/config.toml`, e.g.
<re_irc> <@n​ewam:m​atrix.org> ```toml
<re_irc> <@n​ewam:m​atrix.org> [target.armv7-unknown-linux-gnueabihf]
<re_irc> <@n​ewam:m​atrix.org> Never used a mac myself, so not sure how to get the toolchains installed unfortunately
<re_irc> <@n​ewam:m​atrix.org> linker = "arm-none-linux-gnueabihf-gcc"
<re_irc> <@n​ewam:m​atrix.org> if you search up cross-compiling C on a mac for the pi it should have information to install the toolchains, that part is pretty much the same between rust/c
<re_irc> <@d​irbaio:m​atrix.org> cross always uses docker
<re_irc> <@d​irbaio:m​atrix.org> you don't need to install anything on the host
neceve has quit [Ping timeout: 255 seconds]
dcz has quit [Ping timeout: 265 seconds]
<re_irc> <@n​ewam:m​atrix.org> Are there any tricks to use the STM32 DMA's for SPI RX without a second DMA to keep filling the TX FIFO?
<re_irc> <@f​reckly-sunbeam:m​atrix.org> dirbaio: I don't think it's true that cross always uses docker, there's no cross docker image on my machine after running it
<re_irc> <@d​irbaio:m​atrix.org> can you paste logs of what are you trying to do and how does it fail?
<re_irc> <@f​reckly-sunbeam:m​atrix.org> dirbaio: Sure, this is what I'm trying to build (https://github.com/lily-mara/nanoproxy) and here are the logs of a fresh build
<re_irc> <@f​reckly-sunbeam:m​atrix.org> $ git clone https://github.com/lily-mara/nanoproxy.git
<re_irc> <@f​reckly-sunbeam:m​atrix.org> Cloning into 'nanoproxy'...
<re_irc> <@f​reckly-sunbeam:m​atrix.org> remote: Enumerating objects: 16, done.
<re_irc> <@d​irbaio:m​atrix.org> hmm, seems to work for me, and it does use docker, I can see it spin up a container of image `rustembedded/cross:armv7-unknown-linux-gnueabihf-0.2.1` in `docker ps`
<re_irc> <@t​halesfragoso:m​atrix.org> I compiled to raspberrypi before, never used cross...
<re_irc> <@t​halesfragoso:m​atrix.org> I just had to use musl because I was getting libc incompatibilities
<re_irc> <@d​irbaio:m​atrix.org> freckly-sunbeam: try with `--verbose`
<re_irc> <@f​reckly-sunbeam:m​atrix.org> dirbaio: ```
<re_irc> <@f​reckly-sunbeam:m​atrix.org> + "cargo" "build" "--target" "armv7-unknown-linux-gnueabihf" "--verbose"
<re_irc> <@f​reckly-sunbeam:m​atrix.org> Fresh unicode-xid v0.2.2
<re_irc> <@f​reckly-sunbeam:m​atrix.org> Fresh autocfg v1.0.1
<re_irc> <@d​irbaio:m​atrix.org> oh what
<re_irc> <@d​irbaio:m​atrix.org> for me it prints
<re_irc> <@d​irbaio:m​atrix.org> ^[[A[dirbaio@mars nanoproxy]$ cross build --target armv7-unknown-linux-gnueabihf -vv
<re_irc> <@d​irbaio:m​atrix.org> + "rustc" "--print" "sysroot"
<re_irc> <@d​irbaio:m​atrix.org> + "rustup" "toolchain" "list"
<re_irc> <@n​ewam:m​atrix.org> `cross --version` ?
<re_irc> <@f​reckly-sunbeam:m​atrix.org> thalesfragoso: Maybe I could re-try compiling with rustup without `cross` but using musl. I added the rustup target for armv7 last night and I ran into a lot of issues and was hoping that cross would "just work"
<re_irc> <@d​irbaio:m​atrix.org> it seems it's delegating to the host cargo indeed
<re_irc> <@f​reckly-sunbeam:m​atrix.org> newam: ```
<re_irc> <@f​reckly-sunbeam:m​atrix.org> cross 0.2.1
<re_irc> <@f​reckly-sunbeam:m​atrix.org> cargo 1.53.0 (4369396ce 2021-04-27)
<re_irc> <@d​irbaio:m​atrix.org> maybe try installing cross from git?
<re_irc> <@d​irbaio:m​atrix.org> release 0.2.1 is old, git master has fixes for arm macs
<re_irc> <@f​reckly-sunbeam:m​atrix.org> dirbaio: After installing the git version, it looks like it's running in docker now
<re_irc> <@f​reckly-sunbeam:m​atrix.org> Thanks for the help everyone!
starblue1 has quit [Ping timeout: 246 seconds]
starblue1 has joined #rust-embedded
<re_irc> <@a​lmindor:m​atrix.org> does anyone know what's up with bors timing out?
<re_irc> <@t​herealprof:m​atrix.org> bors has frequent hickups. You could check the state on the bors site.
<re_irc> <@t​herealprof:m​atrix.org> Or the CI is still using Travis. 😉
<re_irc> <@a​lmindor:m​atrix.org> I think https://github.com/rust-embedded/riscv/pull/76 is in a funy state, it says merged but bors timed out and I think it didn't make it?
<re_irc> <@a​lmindor:m​atrix.org> should I just re-bors or something? seems odd
<re_irc> <@t​herealprof:m​atrix.org> Travis CI in this case. Merged is merged.
<re_irc> <@t​herealprof:m​atrix.org> 😉
<re_irc> <@a​lmindor:m​atrix.org> ah
<re_irc> <@a​lmindor:m​atrix.org> ah it goes to staging, right
<re_irc> <@t​herealprof:m​atrix.org> Uhm, that sounds wrong though.
<re_irc> <@a​lmindor:m​atrix.org> seems stuck, it should've checked and merged staging to master right?
<re_irc> <@t​herealprof:m​atrix.org> Honestly I'm a bit lost about this one; haven't seen that before.
<re_irc> <@d​khayes117:m​atrix.org> I could use a review almindor at your convenience of course.
<re_irc> <@d​khayes117:m​atrix.org> https://github.com/rust-embedded/riscv/pull/58
<re_irc> <@t​herealprof:m​atrix.org> Maybe a misconfiguration but it should have been marked as merged.
<re_irc> <@t​herealprof:m​atrix.org> Staging is a temporary branch, the new PR should cause it to be overwritten.
<re_irc> <@t​herealprof:m​atrix.org> The fix here is to get rid of Travis CI ASAP and then redo the PR.
<re_irc> <@a​lmindor:m​atrix.org> > I could use a review almindor at your convenience of course.
<re_irc> <@a​lmindor:m​atrix.org> > https://github.com/rust-embedded/riscv/pull/58
<re_irc> <@a​lmindor:m​atrix.org> could you resolve all the fixed points disasm made in the PR?
<re_irc> <@d​khayes117:m​atrix.org> That was a older version he reviewed. I made more commits.
<re_irc> <@a​lmindor:m​atrix.org> > The fix here is to get rid of Travis CI ASAP and then redo the PR.
<re_irc> <@a​lmindor:m​atrix.org> what do we use instead of travis now?
<re_irc> <@d​khayes117:m​atrix.org> Someone mentioned github actions
<re_irc> <@a​lmindor:m​atrix.org> > That was a older version he reviewed. I made more commits.
<re_irc> <@a​lmindor:m​atrix.org> yes but if you fixed the issues "resolve conversation" so it's not spammy, it's kinda hard to keep track if something is still unsolved
<re_irc> <@d​khayes117:m​atrix.org> Sorry, I am a total noob
<re_irc> <@t​herealprof:m​atrix.org> GHA is the natural choice, yeah. Not saying the best but certainly the easiest to get going and free of charge for such projects.
<re_irc> <@a​lmindor:m​atrix.org> wouldn't we have to move all the repos over?
<re_irc> <@t​herealprof:m​atrix.org> Yes. Travis CI is pretty much dead so there's not much of a choice.
<re_irc> <@a​lmindor:m​atrix.org> hmm I'll have to find out how things like our install.sh script should be done on GHA
<re_irc> <@t​herealprof:m​atrix.org> I think we've pretty much eliminated those scripts since GHA has very good support for a lot of common tasks (including Rust compiler setup).
<re_irc> <@a​lmindor:m​atrix.org> oh how do you handle targets?
<re_irc> <@t​herealprof:m​atrix.org> I'd recommend having a look at comparable crates in the Cortex-M domain.
<re_irc> <@a​lmindor:m​atrix.org> ah not persistent, always re-do
<re_irc> <@a​lmindor:m​atrix.org> > Sorry, I am a total noob
<re_irc> <@a​lmindor:m​atrix.org> no probs at all. I'll need to figure this merging issue in riscv first anyhow, maybe ping me about this tomorrow+ :)
<re_irc> <@d​khayes117:m​atrix.org> Yessir!
<re_irc> <@a​lmindor:m​atrix.org> > I'd recommend having a look at comparable crates in the Cortex-M domain.
<re_irc> <@a​lmindor:m​atrix.org> any chance you could look at https://github.com/rust-embedded/riscv/pull/78 see if it makes sense? ran ok on my fork
tokomak has joined #rust-embedded
<re_irc> <@f​irefrommoonlight:m​atrix.org> I have a question regarding atomics. Previously, I received advice that code like this can product undefined behavior due to the order of atomic operations potentially not being as the code implies:
<re_irc> <@f​irefrommoonlight:m​atrix.org> if EPD_SLEEPING.load(Ordering::Acquire) {
<re_irc> <@f​irefrommoonlight:m​atrix.org> ```rust
<re_irc> <@f​irefrommoonlight:m​atrix.org> epd.wake_up(spi, delay, dma);
<re_irc> <@f​irefrommoonlight:m​atrix.org> EPD_SLEEPING.store(false, Ordering::Release)
<re_irc> <@f​irefrommoonlight:m​atrix.org> }
<re_irc> <@f​irefrommoonlight:m​atrix.org> Is there a good explanation? My intuition says either the block gets executed and `false` is stored, or it doesn't since it was `true`
<re_irc> <@f​irefrommoonlight:m​atrix.org> And that you should do `swap` instead
<re_irc> <@d​irbaio:m​atrix.org> imagine 2 threads running that code
<re_irc> <@d​irbaio:m​atrix.org> initially EPD_SLEEPING = true
<re_irc> <@f​irefrommoonlight:m​atrix.org> oh...
<re_irc> <@d​irbaio:m​atrix.org> thread A does the load, sees `false`
<re_irc> <@d​irbaio:m​atrix.org> thread A does the wakeup
<re_irc> <@d​irbaio:m​atrix.org> thread A writes `true`
<re_irc> <@d​irbaio:m​atrix.org> thread B does the load, sees `false`
<re_irc> <@f​irefrommoonlight:m​atrix.org> Thank you - that makes sense. In this parcitular cause, I suppose that could happen due to it being used in interrupts
<re_irc> <@d​irbaio:m​atrix.org> err the other way around
<re_irc> <@d​irbaio:m​atrix.org> edited
<re_irc> <@d​irbaio:m​atrix.org> so even though that code "looks like" wakeup should be done once, maybe it ends up being done multiple times
<re_irc> <@d​irbaio:m​atrix.org> with swap or similar you can enforce that only one thread does the wakeup
<re_irc> <@d​irbaio:m​atrix.org> making the "check if it's true, set it to false" operation atomic
<re_irc> <@f​irefrommoonlight:m​atrix.org> Is this how you'd do it?
<re_irc> <@f​irefrommoonlight:m​atrix.org> if EPD_SLEEPING.swap(false,Ordering::AcqRel) {
<re_irc> <@f​irefrommoonlight:m​atrix.org> ```rust
<re_irc> <@f​irefrommoonlight:m​atrix.org> epd.wake_up(spi, delay, dma);
<re_irc> <@d​irbaio:m​atrix.org> no need for the else even
<re_irc> <@d​irbaio:m​atrix.org> you want to store `false` then check the old value
<re_irc> <@d​irbaio:m​atrix.org> if the old value was already `false` then you can simply do nothing
<re_irc> <@f​irefrommoonlight:m​atrix.org> Do you have an example?
<re_irc> <@f​irefrommoonlight:m​atrix.org> ```rust
<re_irc> <@f​irefrommoonlight:m​atrix.org> let old_val = EPD_SLEEPING.load(Ordering::Acquire);
<re_irc> <@f​irefrommoonlight:m​atrix.org> EPD_SLEEPING.store(false, Ordering::Release);
<re_irc> <@f​irefrommoonlight:m​atrix.org> if old_val {
<re_irc> <@d​irbaio:m​atrix.org> nope, that code can still race :)
<re_irc> <@d​irbaio:m​atrix.org> to avoid races you really need a CAS operation
<re_irc> <@d​irbaio:m​atrix.org> swap, compare_exchange, etc
<re_irc> <@d​irbaio:m​atrix.org> only *one* thread must be able to put a value in the Forever, even in the face of races
<re_irc> <@d​irbaio:m​atrix.org> so it checks that the old value was `false` AND sets it to `true`in the same operation
<re_irc> <@d​irbaio:m​atrix.org> so only one thread can ever see `false`, all the others will see `true` and panic
<re_irc> <@f​irefrommoonlight:m​atrix.org> I'm considering a cs for code readability
<re_irc> <@f​irefrommoonlight:m​atrix.org> This is quickly turning unintuitive
<re_irc> <@d​irbaio:m​atrix.org> yaeh atomics are harder than cs's
<re_irc> <@f​irefrommoonlight:m​atrix.org> I do want to learn though...
<re_irc> <@d​irbaio:m​atrix.org> the upside is they're somewhat faster and they can't impact interrupt latency
<re_irc> <@f​irefrommoonlight:m​atrix.org> ```rust
<re_irc> <@f​irefrommoonlight:m​atrix.org> if EPD_SLEEPING.compare_exchange(true, false, Ordering::AcqRel, Ordering::AcqRel) {
<re_irc> <@f​irefrommoonlight:m​atrix.org> epd.wake_up(spi, delay, dma);
<re_irc> <@f​irefrommoonlight:m​atrix.org> }
<re_irc> <@f​irefrommoonlight:m​atrix.org> *Aquire in both args
<re_irc> <@d​irbaio:m​atrix.org> if you have 3h to spare, this is the thing that made atomics/orderings click for me 🤣
<re_irc> <@d​irbaio:m​atrix.org> https://www.youtube.com/watch?v=A8eCGOqgvH4 (both parts)
<re_irc> <@f​irefrommoonlight:m​atrix.org> sweet
<re_irc> <@f​irefrommoonlight:m​atrix.org> I think it's worth it
radens has joined #rust-embedded
<re_irc> <@f​irefrommoonlight:m​atrix.org> ```rust
<re_irc> <@f​irefrommoonlight:m​atrix.org> let result = EPD_SLEEPING.compare_exchange(
<re_irc> <@f​irefrommoonlight:m​atrix.org> false,
<re_irc> <@f​irefrommoonlight:m​atrix.org> true,