<thejpster[m]>
It’ll be a while before our MSRV has cfg_if stabilised though.
sroemer has joined #rust-embedded
sroemer has quit [Changing host]
sroemer has joined #rust-embedded
Guest83 has joined #rust-embedded
zeenix[m] has quit [Quit: Idle timeout reached: 172800s]
sourcebox[m] has quit [Quit: Idle timeout reached: 172800s]
Guest83 has quit [Quit: Client closed]
<mkj[m]>
I'm seeing quite a big performance slowdown 1.87 -> 1.88 in a benchmark doing USB transfers device->host on a stm32h7s3. ~15MB/s on 1.87, ~11MB/s on 1.87. I think the workload is mostly limited by memcpy speed, anyone seen something like that? I'll dig into it next week
<mkj[m]>
similar slowdown across various optimisation levels, though optimisation levels make a big difference too. so that's a bit surprising I guess
<jason-kairos[m]>
maybe related to the size improvements that were noted recently
<thejpster[m]>
is this recompiling host code or device code?
<mkj[m]>
device code. the host side is a kernel driver
<mkj[m]>
s/87/88/
<mkj[m]>
* is a linux kernel driver
<dngrs[m]>
maybe new size/offset causes your binary to run into weird alignment edge cases?
<mkj[m]>
dngrs[m]: yeah, seems like a possibility. that would account for it being consistent across optimisation levels too I guess
RoyBuitenhuis[m] has joined #rust-embedded
<RoyBuitenhuis[m]>
On our softcore project, we generate a SVD file that uses deriveFrom to instantiate mutliple perhipherals of the same kind. svd2rust now generates core::fmt::Debug on these, but as they are type aliasses to the "base" peripheral, I get: conflincing implementation of trait `Debug` for x
<RoyBuitenhuis[m]>
There is no way to disable the generation of this impl, right? How should this case be handled? Just updated from 0.28 to 0.36.1, not sure when this exactly broke, but it worked on 0.28.
Emkanea[m] has joined #rust-embedded
<Emkanea[m]>
Not sure if this is a stupid question: eh defines InputPin methods as fallible. Do you bubble Errors up or just unwrap it? For all MCUs I had to deal with this seems reasonable. Do I miss something here?
<dirbaio[m]>
they're fallible to allow for gpio expanders over i2c, usb, etc
<dirbaio[m]>
which is a fairly niche use case
<dirbaio[m]>
as a driver author you can decide whether you want to support it or not
<Emkanea[m]>
Ah this helps! I am writing a board abstraction for my actual board. So here I know it is infallible as I am not using expanders or similiar. Thanks
<dirbaio[m]>
For normal mcu GPIOs, HALs implement them with type Error = Infallible which is an uninhabited type, so at least if you do choose to bubble up the errors it'll compile to nothing when someone uses your drivers with a normal mcu gpio.
<dirbaio[m]>
so theres' no runtime cost or code size downside
<dirbaio[m]>
but yeah it's more code
Guest83 has joined #rust-embedded
<RoyBuitenhuis[m]>
<RoyBuitenhuis[m]> "On our softcore project, we..." <- Hmm, the first instance of the deriveFrom uses the same base addr, so the type alias the same. Maybe this is technically just a svd error. Just anoying that it broke here.
ouilemur has quit [Quit: WeeChat 4.6.3]
burrbull[m] has joined #rust-embedded
<burrbull[m]>
<RoyBuitenhuis[m]> "Hmm, the first instance of the..." <- if you could not find error, open issue in svd2rust repo and attach the SVD
Guest83 has quit [Quit: Client closed]
kenny has quit [Ping timeout: 260 seconds]
kenny has joined #rust-embedded
TomB[m] has quit [Quit: Idle timeout reached: 172800s]
<JamesMunns[m]>
Open to a better log message, right now the code doesn't really understand the difference between an "intentional close" and "the sender may have panicked or something and now the channel is closed"
<JamesMunns[m]>
so, you'll get the same worker if whatever is feeding the worker panics, or if you intentionally close the worker.
<Ralph[m]>
ah, so this is always logged and not just some corner case where i'm holding things wrong?
<JamesMunns[m]>
You could drop that to an `info!` level and remove the "this could be bad" log
<JamesMunns[m]>
yeah, that log just means "the channel feeding the output worker has closed, and the output worker will stop now"
<JamesMunns[m]>
I guess there's some kind of explicit cancellation, since THAT log is hitting instread of the `cancel_fut` in the async fn above, it means the channel is closing without the user explicitly calling cancel
<Ralph[m]>
ok, i'll send you a PR to change it to info as you suggested if you think that's the way to go.
<Ralph[m]>
alternatively there could be an explicit "i really want to stop you now" API which needs to be called by the consumer to prevent the log entry (e.g. from a custom drop handler of the struct holding the client), but that feels wrong
<JamesMunns[m]>
Ralph[m]: There is one, and you're not hitting it if that log is displayed
<JamesMunns[m]>
That log probably happens if you just drop all HostClient instances, which means there are no more producers, which means the consumer is closed
<JamesMunns[m]>
You could add a drop impl to HostContext that calls the explicit stopper I guess, or we could make the log not be as misleading that this could be a "bad" thing, it happens both when things ARE bad, but also when you naturally just drop the last host client.
<JamesMunns[m]>
You could add a drop impl to HostContext that calls the explicit stopper I guess, or we could make the log not be as misleading that this could be a "bad" thing, it happens both when things ARE bad, but also when you naturally just drop the last host client.
<JamesMunns[m]>
edit: it would be a bit of work to do the drop impl, HostContext doesn't have a stopper handle atm, we could add it, but not sure how much value it would bring.
<JamesMunns[m]>
The HostContext is shared between the instances of the HostClient (and maybe the worker tasks? if so: then a drop impl won't help since the worker tasks will still hold it).
<JamesMunns[m]>
That stopper can be called by a method on the HostClient
<Ralph[m]>
JamesMunns[m]: ah, so i should just add an `impl Drop` for my own `struct` and call that there?
<Ralph[m]>
sorry, i missed that!
<JamesMunns[m]>
You could, but you shouldn't have to :)
<JamesMunns[m]>
I'd probably say the easiest fix is to just drop the `warn!` to an `info!` and just say "worker task is closing", and remove this "this might be bad" part
<JamesMunns[m]>
We don't really need to do a lot more, things automatically get cleaned up, regardless of why the client handles are gone (natural drop or panic)
<thejpster[m]>
new release of derive-mmio just came out - fixes a soundness issue where an API should have been unsafe but wasn't.
<thejpster[m]>
I've been using derive-mmio (and bitbybit) to write a new PAC/HAL for use in a safety-critical system and next time I find a new chip, I might just use it instead of finding my way through bugs in SVD files.
<Kert[m]>
Kert[m]: Same principle works on Cortex-M and anywhere else of course. On host, one of the tricks is to run your test suite in a separate thread that has a fixed stack allocation, and watermark it
<nerwalt[m]>
Kert[m]: Thanks for sharing. I have read about watermarking and have been thinking about using it, but was curious to know if there were other ways.
<Kert[m]>
nerwalt[m]: In theory, there are analysis tools as well that figure out the max depth. I still would trust watermarking in a real world test :) call it superstition
<nerwalt[m]>
Kert[m]: the idea is pretty simple. im going to use your stack_measurements module to see what i get
<Kert[m]>
nerwalt[m]: I have a cortex-m version as well somewhere, i don't think it's in public repo but i can push it somewhere
sroemer has quit [Quit: WeeChat 4.5.2]
<nerwalt[m]>
Kert[m]: if you can, that would be great. im working on cortex-ms
<firefrommoonligh>
nerwalt[m]: V interesting. I'm hitting RAM and flash issues RN, and this might help. I'm using a low-mem STM32 variant for this (oops), and have USB/LoRA/UART buffers, as well as in-mem storage that is hitting the limit
<firefrommoonligh>
firefrommoonligh: And had to optimize the bin in cargo.toml for size to not overflow the flash
<Kert[m]>
nerwalt[m]: i'll get to it late tonight, will ping back here
<firefrommoonligh>
Kert[m]: (The answer here btw, is get a higher-memory stm32 variant, but tools like you posted will help!)
k3ma[m] has joined #rust-embedded
<k3ma[m]>
Hello, I'm new to Micro Controllers and embedded and running through the discovery embedded book. I think I'm having trouble with flashing my micro::bit. I'm following the steps in outlined in the book, and ran through about 5 times now making sure everything is followed, but when I check the source code using `layout src my code that should be flashed over isn't showing.
<Kin-o-matix[m]>
<thejpster[m]> "I've been using derive-mmio (and..." <- I take it you have to manually write out the registers and blocks then though?
sourcebox[m] has joined #rust-embedded
<sourcebox[m]>
I'm just trying to get the initial startup of the dual-core STM32MP1 working. So far, I have individual startup code for the cores in .s files. I can sucessfully boot into separate main functions for each core. What I want achieve is starting the second core via a closure like done with ESP32 or RP2040/RP2350. But I have not found any way yet to sucessfully move the closure with all captures to the second core.
RobinMueller[m] has quit [Quit: Idle timeout reached: 172800s]
<sourcebox[m]>
But it's a closure, which doen't have a dedicated symbol name.
<JamesMunns[m]>
I mean a KEEP directive for the entry point
<sourcebox[m]>
The entry point is not optimized away.
<JamesMunns[m]>
You're saying the entry points are both preserved, but the closure that you directly call in rust code IS optimized away?
<JamesMunns[m]>
Are you seeing that with a linker error or something?
<sourcebox[m]>
With entry function, I mean the closure function passed to start_app_core.
<sourcebox[m]>
This contains the code that should be executed on the second core.
<JamesMunns[m]>
can you paste the error message that you see?
<sourcebox[m]>
There's no error messages, I just can't find the code in the assembly dump anymore.
<JamesMunns[m]>
Simple closures often get inlined at their call site
<JamesMunns[m]>
it's probably not *gone*, just *optimized* somewhere else.
<sourcebox[m]>
And therefore, the rest of the magic done in this esp-hal function doen't work anymore.
<sourcebox[m]>
I can search for what the code is doing, and it's not there anymore. Even with inlining, that would be the case.
<JamesMunns[m]>
Gotcha, I must not understand what is going on then, sorry!
<sourcebox[m]>
I know this whole thing is somewhat complicated.
<sourcebox[m]>
The other approach I tried is what is done in the RP HALs, but there's another drawback: since they use a generic function as entry point, it can not be reached from the startup code anymore because these type of functions have to be name-mangled.
<sourcebox[m]>
At then of core1_startup there's a call to entry(), so my guess is, the compiler will get it and the code remains.
<sourcebox[m]>
But as I said, this function is not reachable from the asm startup code.
<sourcebox[m]>
Also, there has to be some arguments passed that the startup code does not have.
<thejpster[m]>
<Kin-o-matix[m]> "I take it you have to manually..." <- Yes. I estimate they only took 15% of the effort. You look at the register map in the data sheet and type out all the names. Then any you really care about you replace the u32 with a bitbybit bitfield struct describing all the bit fields.
<Kin-o-matix[m]>
this kind of suggests there's an issue if you go to aarch64 with a lot of the existing methods https://github.com/google/safe-mmio
<Kin-o-matix[m]>
this is just marketing by google to sell me on a crate they'll abandon in 3 months?
ouilemur has joined #rust-embedded
<Kin-o-matix[m]>
maybe I'll try this for gpio on mcxn, the register blocks are silly simple
<Kin-o-matix[m]>
thejpster: do you feel derive-mmio kind of helps with the safety process then by avoiding the vast quantities of code the tools generate from svds? reviewing the large amount of code svd tools seem to produce for correctness seems like a drag to be honest, can't help but think some bit position issue will turn up and waste a ton of time
<thejpster[m]>
Yes. And once I’m done it’s easy to go in and remove what I’m not using.
<thejpster[m]>
I lost one hour because bitbybit::bitfield let me overlap fields, and I have an issue open to add an option to make that a compile failure. The cross checking between the bit offsets and the field size helps you get it mostly right.
<thejpster[m]>
<Kin-o-matix[m]> "this kind of suggests there's an..." <- Only if you use a hypervisor - LLVM sometimes emits an instruction that is architecturally hard to emulate in EL3.
<thejpster[m]>
The main difference is I give you functions you can see in the docs and they give you a macro! to do field projection. Kind of weird both projects started at about the same time.
<thejpster[m]>
It uses bitflags but I’m going to change it to use bitbybit bit fields because they are just better.
WoodrowDouglass[ has joined #rust-embedded
<WoodrowDouglass[>
Hello. I'd like to use some development tools written in rust to develop some bitbake packages. Can meta-rust-bin build native dev-tools?
TomB[m] has joined #rust-embedded
<TomB[m]>
<thejpster[m]> "Here’s a fully worked example..." <- This looks very C like, looks nice
KevinPFleming[m] has quit [Quit: Idle timeout reached: 172800s]
<WoodrowDouglass[>
<WoodrowDouglass[> "Hello. I'd like to use some..." <- Turns out if i just write my package like normal, and add `BBCLASSEXTEND="native"`, it all just comes out in the wash
kenny has quit [Quit: WeeChat 4.6.3]
ouilemur has quit [Quit: WeeChat 4.6.3]
RockBoynton[m] has quit [Quit: Idle timeout reached: 172800s]
i509vcb[m] has quit [Quit: Idle timeout reached: 172800s]
apirkle has joined #rust-embedded
AstraKernel[m] has joined #rust-embedded
<AstraKernel[m]>
<k3ma[m]> "Hello, I'm new to Micro Controll..." <- In which section you are in. Are you getting any error. Can you provide a screenshot