<re_irc>
<Lachlan> dirbaio: do you know how I might put the info at a set offset before the vector table, but such that it's still included in the flash image without changing the address of the entry point?
<re_irc>
<dirbaio> I don't think you can put it before the vector table, because it has to be at offset 0
<re_irc>
<dirbaio> (you can move the vector table with VTOR but it's very annoying, you need a bootloader and stuff)
<re_irc>
<dirbaio> my snippet above puts it right at the start of .text, which is immediately after the vector table
<re_irc>
<Lachlan> Ah, interesting
<re_irc>
<dirbaio> which is a known offset because the vector table is fixed size
<re_irc>
<Lachlan> Technically, I do have a bootloader
<re_irc>
<dirbaio> +(for a given chip)
<re_irc>
<Lachlan> So I'm fine with having to change VTOR/etc (already do)
<re_irc>
<dirbaio> why doesn't "after vector table, fixed offset" work for you?
<re_irc>
<Lachlan> It does, that's fine too
<re_irc>
<dirbaio> one advantage is you can use the same thing for including the build info _in the bootloader_ :)
<re_irc>
<dirbaio> vs if you moved the vector table you'd need a "bootloader for the bootloader"
<re_irc>
<Lachlan> Ah, true!
<re_irc>
<dirbaio> I do that, so my devices can self-report "bootloader version, application version" :D
<re_irc>
<James Munns> I don't have a vector table in my userspace, but you could do the same immediately after the vector table.
<re_irc>
<dirbaio> my bootloader doesn't even have the irq vectors hehe
<re_irc>
<Lachlan> The snippet earlier on results in the linker complaining about overlapping load addresses
<re_irc>
<dirbaio> Lachlan: i've copypasted and edited the entire cortex-m-rt linker script
<re_irc>
<dirbaio> dunno if it's possible to do it by "extending" it instead
<re_irc>
<Lachlan> Ah
<re_irc>
<James Munns> I think there's some hook for "after vector table, before text"
<re_irc>
<dirbaio> maybe with INSERT AFTER / INSERT BEFORE, but that stuff is super cursed
<re_irc>
<James Munns> I think the rp2040 uses it
<re_irc>
<dirbaio> honestly copypasting it is way easier
<Darius>
if you want to put some data in a specific location can't you frob the linker map?
<Darius>
that's what I've done in C to put image info (version data etc) in a fixed location that tooling can read
<re_irc>
<James Munns> (mnemos' linker script is also a copy/paste/edit of cmrt)
<re_irc>
<dirbaio> and linker script never changes, I wouldn't say copypasting it is "bad" or "tech debt"
* Darius
reads some more
<Darius>
if it complains about overlapping addresses you need to trim the other region to fit it
<re_irc>
<James Munns> nah, totally reasonable
<re_irc>
<James Munns> you might just have to redo it if you update your cmrt version
<re_irc>
<9names (@9names:matrix.org)> James Munns: We put stuff before vector table, not after it
<re_irc>
<James Munns> ah!
causal has joined #rust-embedded
<re_irc>
<Lachlan> I seem to have gotten it working by pointing "_stext" to after the build_info, and putting the build_info at an address directly after the vector table
<re_irc>
<Lachlan> The reason why I wanted to put it before the vector table is because that would make checking the signature of the binary in the bootloader easier
<re_irc>
<dirbaio> strange
<re_irc>
<dirbaio> oof, signatures:D
<re_irc>
<dirbaio> * signatures :D
<re_irc>
<Lachlan> yeah
<re_irc>
<dirbaio> nordic's stores it all out of band to avoid that problem, and I think mcuboot uses a "trailer" instead of a header
<re_irc>
<dirbaio> might be worth exploring these
<re_irc>
<Lachlan> The way I have it set up now stores it out of band
<re_irc>
<Lachlan> It seemed like it had the potential to be simpler if I put it all in the binary, but probably not
<re_irc>
<dirbaio> dunno!
<re_irc>
<dirbaio> I did get the feel nordic's was overcomplicated, so I'm storing everything inline in mine. Not doing signatures/crcs though
<re_irc>
<dirbaio> +(I check it at install time, not boot time)
<re_irc>
<dirbaio> like, storing out of band feels more complicated/dangerous because it can easily get "desynced" :D
<re_irc>
<dirbaio> +with what's really on the firmware partition
<re_irc>
<Lachlan> Exactly
<re_irc>
<dirbaio> welp, have fun
<re_irc>
<Lachlan> Figured out how to put it before the vector table
<re_irc>
<dirbaio> make sure to align the vector table, it has to be aligned to the next higher power of 2 of its size
<re_irc>
<dirbaio> which can force you to waste quite a bit of space...
<re_irc>
<Lachlan> So, like 512 bytes?
<re_irc>
<dirbaio> maybe? :P
<re_irc>
<dirbaio> yeah perhaps it's not that much if your flash is big
<re_irc>
<Lachlan> Looks like the vector table is 664 bytes, so 1k should be enough
<re_irc>
<jannic> jamwaffles: There will be another round of project grants in October
Amadiro_ has quit [Ping timeout: 272 seconds]
<re_irc>
<jamwaffles> Ah October. I've got a chance!
<re_irc>
<James Munns> it's me, I'm clippy
<re_irc>
<firefrommoonlight> Lol
<re_irc>
<firefrommoonlight> James Munns: IIRC clippy will push you into this approach, and even give you a copy+paste of your specific code, eg if you were doing it by indexing instead
<re_irc>
<James Munns> π
<re_irc>
<firefrommoonlight> I don't remember the and_then stuff
<re_irc>
<James Munns> nope
<re_irc>
<jamwaffles> I like the "and_then" solution. I still don't feel great about "copy_from_slice" panicking but it can't if it's behind a checked "get_mut" so...
<re_irc>
<jamwaffles> Thank you clippy β€οΈ
<re_irc>
<firefrommoonlight> Could you change your name here for the benefit of those who don't see this chat segment?
<re_irc>
<James Munns> Chances are it'll get optimized out
<re_irc>
<James Munns> you do the check in get_mut
<re_irc>
<James Munns> and when the compiler smooshes it all together, that panic will likely evaporate.
<re_irc>
<James Munns> (compiler is good about removing duplicate bounds checks)
inara has quit [Quit: Leaving]
<re_irc>
<James Munns> At least when they are that close in proximity to each other. Still not guaranteed I guess, but should go away at basically any opt level
<re_irc>
<dirbaio> yeah, just use indexing if you know the data fits. Much more readable
<re_irc>
<jamwaffles> And it does if you remove "--target" which is very interesting
<re_irc>
<Lachlan> Anyone want to make an issue on the rust repo about the missed optimization here?
<re_irc>
<firefrommoonlight> dirbaio: I kind of agree here, mainly because it makes the code more language-agnostic. Ie more readable for people already familiar with C etc but not Rust
<re_irc>
<firefrommoonlight> While "copy_from_slice" requires looking up docs
<re_irc>
<firefrommoonlight> This is a more universal approach IMO, but James objects
<re_irc>
<jamwaffles> This is quite far down this application's stack so I could certainly panic, but I'd prefer to make it fallible for now, even if I can make it simpler later
<re_irc>
<jamwaffles> And this app is a Rust replacement for a C incumbent so the less readable it is for C devs the better π
<re_irc>
<firefrommoonlight> lol. I think about this stuff because I've been doing a lot of C->Rust translation
<re_irc>
<dirbaio> "copy_from_slice" optimizes better though, thanks to doing a single bounds check upfront https://godbolt.org/z/s6sqGWKd6
<re_irc>
<James Munns> I'll be shipping the "real" 1.0 by monday (the 20th) at the LATEST, so if you could take it for a spin and report any bugs, I'd appreciate it!
<re_irc>
<thejpster> Jannic got a grant for RP2040 work and Debian/Rust work. I got one to make 30 Neotron boards.
<re_irc>
<therealprof> And some adamgreig is listed as mentor. π
<re_irc>
<adamgreig> not a mentor, just helped review!
<re_irc>
<James Munns> Also, there is a written wire format spec now, feel free to give it a read and let me know if you find anything confusing! https://postcard.jamesmunns.com/
<re_irc>
<adamgreig> or am I also a mentor now π¬
<re_irc>
<James Munns> (working on the "alpha.3" release right now, fixing some known bugs, should be out in the next few hours, but don't wait!)
<re_irc>
<James Munns> (that's all, thanks!)
<re_irc>
<therealprof> Oh, only an expert advisor. Never mind then...
bjc` has joined #rust-embedded
<re_irc>
<therealprof> π
VShell has joined #rust-embedded
<re_irc>
<adamgreig> thanks James Munns, nice work!
<re_irc>
<adamgreig> and congrats thejpster and jannic on the grants :D
<re_irc>
<James Munns> (oh, and I'm also working on getting the "cobs" crate to 1.0 as well, if you have any desires/bugs with _that_, lemme know too :D)
<re_irc>
<James Munns> (no more "postcard-cobs v0.1.5-pre" :D
<re_irc>
<adamgreig> for once I don't think I actually have anything else to discuss, no updates on cortex-m or embedded-hal afaik
vancz_ has joined #rust-embedded
<re_irc>
<adamgreig> anyone else have anything we need to talk about this week?
starblue has quit [*.net *.split]
bjc has quit [*.net *.split]
vancz has quit [*.net *.split]
Shell has quit [*.net *.split]
<re_irc>
<James Munns> π¦
<re_irc>
<adamgreig> a quiet week! I usually check all the rust-embedded github notifications since last week but barely any this time around
starblue has joined #rust-embedded
<re_irc>
<adamgreig> I'll need to throw some bikeshed bombs into the mix this week :P
<re_irc>
<therealprof> Yeah, tons of non-embedded stuff to do I'm afraid.
starblue has quit [Ping timeout: 246 seconds]
starblue has joined #rust-embedded
<cr1901>
Crap. I missed the meeting b/c I was distracted ._.
<re_irc>
<adamgreig> wasn't much to miss this week!
<re_irc>
<firefrommoonlight> Thoughts on stm32 PAC rel?
<re_irc>
<firefrommoonlight> Eg fix certain G0 variants
<re_irc>
<adamgreig> sorry, that's long overdue, "yes"
sknebel_ has joined #rust-embedded
agg has quit [*.net *.split]
sknebel has quit [*.net *.split]
agg has joined #rust-embedded
sknebel_ is now known as sknebel
VShell is now known as Shell
<re_irc>
<Lachlan> Does anyone know why the HASH processor on the stm32h7 isn't exposed in the rust pac for it?
<re_irc>
<dirbaio> which chip?
<re_irc>
<Lachlan> stm32H743IIT6
<re_irc>
<Lachlan> I didn't expect it in the hal, but I was surprised to see it wasn't in the pac either
<re_irc>
<dirbaio> it doesn't have HASH
<re_irc>
<Lachlan> The datasheet I'm looking at says it does