<hyphened[m]>
The code is on Github repo, give me a sec to get the links
<JamesMunns[m]>
either way, taking a lot more contextual info, using GDB and breakpoints, to capture register states and things like that around the spooky bits is usually helpful
<holo[m]>
hyphened[m]: i try but compiler didnt like it too
<hyphened[m]>
I was experimenting with dynamic linker scripts based on target so I removed it and spun my own
<hyphened[m]>
I think I can switch back in like 5 mins if you want
<dirbaio[m]>
🍿👀
<hyphened[m]>
But mainly I just initialize BSS and DATA, then clocks, enable the coprocessor and jump to user main code
<hyphened[m]>
The initialization assembly is copied directly from cortex-m-rt (quite shamelessly) 😁
<JamesMunns[m]>
Yeah, some of your init stuff and linker script could maybe not be sound
<JamesMunns[m]>
like "doing init in Rust" is generally not accepted to be sound
<JamesMunns[m]>
dunno if it's the cause of your problem
<hyphened[m]>
Could be
<hyphened[m]>
What bothers me is that it fails only when the function is not inlined
<hyphened[m]>
Cause if it was linker script or init it would fail both times, because all resources are in the same positions
<hyphened[m]>
IDEK
<JamesMunns[m]>
hyphened[m]: undefined behavior is not required to follow any logic or rules
<JamesMunns[m]>
Also i'm a little unclear how you're building your vector table (or the difference between the stack you put in your vector table, vs vector table 0/stack 0?)
<JamesMunns[m]>
It would be useful for you to look at:
<JamesMunns[m]>
* `nm -nSC` to make sure all the symbols are ending up where you expect them to
<JamesMunns[m]>
* objcopy to a bin to make sure your vector table and stuff look reasonable to you
<JamesMunns[m]>
I'm not sure what the ABI of your CPU looks like and how vector tables and stuff are supposed to be assembled, compared to "standard" single core cortex-m parts
<hyphened[m]>
JamesMunns[m]: There are 3 Vector Tables (when going to unsecure mode there will be 2 more), one for the Reset, until it bootstraps, then 1 for core 0 (along with its stack, which will be protected) and 1 for core1 (same as core 0), the exception handlers are copied from the reset one
<hyphened[m]>
This is to account for different memory regions and different cores and operation modes
<hyphened[m]>
JamesMunns[m]: Core 0 behaves like a single core, core 1 jumps to wahtever address you give it
<JamesMunns[m]>
Gotcha! And the stack pointer all looks good according to GDB on init, and just before you go off the edge?
<hyphened[m]>
JamesMunns[m]: Yeah mostly
<hyphened[m]>
(╯°□°)╯︵ ┻━┻
<JamesMunns[m]>
what does mostly mean lol
<hyphened[m]>
If i comment line 147 (engine.finish()) everything works again even if not inlined
<hyphened[m]>
And I just realized that I'm not protecting the VTable with the MPU
<JamesMunns[m]>
really just saying: undefined behavior is spooky and can break unrelated things for any reason it feels like
<JamesMunns[m]>
like, if your code is doing spooky things, the compiler is probably having a field day
<hyphened[m]>
Yeap, it's both fun and distressing at the same time
<hyphened[m]>
JamesMunns[m]: 🤣🤣
<hyphened[m]>
i'm gonna steal that one
<JamesMunns[m]>
I'd probably suggest:
<JamesMunns[m]>
* go back to cortex-m-rt, it's a well reviewed, solid starting foundation
<JamesMunns[m]>
* be real careful and verify each thing you do in the startup sequence, especially around linker script layout, memory initialization, and vector table assembly (at compiler or startup time)
<JamesMunns[m]>
take small steps, one at a time, and lots of git commits, so you can step and diff
<JamesMunns[m]>
I don't have any specific "a hah that's the problem", but a lot of that startup code looks sus, and you really shouldn't be initializing rust with rust, the abstract machine requires that "the world makes sense" before Rust starts executing
<JamesMunns[m]>
yeah, we used to do this, and it generally worked, EXCEPT when you started merging the `c-m-rt` code INTO your application project, at which point rustc would start "seeing through walls" and miscompiling UB
<JamesMunns[m]>
though that was long ago, and it might even be more aggressive now.
<dirbaio[m]>
that was needed in the 0.2 days to force different traits to have the same error type (for example `where T: InputPin<Error = E> + OutputPin<Error = E>`)
<dirbaio[m]>
the 1.0 traits are designed so you never need that anymore
<dirbaio[m]>
s/never/rarely/
<holo[m]>
it was so easy with your advice to satisfy compiler 🙂
<JamesMunns[m]>
Hey Peter Hansen it looks like the outlining fix SHOULD be in the next nightly, could you give it a spin tomorrow?
dngrs[m] has joined #rust-embedded
<dngrs[m]>
Supertrait: the hero we need
<dngrs[m]>
<holo[m]> "image.png" <- btw code screenshots have a few disadvantages (screen readers get left out, they take more space, can't be found by search or copy pasted to edit/comment on, etc). You can post syntax highlighted code by putting it in triple backticks and adding `rust` to the first backticks, like so:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/BBzoqJiAQrqafAUQgpSFPzJj>)
<dngrs[m]>
in related QOL news, if you want a less ad-polluted pastebin than pastebin dot com there is https://dpaste.org/
sirhcel[m] has quit [Quit: Idle timeout reached: 172800s]
notgull has quit [Ping timeout: 260 seconds]
leonardvdj[m] has quit [Quit: Idle timeout reached: 172800s]
<holo[m]>
<dngrs[m]> "btw code screenshots have a..." <- i was using this but somone told me to not paste block of codes
<holo[m]>
holo[m]: i will be using it again in that case
<JamesMunns[m]>
I mean like 3-4 line snippets are fine
<JamesMunns[m]>
You were posting like 20-40+ lines or whole files when I asked you to please not do that.
<holo[m]>
JamesMunns[m]: ahh ok, undestand now
<JamesMunns[m]>
Still, linking to a repo by line is still likely nicer.
ragarnoy[m] has quit [Quit: Idle timeout reached: 172800s]
<vollbrecht[m]>
element auto detects long code sections and box them for scrolling(if you put them in a code section), though i don't know how good that works on other client's, so in general best to not assume that it works for everybody