-
luojia65[m]
How is embedded-dma designed? It uses StableDeref, would Pin be acceptible here?
-
dirbaio[m]
it's very similar to Pin but not exactly the same
-
dirbaio[m]
the main problem it solves is safety against leaking (like with mem::forget)
-
thalesfragoso[m]
<luojia65[m] "How is embedded-dma designed? It"> It revolves around buffers, which are Unpin, causing Pin to not work as expected
-
thalesfragoso[m]
What could work would be to Pin the transfer, but even that there are a few problems
-
thalesfragoso[m]
That I don't know how to solve without macros
-
thalesfragoso[m]
* What could work would be to Pin the transfer, but even with that there are a few problems
-
thalesfragoso[m]
For more information about problems with Pin, see
rust-embedded/embedonomicon #64
-
thalesfragoso[m]
Which reminds me that I still need to fix the docs, I completely forgot about that, damn
-
MathiasKoch[m]
<uep[m] "> <@mathias_koch:matrix.org> How"> Aha.. That's a bummer! I had it working previously, but after updating vscode or R-A, unknown which one? it seems to have broken :(
-
uep[m]
see the workaround above
-
uep[m]
that's fine for me / now
-
MathiasKoch[m]
Ahh.. cool! Missed that it was related to this. Thanks!
-
-
riskable[m]
Is there a way I can configure `cargo run` with probe-rtt so that it flashes via dfu but still debugs over the ST-LINK? I'm just trying to make the default in my code base to flash with DFU so end users don't *need* to have an ST-LINK in order to update the firmware.
-
disasm[m]
Write a script that flashes via DFU and then run cargo-embed or something?
-
disasm[m]
riskable: ^
-
riskable[m]
Yeah I was thinking about doing that but I thought maybe there was maybe a better way
-
disasm[m]
Better in what sense?
-
diondokter[m]
I don't know if it's possible but maybe you can run bash with the .cargo/config.toml runner property?
-
disasm[m]
You just call `cargo run` and this scripts does the job
-
disasm[m]
<diondokter[m] "I don't know if it's possible bu"> Yes, this
-
diondokter[m]
Ah ok
-
diondokter[m]
Or you could do it more cross platform with powershell 😉
-
Lumpio-
How is powershell more cross platform lol
-
dirbaio[m]
works everywhere! it's even opensource now! microsoft are now the good guys! yay
-
dirbaio[m]
-
jschievink
what is that preview icon?
-
dirbaio[m]
good question 🤷♂️
-
mdrobnak[m]
Something from marix.org
-
mdrobnak[m]
-
dirbaio[m]
matrix proxies the images, it's probably some github user's avatar
-
mdrobnak[m]
Ah, ok that's just an on-demand render
-
adamgreig-m
-
adamgreig-m
it's not someone's avatar...
-
adamgreig-m
well I mean it's an avatar
-
adamgreig-m
in the original sense I suppose
-
jschievink
oh wow it's actually an official image :D
-
jschievink
cute
-
adamgreig-m
maybe i should install powershell after all :p
-
dirbaio[m]
oh lol
-
adamgreig-m
-
adamgreig-m
why and how matrix pulled that out though i have no idea
-
dirbaio[m]
-
dirbaio[m]
in repo settings: " Social preview Upload an image to customize your repository’s social media preview. "
-
dirbaio[m]
TIL that exists haha
-
adamgreig-m
aah of course. wild that they don't show the social preview image anywhere on the actual html page
-
adamgreig-m
though i guess this is much nicer than the default where twitter github links include my avatar in huge instead which is quite offputting
-
jamesmunns[m]
adamgreig: I've updated
rust-embedded/wg #449, though I ended up disagreeing with one of your points.
-
jamesmunns[m]
I likely won't be around fully during the meeting, but happy to discuss async on comments (and I'll have my ipad open while cooking dinner)
-
riskable[m]
Is it possible to put an stm32f4 into DFU mode via software? So if a user presses a certain key combo on my keyboard it goes into DFU mode?
-
jamesmunns[m]
I'd like to put a soft limit on proposing any new changes to the MSRV management I described, unless there is something internally inconsistent with the policy I proposed. I understand if people don't *like* the behavior I proposed, but I don't see any other way of "connecting the dots" without just making *different* tradeoffs
-
jamesmunns[m]
<riskable[m] "Is it possible to put an stm32f4"> Which STM32F4? But generally yes, let me find you an example
-
riskable[m]
jamesmunns: stm32f401/stm32f411
-
riskable[m]
I mean, I just started putting the schema together so I can still choose a different MCU :)
-
adamgreig-m
jamesmunns: thanks!
-
therealprof[m]
<riskable[m] "Is it possible to put an stm32f4"> Possibly.
-
jamesmunns[m]
-
riskable[m]
jamesmunns: Awesome, thanks! Looking at that now
-
therealprof[m]
TIL I learned what "Chibi" style is.
-
jamesmunns[m]
There's me doing it for the F405, using an internal implementation detail of `panic-persist`, where it sets a RAM flag when a panic occurs
-
therealprof[m]
* TIL what "Chibi" style is.
-
adamgreig-m
you might find the relevant address is different on the F411/401, but the idea is the same
-
-
jamesmunns[m]
For some reason, that didn't *always* work on the F405 (or at least it was much more reliable on the stm32f072), which might be because this would be better to do in a `naked` assembly function.
-
jamesmunns[m]
but yeah, adamgreig is right, there's an app note that gives you the values you need for the stack pointer and jump-to location
-
jamesmunns[m]
You might also consider resetting the vector table and stack pointer back to the "right" location if you don't jump to bootloader. I'm not sure how "clean" the bootloader leaves the operating environment
-
jamesmunns[m]
(but then definitely do that in ASM, not Rust)
-
adamgreig-m
if you don't jump to the bootloader, you shouldn't need to touch vtor/sp i wouldn't have thought
-
jamesmunns[m]
I meant if the bootloader moved them, and expected you to put them back
-
adamgreig-m
if the bootloader has touched them your code won't be running though
-
jamesmunns[m]
all the vendor C startup code I've seen manually sets the VTOR and SP
-
adamgreig-m
hmm, unless you can ask the bootloader to jump into your code over dfu?
-
adamgreig-m
i thought you could just reset
-
jamesmunns[m]
No idea, I'm guessing at that.
-
jamesmunns[m]
it was flaky, that was all I knew for sure. Never found out why.
-
adamgreig-m
the built in bootloader doesn't run at boot on the stm32, only if you manually jump to it somehow
-
adamgreig-m
(unlike some platforms where the bootloader ROM always runs first and can decide whether or not to jump to your code)
-
timokrgr[m]
I got burned by this before, the STM32F1 ROM bootloader also modifies VTOR and you gotto reset them manually
-
adamgreig-m
manually setting vtor and sp always seems like such a cludge to me but i guess welcome to embedded
-
adamgreig-m
timokrgr: were you asking the f1 bootloader to jump back to your code without going through a reset/
-
adamgreig-m
* timokrgr: were you asking the f1 bootloader to jump back to your code without going through a reset?
-
timokrgr[m]
yes
-
adamgreig-m
<adamgreig-m "manually setting vtor and sp alw"> to be clear, I mean doing this on every boot, irregardless of whether it should be needed
-
adamgreig-m
timokrgr: I guess that's fair then, since vtor needs to be correct for the bootloader to service interrupts, kind of handy that it sets it itself perhaps
-
jamesmunns[m]
Does dfu util command this after a program?
-
adamgreig-m
but in the USB DFU bootloader case I don't think you can ask it to jump to your code, only to reset, which should clear vtor... aiui
-
jamesmunns[m]
To jump to the new image?
-
timokrgr[m]
adamgreig: yeah I agree
-
jamesmunns[m]
We should probably offer that as an opt in feature for cmrt
-
timokrgr[m]
why have a dedicated GO command and not reset VTOR? ST shenanigan :D
-
jamesmunns[m]
To set things we shouldn't have to set
-
adamgreig-m
so dfu-util supports sending a 'detach' request which should trigger a reset
-
adamgreig-m
st's protocol description also says they support a non-standard "2. Leave DFU is achieved by a 0 data download request followed by GetStatus request and device reset." which triggers "jump to application address and exit DFU mode"
-
adamgreig-m
so possibly you can wrangle it into jumping to your code but I think the usual thing is a reset
-
jamesmunns[m]
-
adamgreig-m
-
jamesmunns[m]
That's dfu-util command I used
-
adamgreig-m
aah, `:leave` instead of `-e`
-
adamgreig-m
wonder what it does to the device
-
jamesmunns[m]
Nb: I have no idea what I'm doing with dfu-util, so I probably just copied that from someone else's project :p
-
adamgreig-m
the other nice thing you can do is implement DFU in your device's USB descriptor and handle just the 'detach' event, so you can use dfu-util to trigger your not-in-bootloader device to jump to bootloader
-
-
-
adamgreig-m
-
jamesmunns[m]
Does this mean that leave SHOULD work?
-
adamgreig-m
leave should work, but you do need to set VTOR yourself if you're doing it
-
adamgreig-m
assuming dfu-util correctly does the things that st require, which I guess is likely
-
thalesfragoso[m]
[adamgreig](
matrix.to/#/@adamgreig:matrix.org) don't we want to remove the (not working) deprecated warning from cortex-m ?
-
adamgreig-m
though on this stm32f0 it causes it to re-enter the bootloader, heh
-
adamgreig-m
thalesfragoso: yep i think so
-
adamgreig-m
agenda for upcoming meeting is
hackmd.io/hz2ImTjZQA2qJWShrb9bxA if anyone wants to add items
-
adamgreig-m
thalesfragoso: from 0.7, you mean?
-
thalesfragoso[m]
Yeah, I mean, it shouldn't be breaking, but doesn't make sense to leave it there anyways
-
thalesfragoso[m]
It doesn't work and breaks CI on nightly
-
dirbaio[m]
anyone got a smoltcp dns implementation? can't find much online
-
adamgreig-m
thanks, I've pushed an update removing the deprecation warning
-
adamgreig-m
@room meeting in 5 min, please sign in add anything you'd like to discuss to the agenda:
hackmd.io/hz2ImTjZQA2qJWShrb9bxA
-
adamgreig-m
ok, let's get started!
-
adamgreig-m
as far as I know there's no update on the REC issue, if eldruin is around later or we have time at the end let's come back to that
-
adamgreig-m
jamesmunns updated the MSRV policy PR here:
rust-embedded/wg #449 which is now ready for voting
-
adamgreig-m
the new scorched earth alternative of throwing msrv in the bin certainly has appeal, hah
-
jamesmunns[m]
I'm sort of at this point
-
adamgreig-m
on balance I think you're right, handle dependencies that bump our MSRV by pinning a max version of that dependency and soon/simultaneously releasing a new semver bump that increases our MSRV, and that is just how we handle that edge case
-
jamesmunns[m]
We have provided little to no value (in my opinion) for discussing it or maintaining it, and I don't think that has changed since April (!!!) since I originally wrote this RFC.
-
therealprof[m]
I'm surprised to hear that.
-
disasm[m]
<adamgreig-m "on balance I think you're right,"> It's a mistake the RISC-V team already made and got dependency hell for half a year
-
jamesmunns[m]
I think MSRV leads to "pick your poison".
-
jschievink
this doesn't really sit right with me, do any other crates do something like this?
-
jamesmunns[m]
I honestly think keeping things simple and "must build for the last three stable releases at the time of crate release" would be a much better and simpler policy.
-
jschievink
shouldn't the MSRV policy be picked such that no dependencies have a looser MSRV?
-
adamgreig-m
jschievink: the problem is we don't control all our dependencies
-
jschievink
because if not, what's the worth that our policy adds?
-
jschievink
I'm aware
-
adamgreig-m
so they could and have released semver-trivial updates that break our msrv, at which point we have no good options really
-
adamgreig-m
jamesmunns: is that meaningfully different?
-
jamesmunns[m]
ehhh ignore me
-
jamesmunns[m]
I'm not proposing any new MSRV policies.
-
adamgreig-m
I guess the key difference is it means we can ignore dependencies changing after release, heh
-
jschievink
to a user, it doesn't matter if our code or our dependencies caused breakage, so I don't see how a policy that ignores dependencies is useful
-
jamesmunns[m]
I definitely think disasm and jschievink have salient points (though I think my RFC addresses how we handle dependencies)
-
jamesmunns[m]
* I honestly think keeping things simple and "must build for the last three stable releases at the time of crate release" would be a much better and simpler policy.
-
jamesmunns[m]
Edit: Don't listen to this.
-
therealprof[m]
My main surprise here is that not having a strict MSRV policy would that not counter the idea of having something like sealed Rust?
-
jamesmunns[m]
Sealed Rust is likely to require paid/maintained third party support (if for no other reason than certification), so pushing that on open source maintainers is undesirable and likely unhelpful.
-
jamesmunns[m]
or rather
-
adamgreig-m
in the situation where a dependency releases an update after us which breaks our released crate's msrv, can the end user just pin the earlier version of the dependency themselves? perhaps that's a reasonable thing to ask of someone wanting an older msrv to work
-
jamesmunns[m]
to use libraries in a safety criticial context, they are likely to require documentation, due diligence, and process that is unlikely to be useful for general purpose open source development.
-
jamesmunns[m]
If you can use off the shelf open source libraries: You probably don't need sealed rust, IMO.
-
therealprof[m]
Interesting.
-
adamgreig-m
or at the very least you can vendor them all yourself and therefore not get msrv surprises
-
jamesmunns[m]
Also that
-
jamesmunns[m]
Taking open source "in house" and writing your own docs and verification plan is also totally a legit option
-
jamesmunns[m]
OR: If the desire to have them certified is enough, a company that is getting paid to maintain that (and deal with all the pain in the ass work or multiple release trains) should be doing that and contributing back to open source.
-
jamesmunns[m]
Don't let me derail the meeting though. I'm always happy to share my opinions on less limited time.
-
adamgreig-m
still, I don't want us to just not care and release say cortex-m 0.7 that requires a week-old rustc
-
therealprof[m]
I've never been a fan of MSRV. It's a rather strange concept causing a lot of effort and providing little benefit; especially for a well working environment like Rust.
-
jamesmunns[m]
I sorta disagree, but that's me.
-
adamgreig-m
or to take a PR that incidentally uses some new feature that bumps msrv to something very new without much benefit, perhaps
-
adamgreig-m
would you basically be happy just so long as it builds on current stable at the time of release?
-
jamesmunns[m]
Sorry for sabotaging my own RFC, but the fact that this has been in open discussion since April sort of makes me agree with therealprof more strongly
-
jamesmunns[m]
<adamgreig-m "would you basically be happy jus"> Yeah, honestly.
-
jamesmunns[m]
Again, I'm not the maintainer of these crates, so take my opinions with a grain of salt
-
jamesmunns[m]
If someone complains, I will be happy to offer them an LTS service contract for any of the WG crates, or refer them to other contractors who could
-
disasm[m]
<adamgreig-m "would you basically be happy jus"> Fix: works, not builds ;)
-
therealprof[m]
I think it's far more important to ensure forward compatibility than backwards compatibility, yeah.
-
jamesmunns[m]
But I don't like the idea of asking OSS maintainers to bend over backwards for LTS
-
adamgreig-m
disasm: if only we had some sort of hardware-in-loop testing :p
-
jamesmunns[m]
IM WORKING ON IT, OKAY
-
adamgreig-m
<jamesmunns[m] "But I don't like the idea of ask"> yea, that's totally fair and quite appealing
-
jamesmunns[m]
:D
-
adamgreig-m
though perhaps you have a slight conflict of interest :p
-
jamesmunns[m]
Sure! Feel free not to point people my way.
-
adamgreig-m
well, maybe the thing is to do a second very simple PR suggesting nuking the MSRV and vote between them?
-
jamesmunns[m]
Lots of other folks doing great embedded-rust contracting work. I'd be happy to point folks to Hanno Braun or eldruin, who also do excellent work.
-
adamgreig-m
I don't think your opinion is any less valid
-
jamesmunns[m]
(also thanks to therealprof for bringing up sealed rust, I saw that in the scroll buffer a while back, and wanted to weigh in on that, but forgot)
-
adamgreig-m
if there's no strong interest in maintaining MSRVs and there is interest in using newer rustc features, perhaps dumping the msrv policy is the way forward
-
adamgreig-m
at least maybe an rfc about it might get some comments from anyone who actually benefits from it
-
jamesmunns[m]
There's certainly a cost to maintaining one.
-
adamgreig-m
which I think we're sort of lacking at the moment, beyond hypothetical users
-
therealprof[m]
I'm always hoping someone comes forward with a strong opinion so I don't have to forge one. 😛
-
adamgreig-m
ok, shall I put together a very minimal alternative rfc, specifically also asking for feedback from anyone benefitting from having msrv, and see what we get?
-
jamesmunns[m]
Yeah, explicit 👍️ to making a "nuke the MSRV" RFC.
-
adamgreig-m
(and open it for voting immediately too, no need to wait I don't think, it will be at least 2 weeks before we have a majority vote I expect)
-
jamesmunns[m]
I do think we should keep periodic CI tests for the current stable rust version
-
jamesmunns[m]
in case some dependency decides to intro an unstable features
-
jamesmunns[m]
but outside that, yolo
-
adamgreig-m
yea, just need to add some sort of cron entry to the new github actions stuff
-
adamgreig-m
and some sort of email altering for it I guess, or maybe it could open an issue for us :p
-
therealprof[m]
<jamesmunns[m] "I do think we should keep period"> Yes, that's quite important. You don't want to find forward breakage only if someone PRs a change.
-
adamgreig-m
ok, thanks
-
adamgreig-m
any last comments/thoughts on msrv?
-
jamesmunns[m]
good riddance
-
therealprof[m]
lol
-
jamesmunns[m]
(another 25 minutes lost to msrv)
-
thalesfragoso[m]
We might even test an "expected MSRV" for documentation purposes
-
jschievink
and we still cant use `rustup install stable-3`, so the MSRV requires periodic bumps anyways :|
-
adamgreig-m
jschievink: not if the msrv is just "stable" :p
-
jschievink
yup :)
-
thalesfragoso[m]
* We might even want to test an "expected MSRV" for documentation purposes
-
thalesfragoso[m]
Maybe find another name other than MSRV for that, it got a bit burned, heh
-
jamesmunns[m]
eh, if we don't care, let's explicitly not care.
-
adamgreig-m
"minimum suggested rust version"
-
adamgreig-m
ok, let's move on to the next agenda bits, we can come back if there's time after
-
adamgreig-m
cortex-m 0.7 is in principle ready to go I think:
rust-embedded/cortex-m #286
-
disasm[m]
End of the Delay impl copy-paste, finally!
-
adamgreig-m
haha yep it's been a while coming
-
adamgreig-m
hopefully we can move towards 1.0 after this
-
adamgreig-m
though we'll see, might be a few things worth tidying up
-
adamgreig-m
should also allow moving to bare-metal 1.0
-
adamgreig-m
the main questions for c-m 0.7 is whether we're missing anything we should get in, and whether the changelog is missing anything we already got in :p
-
therealprof[m]
I'll check later.
-
adamgreig-m
this has all the breaking changes we've been accumulating since 0.6.1 or so
-
therealprof[m]
I just noticed I've been asked to review it, oops. ;)
-
adamgreig-m
there's some nuisance in that a lot of wg crates depend on cortex-m <0.7, so they'll all need updating when/if they still build with 0.7
-
adamgreig-m
I said "a lot" but it's not that many really. there's more in the generic ecosystem.
-
adamgreig-m
-
adamgreig-m
* I said "a lot" but it's not that many really. there's more in the general ecosystem.
-
disasm[m]
I believe lots of them can use 0.6 and 0.7 at the same time
-
adamgreig-m
lots of them could but I don't think any have a cargo.toml that would allow it
-
adamgreig-m
(since that would be pretty naughty to have specified before 0.7 was even released)
-
therealprof[m]
premature anticipation? 😀
-
adamgreig-m
I guess my point is: each breaking release requires a lot of other crates to eventually update their dependencies, so ideally we wouldn't do them all the time, but this one is long overdue
-
therealprof[m]
... or a good crystal ball.
-
therealprof[m]
Indeed.
-
therealprof[m]
Let's get that shipped ASAP.
-
adamgreig-m
ok, if there's any other comments please drop them on the PR
-
adamgreig-m
for the remaining time I wanted to see if anyone wanted to chat about
rust-embedded/svd2rust #478#issuecomment-724732527
-
jschievink
have people tested cortex-m master? I'm still somewhat uneasy about having 0 integration tests
-
disasm[m]
I don't see any good reason to not make breaking changes, everyone can still use older svd2rust versions to generate the code if they don't like the newer ones
-
japaric[m]
re: 478 I have not read the whole thread but would it be possible to make write's closure's return type generic so that it accepts both `()` (statement) and `&mut W` -- unsure if that would even compile
-
disasm[m]
Also think about this: people make positive changes, they spend their time on implementation, so this implementation already has value. Ignoring it just because it's not "valuable enough" is really strange.
-
disasm[m]
It's not a hacktober fest PR after all
-
jschievink
it is fair to reject minor improvements over widespread breakage imo
-
jschievink
provided it is deemed too minor to be worth the breakage
-
disasm[m]
I think that the breakage itself is overestimated
-
jschievink
but I'm not sure if embedded rust is at that point yet
-
yatekii[m]
how is it widespread breakage tho? svd2rust is only used once to generate the PAC, then the PAC is fixed without a new release, so I don't see much issue here?
-
yatekii[m]
(genuinely curious :))
-
jschievink
<japaric[m] "re: 478 I have not read the whol"> seems like it doesn't, because the return type would have to contain a higher-ranked lifetime bound by the closure's FnOnce bound
-
therealprof[m]
<disasm[m] "Also think about this: people ma"> No one is ignoring anyone.
-
japaric[m]
<jschievink "seems like it doesn't, because t"> hmm, yeah. this does compile
play.rust-lang.org/?version=stable&…st=29358fd7d9a016c5c28c1c1cfa9babba but that generic `'a` feels not right
-
jschievink
I don't think you could call that closure with the right argument lifetime though
-
japaric[m]
yep, the closure argument cannot be called (`let mut w = W; f(&mut w);` within `write` doesn't compile)
-
adamgreig-m
yatekii: yea, the breakage is when the PACs update (for example to cover more registers), and choose to use the latest svd2rust, and then all the HALs need to do a load of small syntax changes to get them to build with the new PAC version
-
adamgreig-m
so it creates work for HAL maintainers and for users directly using the PACs
-
adamgreig-m
but it's not work they have to undertake until they want to use the new versions of the PAC
-
yatekii[m]
ok, I totally see that one :)
-
adamgreig-m
beyond that specific and relatively simple breaking change I worry a bit more about the idea that svd2rust doesn't really have a clear long-term plan or policy for breaking changes
-
adamgreig-m
perhaps the plan is basically "svd2rust is more or less stable, so we won't make non-bug-fix changes that aren't really necessary, because it's now widely used and good enough"
-
therealprof[m]
Yeah, that.
-
-
yatekii[m]
Tho, I feel like if the change is actually seen as an improvement by the majority of folks it is better doing it sooner than later. Not having a strong opionion which one I'd like more :)
-
adamgreig-m
or perhaps it's "anything better would have to be so radically different we need to experiment with it out-of-tree, see if it's popular, and then consider swapping over to it wholesale"
-
adamgreig-m
it's fair to not just accept whatever breaking changes come along if they're not in the direction we want to go, but it's harder to explain that if we don't know what the direction is either
-
therealprof[m]
I think if we make a breaking change we need to have a complete remodel.
-
adamgreig-m
certainly for this particular change i think it would be fair to go either way; it's not a complicated break and it does make the api a little nicer, but it is a breaking change that would require a bunch of mechanical changes
-
disasm[m]
Also svd2rust is version 0.17.0, so about ~16 breaking releases already
-
adamgreig-m
if we were currently releasing a few breaking changes every few months it would definitely get included, no doubt
-
jschievink
would this be the one and only breaking change in the next release?
-
adamgreig-m
but we're not, the last was 10 months ago and that didn't even break existing code iirc
-
therealprof[m]
disasm: Not really correct.
-
adamgreig-m
jschievink: we have the Nr/InterruptNumber thing pending, and some small msp430 breaks, I think
-
jschievink
okay, seems fine to bundle them up then
-
therealprof[m]
That's not really an general API brreakage.
-
therealprof[m]
* That's not really an general API breakage.
-
therealprof[m]
If we break the API we're going to split the whole ecosystem which is really bad.
-
jschievink
hmm
-
adamgreig-m
I'm not sure when the last API breakage was, but they're very rare
-
jschievink
it seems to be that this change would not really split the whole ecosystem, since PACs/HALs can update at their leisure
-
jschievink
* it seems to me that this change would not really split the whole ecosystem, since PACs/HALs can update at their leisure
-
disasm[m]
HALs "split the ecosystem" in pretty the same way
-
jschievink
so it's no like in async land where tokio uses one set of traits and has one reactor, and the rest uses entirely different foundations
-
therealprof[m]
You also have have applications and helper crates like stm32-usbd which might also be affected.
-
therealprof[m]
disasm: Not rreally.
-
therealprof[m]
* disasm: Not really.
-
jschievink
hmm, yeah, stm32-usbd is a good example
-
disasm[m]
<therealprof[m] "disasm: Not rreally."> Explain then please
-
adamgreig-m
I think stm32-usbd is a bad example, doesn't it vendor its own pac entirely?
-
jschievink
oh
-
disasm[m]
It does, but before it did this was a huge pain
-
disasm[m]
But for different reason
-
therealprof[m]
disasm: Well, that was your claim; I haven't seen that yet. Or do you mean different APIs for different families?
-
adamgreig-m
because the types were wrong for cross-device compat?
-
disasm[m]
<therealprof[m] "disasm: Well, that was your clai"> Some HALs update their API in a breaking way and it's not a huge problem in general
-
therealprof[m]
disasm: That happens rarely and not wholesale. PAC updates are also breaking but they often don't require any or only minor changes.
-
disasm[m]
<adamgreig-m "because the types were wrong for"> Because it depended on multiple hal versions at once and it was painful to update stm32-usbd each time one of the HALs releases a new version. But yeah, different PACs were incompatible too
-
disasm[m]
<therealprof[m] "disasm: That happens rarely and "> But you still have to fix something in your code, like RCC setup. Is that a lot different from pac register accesses?
-
therealprof[m]
Again rarely.
-
disasm[m]
You don't usually notice it because it's an easy change and it's distributed
-
therealprof[m]
Also PACs are different because they're forwarded by the HAL. If you access a PAC in an application through the HAL it will usually just work with a dependency bump of the HAL and you don't need to worry.
-
therealprof[m]
If the PAC changes the interface that's a whole different story.
-
adamgreig-m
no one's denying that people will have to make some changes when they update to a newer PAC/HAL, whether they're HAL authors or end users
-
adamgreig-m
quite possibly people will have to do so anyway for the Nr thing
-
disasm[m]
<therealprof[m] "Also PACs are different because "> It's not something that breaks accidentally, you have to update the HAL version explicitly. And it's ok to get different API in this case
-
therealprof[m]
I disagree.
-
disasm[m]
That's how semver works
-
disasm[m]
And we don't have "stable" channels like Rust does
-
therealprof[m]
Breaking the API for a minor feelgood change is not a good idea.
-
disasm[m]
Is there a rule that forces all users to only use the latest svd2rust to build pacs?
-
disasm[m]
Don't like the release? Wait until the next one you like
-
yatekii[m]
<disasm[m] "Is there a rule that forces all "> no, but it would default to this, which I guess most fear will cause lots of confusion :)
-
therealprof[m]
disasm: I agree you can do that technically. I disagree is that this should be done lightly because it's technically okay.
-
therealprof[m]
The next release will be kind of mandatory due to the Nr change.
-
adamgreig-m
(we're out of time for the meeting, sorry, I didn't notice)
-
disasm[m]
Well, I think that the main point is that we don't have understanding of the development direction
-
disasm[m]
And we have problems due to this
-
adamgreig-m
right, I think if we had a better handle on that it would be much easier to make a decision about this pr
-
therealprof[m]
Indeed we don't.
-
adamgreig-m
if we're "still doing active development, we expect there might be more breaking changes coming, we're working on things", then the pr seems really good to merge
-
adamgreig-m
if we're "basically done, stable, bug fixes, maybe one day we'll change the whole thing for 1.0 or just swap everyone to a new project", no point accepting it
-
adamgreig-m
if we're sort of somewhere in the middle it's harder :p
-
therealprof[m]
Maybe. But if we're breaking things we could go into a completely different direction altogether.
-
disasm[m]
Why people are thinking in a way that 1.0 is the end of the world?
-
therealprof[m]
It's not? 😛
-
disasm[m]
Like, "we should do everything before 1.0 and then stop"
-
adamgreig-m
at one point we were hoping to get to 1.0 really soon so we could have a stable set of 1.0 releases and start planning some very different 2.0s
-
adamgreig-m
which honestly sounds like a nicer place to be, so we can get all three digits of sember to be meaningful again, heh
-
disasm[m]
But what actually changes? You still have semver, but one more digit for differentiating between "minor release" and "patch-fix release"
-
therealprof[m]
We could actually just call it 1.0 now.
-
adamgreig-m
I think part of the problem of answering "what's the development direction" is also "who are the developers"
-
therealprof[m]
Right.
-
disasm[m]
What I really liked about EWG ecosystem is fast development pace, and making these super-stable 1.0 releases basically destroys this.
-
therealprof[m]
svd2rust is pretty much that. A rock in the ecosystem.
-
therealprof[m]
It's not perfect but it's used all over the map.
-
disasm[m]
It wasn't a rock, I remember these times
-
adamgreig-m
but there's definitely lots of things people want to change about it, it's just become (as one of the comments called it) weighed down by its dependants
-
disasm[m]
Remember, therealprof asked me to join the tools team to help with lots of svd2rust PRs :)
-
therealprof[m]
Honestly we haven't had that many changes which were turned down.
-
therealprof[m]
Yes, tons of good and compatible improvements which needed reviewing.
-
therealprof[m]
But what's being complained about now is that there's not checklist of things to do next or roadmap.
-
jschievink
I have some opinions on that
-
jschievink
But they get very close to "delete svd2rust and rewrite it from scratch"
-
jschievink
So I'm not sure how helpful that is
-
disasm[m]
<therealprof[m] "Yes, tons of good and compatible"> Some of them changed API in a breaking, but good way. For example,
riscv-rust/e310x-hal 3edab54
-
adamgreig-m
svd3rust :D
-
therealprof[m]
disasm: Yeah, but not cortex-m.
-
adamgreig-m
that change definitely affected cortex-m?
-
disasm[m]
<jschievink "But they get very close to "dele"> Actually I want to do something similar
-
adamgreig-m
it's where the union types changed to method calls right?
-
therealprof[m]
jschievink: Very much. I think that's the way to go.
-
disasm[m]
<adamgreig-m "that change definitely affected "> It technically affected hal, why are you asking about cortex-m?
-
adamgreig-m
disasm: I'm just saying that the change there affected all users, not just riscv
-
disasm[m]
Well, let's stop making breaking changes, they affect all users
-
therealprof[m]
The other architectures were bolted on later (and technically shouldn't even be using it) so assuming the same sort of API stability is weird.
-
therealprof[m]
<disasm[m] "Well, let's stop making breaking"> I feel you're missing the point. It's all about unjustified breaking changes out of the blue.
-
adamgreig-m
disasm: sorry!! I agree with you here, I was replying to therealprof who I thought was suggesting your link only related to risc-v
-
yatekii[m]
Hmm why rewrite the svd2rust tooling completely. I mean I am complaining about the API a lot, but what would actually change; I don't know too much specifics here :/
-
disasm[m]
And you're about to release a new cortex-m version with breaking changes "for the whole ecosystem"
-
adamgreig-m
yea, including the huge Nr/InterruptNumber churn
-
therealprof[m]
Who are we doing that for again? 😛
-
adamgreig-m
yatekii: well, hopefully you could keep most of the tooling and backend, it's the generated api that most wants to change
-
therealprof[m]
It's not exactly that we're making that change lightly but because there's an actual need to do it. And that's the difference between nice-to-have and a requirement.
-
disasm[m]
Well, I think I'm done with my thoughts here. Anyone interested in my vision of PAC v2.0 concept?
-
adamgreig-m
I am, but I have to run for now
-
therealprof[m]
disasm: Absolutely.
-
adamgreig-m
does it start by rewriting stm32ral in rust :p
-
adamgreig-m
(bbl)
-
disasm[m]
Not really :D
-
yatekii[m]
<disasm[m] "Well, I think I'm done with my t"> yes :D
-
disasm[m]
Well, the main idea is to separate ownership and register access. Completely, maybe into a separate crates. The idea is to have a stable "base" with peripherals to provide ownership, but moving "register access" crate to access the peripherals
-
disasm[m]
This enables one to use different register accessors for the same peripherals
-
disasm[m]
For example, you can update "pac" in a non-breaking way in each hal, you can fix bugs in register definitions without breaking HAL API, because PAC will not be reexported
-
therealprof[m]
How'd that work?
-
disasm[m]
Also, you can build only a subset of register accessors, only those you actually need
-
therealprof[m]
And how is ownership realised or are you giving up on the concept?
-
disasm[m]
Well, you can implement you own set of functions, "deref" and whatever you need to access the peripheral
-
disasm[m]
<therealprof[m] "And how is ownership realised or"> Ownership is implemented in the very same way as before: you get the Peripheral structure in a singleton way and get separate peripherals from it
-
disasm[m]
But this structure, as well as the peripherals, know nothing about register access layer
-
disasm[m]
You can use svd2rust layer, stm32ral layer or whatever you like
-
therealprof[m]
Hm...
-
disasm[m]
The peripheral crate will be super-stable, and it's easy to achieve, because peripheral usually don't appear out of the blue
-
disasm[m]
* The peripheral crate will be super-stable, and it's easy to achieve, because peripherals usually don't appear out of the blue
-
therealprof[m]
Well, don't tell that to ST. ;)
-
kevlan[m]
What level of abstraction would the peripheral crate provide?
-
disasm[m]
Only the Peripheral structure and ZST peripheral types
-
yatekii[m]
<therealprof[m] "Well, don't tell that to ST. ;)"> XD kekd
-
disasm[m]
That's basically it
-
therealprof[m]
I guess there're three main points for me such a new concept has to deliver: Register documentation, compile speed, code efficiency for non-optimized code.
-
disasm[m]
Sure, it should be at least not worse
-
therealprof[m]
The only item of those three which is currently provided by svd2rust is barely acceptable documentation.
-
therealprof[m]
The other two points are abysmal.
-
therealprof[m]
I'm very much okay with anything else including the API.
-
disasm[m]
I think that the first one is too, documentation became much worse in terms of usability
-
jschievink
svd2rust's API is incredibly hard to understand, even for people who are working with it for a long time
-
disasm[m]
The `Reg` concept made it almost unusable
-
disasm[m]
<jschievink "svd2rust's API is incredibly har"> Switch to stm32ral :D
-
jschievink
I don't even use STM much :D
-
Lumpio-
It works with anything
-
Lumpio-
They need to change the name
-
disasm[m]
Yep, basically everything that is ARM :D
-
therealprof[m]
<jschievink "svd2rust's API is incredibly har"> I don't think so. I've also explained it to a lot of people and they understood and liked it.
-
jschievink
Well, survivorship bias makes this hard to judge
-
yatekii[m]
I agree with jschievink on this one :) Maybe I am just below average IQ then :)
-
therealprof[m]
Heh.
-
adamgreig-m
<Lumpio- "They need to change the name"> Heh, I should probably have written a generic svd2ral and then used it in stm32ral but, well, hindsight
-
jschievink
-
yatekii[m]
I mean the API is not all bad. what I struggle most with is that there is a basic trait with generics which is implemented like 10k times for all the different regs and it's hard to find the right call for anything related to that. And everytime I have to figure this out anew. I did not work with it nearly as much as you folks did, so my sample might be an outlier :)
-
jschievink
mhmm, and that is a workaround for slow compile times, I believe
-
jschievink
(ironically running straight into other compile time issues in rustc)
-
adamgreig-m
It looks like rustdoc is getting some work that should specifically help svd2rust crates
-
adamgreig-m
I guess they are sort of especially pathological
-
yatekii[m]
I'll praise the day intuitive type links hit in rustdoc =) I think this is still nightly tho
-
jschievink
rustc build times are also very poor imo
-
jschievink
I always get annoyed when I have to rebuild PACs for something
-
yatekii[m]
yeah, I mean I can live with build times personnally, but I guess the impact on things like r-a matter to me very much :)
-
jschievink
yup, r-a is also taking a fair while longer on PACs than on most other crates
-
GrantM11235
Has anyone made some sort of abstraction that works on both mcu peripherals and spi/i2c peripherals?
-
GrantM11235
They both involve reading/writing/rmw-ing registers
-
adamgreig-m
<jschievink "I always get annoyed when I have"> This was a major motivator for stm32ral which is about 3s to build from cold
-
jschievink
yeah, I know
-
jschievink
it should be a primary goal of whatever svd2rust's successor will be
-
adamgreig-m
Oh, any replacement for svd2rust should probably address dereferenceable etc
-
jschievink
svd2rust is literally impossible to use for some chips because of this
-
jschievink
yeah, that too
-
andodeki[m]
hey guys am new here and also new to hardware coming from sofware dev background
-
andodeki[m]
what's preferable to start out with in C or Rust??
-
disasm[m]
<adamgreig-m "Oh, any replacement for svd2rust"> What do you mean?
-
jschievink
not using references to registers and register blocks
-
adamgreig-m
Not using references into mmio addresses anyway
-
disasm[m]
Hmm, interesting. Anything I can read about the impact?
-
adamgreig-m
I had some vague ideas for doing it in ral but didn't implement any yet
-
disasm[m]
I guess raw pointers are ok
-
adamgreig-m
-
adamgreig-m
Raw pointers are probably the only thing that's ok, just passing them into read_volatile etc
-
ian_rees[m]
andodeki - are you comfortable with C or Rust already?
-
andodeki[m]
ian_rees I am comfortable with C
-
therealprof[m]
If we had non-multiple-of-8-bits native types we could do really smooth things.
-
yatekii[m]
<adamgreig-m "Not using references into mmio a"> why is this bad?
-
adamgreig-m
<disasm[m] "Well, the main idea is to separa"> This was sort of my hope with the nosync feature in ral but only ever did the ral half
-
adamgreig-m
But it seems nice that the actual register access is globally available and always unsafe, and a hal or other ownership structure wraps unsafe access in a way that ensures single use
-
adamgreig-m
But it's not clear how you enforce that globally (eg if users just use two such wrappers in one project), maybe using a pre-agreed links key in cargo
-
disasm[m]
You still have ownership
-
adamgreig-m
<yatekii[m] "why is this bad?"> Check that wg pr I linked, the gist is rust may insert extra reads to them at any time, which might have side effects
-
adamgreig-m
<disasm[m] "You still have ownership"> Managed by the register access layer?
-
disasm[m]
<adamgreig-m "But it's not clear how you enfor"> You can't create two wrappers in a safe way, because you have only one peripheral "object"
-
adamgreig-m
Oh, maybe I gave the layers the wrong way around, would you sort of give that single peripheral object to the register access layer?
-
disasm[m]
<adamgreig-m "Oh, maybe I gave the layers the "> Yes, sure
-
yatekii[m]
<adamgreig-m "Check that wg pr I linked, the g"> oh sorry, missed that one, thanks, will read! sounds kinda bad, but folks warned me on discord that references can have sideeffects if you do not actually treat it as the reference rustc does :)
-
adamgreig-m
It's not clear it has ever caused any actual problem
-
adamgreig-m
But at least theoretically it could
-
disasm[m]
<disasm[m] "Yes, sure"> Either by wrapping or with deref, but register access layer should not allow you to get round the ownership
-
disasm[m]
I don't think it's possible to implement Deref due to the orphan rule, but anyway, the idea is "to achieve register access via a trait method"
-
ian_rees[m]
andodeki: I work on firmware for a living, almost all in C, and am fairly new to Rust. Embedded Rust has been fun so far, and is very promising, but it's a steep learning curve. There is a whole lot of C-based example code available, including Arduino (C++ but with lots of helper).
-
andodeki[m]
ian_rees thanks man
-
andodeki[m]
I agree lots of material in C than Rust
-
ian_rees[m]
no problem, I guess the answer depends on what you're looking to do. If I were just starting out and considering a career in embedded, I'd be tempted to go the Rust route. If your goal is just to get something working for a hobby project, probably Arduino.
-
jschievink
LLVM does definitely use `dereferenceable` for optimizations (just checked, there's several uses that look like they can become issues in practice)
-
andodeki[m]
ian_rees I am seriously considering a career in embedded I have been hearing lots of Rust in hardware so was curious how the future of C and Rust in hardware is.
-
yatekii[m]
andodeki: at this point nobody can really tell, as we are still trying out what's best in Rust in a lot of ways, but there is a lot of folks already using rust embedded production :)
-
andodeki[m]
yatekii: thanks for the response.
-
yatekii[m]
I, personally, would never go back. I do have to for some clients :)
-
andodeki[m]
<yatekii[m] "I, personally, would never go ba"> 🤣🤣
-
ian_rees[m]
I imagine that a person who's proficient in Rust would not have a hard time learning C, but it would feel dirty
-
andodeki[m]
<ian_rees[m] "I imagine that a person who's pr"> oooh really
-
yatekii[m]
I mean only with Rust I actually learned to code properly. before it was a hot mess even tho, back then, I would have insisted on the contrary :) does not mean my code is proper today tho :D
-
ian_rees[m]
kinda general career advice: having a skill set that's useful but relatively rare (maybe an uncommon combination of fields or technologies) can be a good thing
-
andodeki[m]
<ian_rees[m] "kinda general career advice: hav"> I see sounds good
-
andodeki[m]
<yatekii[m] "I mean only with Rust I actually"> it's a strict language huh?
-
pinealservo[m]
Rust's path of least resistance is to write code that would generally also work well in C. C isn't particularly strict but requires you to provide your own discipline which you have to be taught somehow, either through painful experience or good example code or a mentor or something.
-
yatekii[m]
^ this
-
therealprof[m]
For embedded uses C is only easier if you're buying into an existing ecosystem. If not then Rust much easier to get started.
-
andodeki[m]
<pinealservo[m] "Rust's path of least resistance "> insightful pinealservo🤔
-
andodeki[m]
<therealprof[m] "For embedded uses C is only easi"> at the expense of painfully experience as pinealservo pointed out
-
jschievink
I have some time for rust-embedded stuff now, do we want to do the big cortex-m merge before 0.7?
-
dirbaio[m]
I have lots of panic message strings bloating my .rodata
-
dirbaio[m]
even building with release, LTO, and with panic-probe
-
therealprof[m]
dirbaio: Avoid panicing branches wherever possible.
-
dirbaio[m]
yeah but many are in library code
-
therealprof[m]
Fix the libraries. ;)
-
dirbaio[m]
is there really no way for the compiler to see these are unused?
-
therealprof[m]
Nope.
-
dirbaio[m]
😱
-
dirbaio[m]
😱😱
-
jschievink
I don't think there's any fundamental reason it can't see that
-
jschievink
it's just that the panic entry points are always considered cold, and there's too much indirection in the panic arguments
-
dirbaio[m]
maybe because core comes prebuilt?
-
dirbaio[m]
is it prebuilt without LTO?
-
jschievink
not sure
-
jschievink
it should be LTO-enabled at least
-
therealprof[m]
Getting rid of the tons of indirections in panic! calls is currently WIP.
-
dirbaio[m]
maybe monkeypatching core somehow
-
therealprof[m]
More like directly using the most apropriate code for the task at hand.
-
therealprof[m]
* More like directly using the most appropriate code for the task at hand.
-
dirbaio[m]
everything panics in rust! I can't rewrite the world
-
therealprof[m]
It really shouldn't.
-
dirbaio[m]
even reading from a slice it's easy to get a bounds check that calls panic
-
dirbaio[m]
sure I can add my own bounds check before, and hope it'll cause the compiler to optimize out its own
-
therealprof[m]
Or use iterators.
-
dirbaio[m]
but still
-
therealprof[m]
-
therealprof[m]
panic is now a const item and things are being reworked to be much leaner. I'm not following everything that's going on but it looks as if it could turn into a profit for embedded as well.
-
therealprof[m]
Still, panicking code is bad style, especially panicking library code.
-
dirbaio[m]
say I have some complex datastructure/algorithm
-
dirbaio[m]
and if the program gets into a certain state that means I got a bug
-
dirbaio[m]
shouldn't I use panic in that case?
-
therealprof[m]
No.
-
therealprof[m]
Unless you can't code your code in a resilient way.
-
jschievink
what? that's definitely a place where you should panic
-
therealprof[m]
A panic really means: There's no clean way out of a situation.
-
jschievink
that sounds like something where an assertion would fail
-
dirbaio[m]
sometimes there IS no clean way out
-
dirbaio[m]
and many of these are panics that I know will never be hit at runtime once i've got rid of all bugs
-
dirbaio[m]
but the compiler can't still prove it
-
dirbaio[m]
* but the compiler still can't prove it
-
jschievink
> C++ requires implementations to detect UB during constexpr evaluation
-
jschievink
wow, cool
-
therealprof[m]
If you say so.
-
dirbaio[m]
let's replace them all with `unsafe { core::intrinsics::unreachable_unchecked() }` :D
-
dirbaio[m]
(jk)
-
therealprof[m]
The only situation I every recall where there was no way out if when I ran out of memory I needed to tell the user I ran out of memory.
-
therealprof[m]
* The only situation I every recall where there was no way out is when I ran out of memory I needed to tell the user I ran out of memory.
-
therealprof[m]
* The only situation I ever recall where there was no way out is when I ran out of memory I needed to tell the user I ran out of memory.
-
therealprof[m]
But hey, feel free to panic wherever you like. I'm not going to stop you...
-
thalesfragoso[m]
<dirbaio[m] "is there really no way for the c"> `panic-halt` usually works for me, I can't remember a time when it didn't
-
dirbaio[m]
how are you building?
-
dirbaio[m]
LTO? any special sauce thing?
-
therealprof[m]
Uhm, nope doesn't.
-
-
dirbaio[m]
and if you `panic!("foo")` you don't get "foo" in your ".rodata"?
-
thalesfragoso[m]
hmm, I usually just check if I get formatting, not strings
-
thalesfragoso[m]
do you still get formatting code ?
-
therealprof[m]
Yes.
-
dirbaio[m]
yeah, with panic-probe I don't get any of the `fmt` code
-
dirbaio[m]
but I still get the strings
-
thalesfragoso[m]
let me try with panic-halt
-
-
-
dirbaio[m]
loads the string, calls panic
-
dirbaio[m]
panic does nothing with the string
-
dirbaio[m]
it's also quite frustrating that it's 10 bytes when it could be 2 🤷♂️
-
-
jschievink
std-aware cargo could also help with this, since you could then turn on `feature = "panic_immediate_abort"`
-
dirbaio[m]
I messed with it a while ago but didn't find any way to enable std/core featuers
-
dirbaio[m]
has that changed?
-
dirbaio[m]
-Zbuild-std-features
-
dirbaio[m]
ooooooooooooh
-
jschievink
oh right you're on nightly anyways
-
thalesfragoso[m]
Hmm, just tested here, I actually get 10B of panic_fmt, probably didn't notice before since it's close to nothing
-
thalesfragoso[m]
but I don't get nothing on rodata
-
thalesfragoso[m]
and if I don't panic it seems that rust inlines my main (for the very simple test I have)
-
thalesfragoso[m]
which saves a few bytes more
-
therealprof[m]
Yeah, but panic_halt alone doesn't give you anything.
-
dirbaio[m]
LTO + `-Zbuild-std=core -Zbuild-std-features=panic_immediate_abort`
-
dirbaio[m]
aaaaaand panic strings are gone!!!
-
dirbaio[m]
YES
-
jschievink
nice!
-
jschievink
this also disables the inline(never) annotations
-
dirbaio[m]
`-Zbuild-std` seems broken if using lto + overflow_checks though
-
dirbaio[m]
* `-Zbuild-std` seems broken with lto + overflow_checks though
-
thalesfragoso[m]
<jschievink "this also disables the inline(ne"> just on core ? or all code ?
-
jschievink
on the panic entry points
-
jschievink
in core
-
jschievink
nothing else
-
thalesfragoso[m]
got it
-
dirbaio[m]
it builds compiler_builtins with overflow_checks, which results in it having panic calls, which apparently is not okay
-
jschievink
yeah, sounds reasonable
-
jschievink
compiler_builtins is `#![no_core]` I believe
-
jschievink
huh, no, just no_std
-
-
dirbaio[m]
wat
-
dirbaio[m]
but still better than before
-
therealprof[m]
🤷♂️
-
jschievink
probably the result of an abort intrinsic followed by an unreachable intrinsic when trap-unreachable is enabled
-
jschievink
we will turn trap-unreachable off once the loop misoptimizations are fixed
-
therealprof[m]
Hm, I don't see any difference with those options on Cortex-M.
-
jschievink
huh, how did to turn off TrapUnreachable?
-
jschievink
I thought that wasn't configurable
-
jschievink
oh you mean `-Zbuild-std-features`
-
dirbaio[m]
now this is weird:
-
dirbaio[m]
this works: cortex-m/inline-asm + -Zbuild-std=core -Zbuild-std-features=panic_immediate_abort
-
dirbaio[m]
this fails: cortex-m/inline-asm + -Zbuild-std=core -Zbuild-std-features=panic_immediate_abort
-
dirbaio[m]
* now this is weird:
-
dirbaio[m]
this works: cortex-m/inline-asm + -Zbuild-std=core -Zbuild-std-features=panic_immediate_abort
-
dirbaio[m]
this fails: cortex-m/inline-asm
-
dirbaio[m]
with
-
-
dirbaio[m]
no indication of where, but I guess it's in `cortex_m::asm::udf()`
-
jschievink
hwat
-
dirbaio[m]
llvm_asm!("udf" :::: "volatile");
-
dirbaio[m]
it wants `udf #0xfe`
-
dirbaio[m]
but `asm!("udf");` works
-
jschievink
oh, I think we fixed that on master
-
dirbaio[m]
ah no it doesn't
-
dirbaio[m]
true, master has `udf #0`
-
dirbaio[m]
cool
-
dirbaio[m]
no idea why `-Zbuild-std` affects it tho
-
jschievink
yeah that is weird
-
therealprof[m]
return -ETOOMUCHMAGIC
-
dirbaio[m]
writing my own panic_handler that calls `udf`, I still get panic strings
-
dirbaio[m]
so the problem is not panic-probe
-
dirbaio[m]
I can only get rid of panic strings with `-Zbuild-std=core -Zbuild-std-features=panic_immediate_abort`
-
dirbaio[m]
i'm cursed
-
thalesfragoso[m]
probably the `inline(never)` obscures stuff
-
thalesfragoso[m]
Have you tried `panic-halt` ? just for kicks
-
thalesfragoso[m]
I didn't get strings with that
-
thalesfragoso[m]
but it was a very simplistic example
-
jschievink
yes, this is pretty cursed in my experience as well :)
-
jschievink
panic-halt sometimes does and sometimes doesn't include the strings
-
dirbaio[m]
nope, still get strings with panic-halt
-
therealprof[m]
I'll always get strings with panic-halt as shown above.
-
dirbaio[m]
even with `-Zbuild-std=core -Zbuild-std-features=panic_immediate_abort` ?
-
therealprof[m]
Yes, even then but that was a one-off check. I don't really care about esoteric nightly options. I do run code size tests for all releases and some nightly regularly for comparison.
-
dirbaio[m]
🤷♂️
-
dirbaio[m]
panic_immediate_abort does work solidly for me it seems
-
dirbaio[m]
solid 10% binary size reduction!
-
-
jschievink
what if you use panic-halt but without the fence?
-
jschievink
only `loop {}`
-
jschievink
I wonder if putting `#[inline]` on the panic handler does anything :)
-
dirbaio[m]
lemme try
-
dirbaio[m]
well it's already being inlined
-
-
adamgreig-m
-
dirbaio[m]
has nrf-softdevice, smoltcp, ppp driver, ethernet driver, our custom protocol with crypto shit, a "tiny VM script interpreter"
-
dirbaio[m]
and I'm still not done :S
-
adamgreig-m
how much flash do you have?
-
dirbaio[m]
nrf52840
-
dirbaio[m]
1mb
-
dirbaio[m]
* 1mbyte
-
dirbaio[m]
but I have to fit softdevice, 2 oartitions of the app firmware for DFU, bootloader, config data
-
dirbaio[m]
so unfortunately space is tight 😂
-
adamgreig-m
fun
-
dirbaio[m]
<jschievink "what if you use panic-halt but w"> exactly the same as my `udf` panic
-
dirbaio[m]
because loop{} becomes udf hah
-
jschievink
hmm, even on the current nightly?
-
jschievink
because `loop {}` should be fixed there
-
dirbaio[m]
rustc 1.49.0-nightly (25f6938da 2020-11-09)
-
yatekii[m]
<dirbaio[m] "has nrf-softdevice, smoltcp, ppp"> sounds like basically what we want too, except I dooubt anyone is willing to learn rust ... they want async tho
-
adamgreig-m
hah, i left my scope on from before the meeting by mistake and it entered screensaver, forgot keysight included a portal easter egg
imgur.com/a/Eb3nPRu
-
yatekii[m]
also sound like we finally need to implement page hashing :D
-
dirbaio[m]
`udf`, `loop{}` and `loop{fence}` give me essentially the same binary
-
yatekii[m]
xd nicd
-
jschievink
<adamgreig-m "hah, i left my scope on from bef"> wow :D
-
adamgreig-m
it scrolls a bunch of portal 2 quotes and swaps between ascii cake and ascii keysight logo
-
adamgreig-m
while printing the names of presumably the dev team
-
jschievink
hmm, how do we plan on tagging releases in the cortex-m monorepo?
-
jschievink
with a prefix per crate?
-
adamgreig-m
that's what i've done so far
-
adamgreig-m
for c-m-sh
-
adamgreig-m
and p-sh
-
jschievink
have you recreated the tags for old releases?
-
adamgreig-m
though i had left c-m itself unprefixed
-
dirbaio[m]
welp back to optimizing other shit
-
dirbaio[m]
still got strings left, but they're from somewhere else now
-
adamgreig-m
no, it doesn't have the history anyway
-
adamgreig-m
the changelog points to the old repository and tags, and the old url remains valid
-
jschievink
oh, right
-
adamgreig-m
we could have done a subtree merge i guess
-
adamgreig-m
shrug
-
adamgreig-m
might be more worthwhile for c-m-rt if we merge that too
-
jschievink
currently importing panic-itm
-
jschievink
will do rt afterwards
-
jschievink
I know that miri was merged into rustc via history merge
-
jschievink
so now we have 2 "initial commit"s there :)
-
jschievink
the linux kernel has like 4
-
adamgreig-m
yea
-
adamgreig-m
-
adamgreig-m
i force merged my old PR to add the note to readme
-
adamgreig-m
don't need to replace ci with a dummy job, just turned off branch protection instead :p
-
dirbaio[m]
is there a problem in running a `thumbv7em-none-eabi` in a cortex-m4f?
-
dirbaio[m]
eabihf is 1kb larger lol
-
adamgreig-m
it's fine
-
adamgreig-m
cortex-m-rt won't enable the FPU though
-
adamgreig-m
in fact I think rustc won't
-
adamgreig-m
so no hardware floating point
-
dirbaio[m]
yeah I'm not using floats
-
adamgreig-m
no problem then
-
dirbaio[m]
so eabi is a strict subset
-
dirbaio[m]
* so eabi is a strict subset of eabihf
-
dirbaio[m]
that's very neat
-
adamgreig-m
you could even see if thumbv6m-none-eabi is smaller
-
jschievink
<adamgreig-m "don't need to replace ci with a "> yeah I can't do that
-
adamgreig-m
it's actually a different ABI
-
adamgreig-m
the instructions are the same
-
dirbaio[m]
esy
-
dirbaio[m]
* wat
-
adamgreig-m
in C, you can use hardware floating point while using the eabi (non-hf) ABI
-
jschievink
in Rust, -hf will use FPU instructions, non-hf will not
-
adamgreig-m
in rust, our eabihf target tells rustc to do hardware fp, and also tells cortex-m-rt to enable the fpu at startup
-
adamgreig-m
but the real difference is in how you pass float arguments to function calls
-
adamgreig-m
in hf they go in the float registers
-
jschievink
1kb larger seems like a lot, the additional code should be way smaller than that
-
adamgreig-m
what _is_ a strict subset is thumbv6m-none-eabi < thumbv7m-none-eabi < thumbv7em-none-eabi
-
adamgreig-m
i.e. you can run all the thumbv6 instructions on a cortex-m4f
-
dirbaio[m]
haha build fails because I'm using
github.com/Emill/X25519-Cortex-M4
-
dirbaio[m]
which requires v7em
-
adamgreig-m
ah, fair
-
adamgreig-m
I would doubt v6 will be smaller anyway
-
dirbaio[m]
and it'd definitely be slower right?
-
adamgreig-m
it has fewer instructions but they take the same space to encode, so some sequences will just require more instructions -> more flash used
-
adamgreig-m
it wouldn't be faster
-
adamgreig-m
1kb does seem a big difference admittedly, wonder what's causing it
-
dirbaio[m]
:shrug
-
adamgreig-m
hmm, guess I should release c-m 0.7
-
dirbaio[m]
* 🤷♂️
-
adamgreig-m
i hope it's less cursed than the last two c-m-sh releases
-
thalesfragoso[m]
> <@dirbaio:matrix.org> haha build fails because I'm using
github.com/Emill/X25519-Cortex-M4
-
thalesfragoso[m]
> which requires v7em
-
thalesfragoso[m]
You wouldn't be able to use v6 anyways, because of the atomics...
-
therealprof[m]
Yeah, v6 is quite limited.
-
dirbaio[m]
damn atomics xD
-
therealprof[m]
No long branch targets, no int division, no CAS.
-
-
thalesfragoso[m]
Manufacturers to like the M0/M0+ alot though :/
-
-
thalesfragoso[m]
* Manufacturers do like the M0/M0+ alot though :/
-
adamgreig-m
ok, cortex-m v0.7.0 published and tagged
-
adamgreig-m
brace for impact :p
-
thalesfragoso[m]
No division is also tough ugh
-
therealprof[m]
It's not that bad, I love the M0 but one should be aware of the ristrictions and things the compiler won't work around like odd divisions.
-
yatekii[m]
huh?
-
therealprof[m]
On the plus side rustc won't go out of it's way to bloat the code for you just to make it faster...
-
jschievink
dirbaio: have you played around with the inlining threshold?
-
dirbaio[m]
nope
-
jschievink
that might help if you're using `-Os`
-
adamgreig-m
you might try -Oz too I guess
-
adamgreig-m
though it seems like -Os is usually better anyway somehow
-
therealprof[m]
-Os in rust is not that great
-
therealprof[m]
Seems the compiler options haven't really been tweaked to give a nice small binary size.
-
thalesfragoso[m]
<therealprof[m] "-Os in rust is not that great"> I have found it to be similar to clang's Oz, although I haven't used clang for embedded all that much
-
thalesfragoso[m]
just a few tests tbh
-
thalesfragoso[m]
<adamgreig-m "ok, cortex-m v0.7.0 published an"> heh, that `const-fn` feature sure took its time
-
-
dirbaio[m]
I did it!! 100% size reduction!! 🎉
-
adamgreig-m
hahaha
-
dirbaio[m]
what the fuck broke
-
adamgreig-m
perfect, done, home time
-
therealprof[m]
<thalesfragoso[m] "I have found it to be similar to"> I don't really have any comparison between clang and rust. I just noticed from analyzing various options that the rust options are not picking up a lot of low hanging fruit.
-
therealprof[m]
And for whatever reason if you go thumbv7m instead of thumbv6m rustc really goes nuts.
-
thalesfragoso[m]
Hmm, I sure haven't look all that much at the generated code in that regards
-
therealprof[m]
Easily observable by the memcpy done by r0.
-
thalesfragoso[m]
only for looking for holes
-
therealprof[m]
Rustc is like: Oh, this loop sure looks like a memcpy so let's replace it with one. Hey look, we even have a "go fast" implementation for that so let's just paste it in and call it day.
-
thalesfragoso[m]
"gotta go fast, don't mind Os"
-
therealprof[m]
Yeah.