glitchy has quit [Remote host closed the connection]
glitchy has joined #rust-embedded
mkj[m] has joined #rust-embedded
<mkj[m]>
some interesting embedded rust here. https://news.ycombinator.com/item?id=44971998 "For now we've hardcoded Bosch, Bafang, Brose and a few others (more coming), and we plan to open-source the communication protocol soon so that anyone can upload their own WASM code on the battery to talk to any [bike battery] controller!"
<mkj[m]>
* some interesting embedded rust here. https://news.ycombinator.com/item?id=44971998 "For now we've hardcoded Bosch, Bafang, Brose and a few others (more coming), and we plan to open-source the communication protocol soon so that anyone can upload their own WASM code on the battery to talk to any \[bike motor\] controller!"
sroemer has joined #rust-embedded
<thejpster[m]>
I have an AM243x Launchpad and I got Rust going on the R5. The problem is the R5 can only let the debugger read memory when stopped, so RTT doesn’t work.
<danielb[m]>
Stop-mode rtt is still a pretty okay thing if you dont have anything else
<diondokter[m]>
danielb[m]: Isn't semihosting better then? That at least gives a signal to the debugger when there's data
<danielb[m]>
Semihosting is net terrible
<danielb[m]>
Current formatted semihosting needs to trigger a breakpoint for every single fragment, try dumping an array like that 😅
<diondokter[m]>
Oh yeah, that's awful.
<diondokter[m]>
Adding a buffer (à lá RTT) in between probably works better
<diondokter[m]>
s/lá/la/
<danielb[m]>
* formatted semihosting print needs to
<danielb[m]>
Also the debugger needs to notice the breakpoint
<diondokter[m]>
Is that slower than reading memory?
<danielb[m]>
No, it just depends on when the drbugger decides to poll
<diondokter[m]>
Right
M9names[m] has joined #rust-embedded
<M9names[m]>
I expect it's less time for halt-read-run than brkpt-wait-read-run, the only benefit for breakpoint is the firmware chooses the halt position
<M9names[m]>
Can you use SWO thejpster ?
<danielb[m]>
Yeah rtt can be very intrusive, we had several issues caused by randomly halting firmware
glitchy has quit [Remote host closed the connection]
<danielb[m]>
Which is also a very good test method lol
glitchy has joined #rust-embedded
tschundler has quit [Server closed connection]
tschundler has joined #rust-embedded
thenightmail has quit [Server closed connection]
thenightmail has joined #rust-embedded
majors has quit [Server closed connection]
majors has joined #rust-embedded
glitchy has quit [Remote host closed the connection]
glitchy has joined #rust-embedded
<thejpster[m]>
<M9names[m]> Can you use SWO thejpster ?
<thejpster[m]>
I don’t think so. Pretty sure it was JTAG.
<thejpster[m]>
I think you can do RTT on the M4 core and IPC it from the R5 to the M4. I just haven’t had the time to try.
<thejpster[m]>
That would also mean loading code to RAM using the M4, which would need to take the R5 out of reset.
JamesMunns[m] has quit [Quit: Idle timeout reached: 172800s]
corecode[m] has joined #rust-embedded
<corecode[m]>
is there any way to allocate and initialize a struct on the heap?
<corecode[m]>
i'm getting a stack overflow because of my huge application state struct
<diondokter[m]>
corecode[m]: Yes, but you're not gonna like it
JamesMunns[m] has joined #rust-embedded
<JamesMunns[m]>
You can allocate a MaybeUninit, and unsafely initialize it in place
<TomB[m]>
alternatively... write the stack region with a pattern, periodically walk the stack region for where the pattern has been over written using asm at your initialization vector
<TomB[m]>
* alternatively... write the stack region with a pattern, periodically walk the stack region for where the pattern has been over written. Using asm at your initialization vector to do this prior to using rust/c type stuff.
<corecode[m]>
oh man this is terrible, i need close to O(N^2) stack size, because every ::new allocates everything on the stack
<MartinSivk[m]>
I prefer the flip stack approach, it hard faults on overflow :)
<corecode[m]>
or at least 2N
<JamesMunns[m]>
TomB[m]: I think the cortex-m crate has a stack painting feature? I'm not sure if probe-rs supports automatically checking it
<corecode[m]>
yea i just enabled stack limits and now i'm here
<TomB[m]>
JamesMunns[m]: nice to know!
<MartinSivk[m]>
corecode: Been there too.. in place init language support would have been nice
<corecode[m]>
yea this is a problem. i don't want to pay 2N stack size
<JamesMunns[m]>
MartinSivk[m]: It is being worked on, atm, but not like, "this week/month"
<TomB[m]>
mpu regioning the stack is another option for some devices (zephyr uses this) though I think newer armv8m supports some sort of stack limit and exception
<MartinSivk[m]>
My use case was a framebuffer structure for ESP32S3 SPI attached RAM.. encapsulated unsafe and pinning helped
<corecode[m]>
yes, i have that
<corecode[m]>
very convenient to find it
andar1an has joined #rust-embedded
<corecode[m]>
this is my main app state
<JamesMunns[m]>
I expect it to get quite a bit better over the next year or so, rust-for-linux and c/c++ interop folks are all pushing for improvements on in-place construction
<MartinSivk[m]>
Yeah, we are using the latest and greatest so it is expected stuff gets rough :D
<JamesMunns[m]>
(that doesn't help today, but Soon™️ hopefully!)
<TomB[m]>
this is for like static initializers and .data type stuff? or is this to avoid the "move" that kind of happens for fn new(some_params: P) -> Self
<TomB[m]>
* this is for like static initializers and .data type stuff? or is this to avoid the "move" (copy) that kind of happens for fn new(some\_params: P) -> Self
<TomB[m]>
* this is for like static initializers and .data type stuff? or is this to avoid the "move" (copy) that kind of happens for fn new(some\_params: P) -> Self?
<corecode[m]>
new returning self
<corecode[m]>
in several levels
<corecode[m]>
machine dependent owns machine independent state
<corecode[m]>
seems every new needs all of the members on the stack in order to then copy it into the parent stack frame?
<TomB[m]>
yikes
<corecode[m]>
yes yikes
<TomB[m]>
well when it doubt make it a global... can't waste/use excessive memory accidently if its already pre-allocated and maybe even pre-initialized in the elf in .bss/.data
<TomB[m]>
s/it/in/
<corecode[m]>
i don't have const new
<TomB[m]>
unsafe all the things with global mutable statics
<TomB[m]>
back to the stone ages
<TomB[m]>
wonder if misra-rust ever came about it'd have a rule akin to the stack allocated dynamically sized array rules for C...
<JamesMunns[m]>
that's for `alloca`, right? Rust just doesn't have that, and it's somewhat hard to even sort of do that safely
<TomB[m]>
alloca or vla
<corecode[m]>
meh and gdb ptype/o doesn't work. says my type is dynamic
<corecode[m]>
is there some tool that will show my type size (and paddings?)
<corecode[m]>
i'm surprised that my app state is over 700 bytes
<JamesMunns[m]>
`core::mem::size_of::<T>()`?
<corecode[m]>
yea i mean a more recursive way of figuring out the components
<corecode[m]>
like what gdb's ptype/o should do
thalesfragoso[m] has joined #rust-embedded
<thalesfragoso[m]>
corecode[m]: r-a shows sizes on rover.
<thalesfragoso[m]>
* r-a shows sizes on hover.
<thalesfragoso[m]>
I mean, when you hover on the type definition.
<thalesfragoso[m]>
<JamesMunns[m]> that's for `alloca`, right? Rust just doesn't have that, and it's somewhat hard to even sort of do that safely
<thalesfragoso[m]>
It does (did?) have something on unstable, namely unsize_locals. But I remember they wanted to split that into unsized function parameters and alloca like stuff.
<thalesfragoso[m]>
Since the unsized parameters were the most important.
<corecode[m]>
thanks for the hint with hover
<corecode[m]>
unfortunately it shows the mock sizes -_-
<thalesfragoso[m]>
mock?
<mkj[m]>
RUSTFLAGS="-Zprint-type-sizes" cargo +nightly build will print all the sizes of everything
<corecode[m]>
thanks
<corecode[m]>
thalesfragoso: yes, i use mocks for testing
<thalesfragoso[m]>
<thalesfragoso[m]> Since the unsized parameters were the most important.
<thalesfragoso[m]>
It's even used in libstd to implement FnOnce for Box<dyn FnOnce>.
<thalesfragoso[m]>
* It's even used in libstd to implement FnOnce for Box<dyn FnOnce> .
<thalesfragoso[m]>
What, element doesn't let me write `Box<dyn FnOnce>`...
ouilemur has quit [Quit: WeeChat 4.7.0]
Kaspar[m] has quit [Quit: Idle timeout reached: 172800s]
<thejpster[m]>
<vollbrecht[m]> did you set a filename extension or use a blank name?...
<thejpster[m]>
I think it has to be called .bat or .cmd on Windows, so I called it .cmd.
<thejpster[m]>
Linux and macOS seem to execute it in the default shell, despite a lack of shebang, which surprised me
<thejpster[m]>
really wish cargo let me set a runner according to the host target, not just the cross-compile target
<thejpster[m]>
the other option was making a rust program called qemu-defmt which you could install, and it would spawn qemu and grab the output and defmt decode it. The reason I can't just put a long command line in as the runner is that I need to pass the filename to both qemu and defmt-print, and the runner string doesn't do variable expansion - it only tacks the filename on as the last argument.
<thejpster[m]>
also, this example now not only runs Rust on ThreadX on Arm Cortex-R5, but also adds defmt over semihosting.
mort has quit [Server closed connection]
<whitequark[cis]>
<thejpster[m]> Linux and macOS seem to execute it in the default shell, despite a lack of shebang, which surprised me
<whitequark[cis]>
this is a shell feature, not OS feature
mort has joined #rust-embedded
andar1an has quit [Ping timeout: 248 seconds]
andar1an has joined #rust-embedded
glitchy has quit [Remote host closed the connection]
glitchy has joined #rust-embedded
wassasin[m] has joined #rust-embedded
<wassasin[m]>
Monthly whine that workspaces with mixed targets are terrible
<vollbrecht[m]>
we need something like a clippy lint for cargo setups to tell people to dont do that :D
glitchy has quit [Remote host closed the connection]
<jason-kairos[m]>
<wassasin[m]> Monthly whine that workspaces with mixed targets are terrible
<jason-kairos[m]>
Maybe if a mob of 50 or so embedded developers got together, they might be able to organize an effort to do something. Event if that something might be to complain to the cargo maintainers.
<jason-kairos[m]>
I really wish it was better thought out.
<jason-kairos[m]>
* something might merely be to, * to complain very politely to the
<thejpster[m]>
<whitequark[cis]> this is a shell feature, not OS feature
<thejpster[m]>
even when executed from inside cargo by virtue of being given in `runner = "..."`?
<thejpster[m]>
looking at the cargo source code, I think it just does Command::new()
<whitequark[cis]>
<thejpster[m]> even when executed from inside cargo by virtue of being given in `runner = "..."`?
<whitequark[cis]>
ohhh interesting, not sure then
firefrommoonligh has quit [Quit: Idle timeout reached: 172800s]
andar1an has quit [Quit: andar1an]
Mihael[m] has quit [Quit: Idle timeout reached: 172800s]
adamgreig[m] has quit [Quit: Idle timeout reached: 172800s]
davidtwco[m] has quit [Quit: Idle timeout reached: 172800s]