ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
IlPalazzo-ojiisa has quit [Quit: Leaving.]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
IlPalazzo-ojiisa has joined #rust-embedded
IlPalazzo-ojiisa has quit [Client Quit]
troglodito has joined #rust-embedded
troglodito has left #rust-embedded [#rust-embedded]
<re_irc> <Julia> I am working on an extremely memory constrained application and I was wondering if it is possible to deallocate parts of a slice or vec. It seems I can truncate a vector for instance, but that does not actually reduce the memory allocated to it. Any ideas?
<re_irc> < (@jamesmunns:beeper.com)> Not generally - arrays are stored on the stack, and you can't generally "shrink" a stack frame without returning
<re_irc> < (@jamesmunns:beeper.com)> if you are using the standard library, you can shrink a vec with something like "shrink_to_capacity"
<re_irc> < (@jamesmunns:beeper.com)> but if you are not using the standard library (or some other heap allocator), it's not generally possible to shrink a static array or stack frame.
<re_irc> <Julia> I am using a heap allocator, but it is no-std.
<re_irc> < (@jamesmunns:beeper.com)> Ah! Then yeah, if you are using standard alloc types, https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.shrink_to or https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.shrink_to_fit are probably what you want.
<re_irc> < (@jamesmunns:beeper.com)> I think you need to drop the items off the tail first, then call truncate to free the space. Depending on your allocator (?), this may end up doing another allocation. I don't think Rust's alloc guarantees allocation resizings are done in place.
<re_irc> < (@jamesmunns:beeper.com)> e.g. if you have a vec with capacity 32, and len 8, and you shrink it to 8, it will probably (I think?) allocate a second, capacity 8 vector, copy the data there, then free the original vector
<re_irc> < (@jamesmunns:beeper.com)> followed up privately, but tl;dr:
<re_irc> - The Allocator trait has "resize", and GlobalAlloc has "realloc", which _could_ do resizing in place (vec calls realloc on "shrink_to*"), BUT
<re_irc> - CortexMHeap, and the underlying linked-list-allocator don't support realloc, which means realloc gets the default behavior of "make new alloc, copy to dest, free old alloc"
<re_irc> < (@jamesmunns:beeper.com)> which means the heap usage is going to get bigger before it gets smaller.
<re_irc> < (@yatekii:matrix.org)> hmm how do I best make a linkerscript in a library customizable? :/
<re_irc> < (@jamesmunns:beeper.com)> honestly? "build.rs" probably.
<re_irc> < (@yatekii:matrix.org)> hmm oki :)
<re_irc> < (@jamesmunns:beeper.com)> generate a linker fragment like "mylib.x", ask users to include "-Tmylib.x" or whatever in their ".cargo/config.toml"
<re_irc> < (@yatekii:matrix.org)> hmm do you have an example for that? :/ linkerscript is total blackmagic to me ...
<re_irc> < (@jamesmunns:beeper.com)> I think defmt does something like this?
<re_irc> < (@yatekii:matrix.org)> I know that cortex-m does it like this somehow
<re_irc> < (@yatekii:matrix.org)> hmmm
<re_irc> < (@yatekii:matrix.org)> thanks!
<re_irc> < (@jamesmunns:beeper.com)> that's not doing any modification or template filling or anything, but it's doing the read/write/add "rustc-link-search" thing you will need to do from your lib
<re_irc> < (@jamesmunns:beeper.com)> you'd mutate the contents of the "linker_script" var for your use case.
<re_irc> <Julia> I managed to find a very _ugly_ workaround for my problem.
<re_irc> <Julia> let mut output = vec![0; 27000];
<re_irc> SliceReader::new(include_bytes!("../inputs/d01c.txt")),
<re_irc> let result = MyLzss::decompress(
<re_irc> SliceWriter::new(&mut output),
<re_irc> < (@jamesmunns:beeper.com)> :D
<re_irc> <Julia> Read in 27kb, check what the actual size was, drop it, reallocate it, read again.
<re_irc> < (@jamesmunns:beeper.com)> you could make an "empty writer" to avoid the first heap allocation
<re_irc> < (@jamesmunns:beeper.com)> still just as wasteful, CPU wise, but at least you'll save yourself the first allocation?
<re_irc> <Julia> I don't know if that'll work. I'm not really directly reading here. I am actually decompressing :P.
<re_irc> <Julia> Or maybe I misunderstand what you just said.
<re_irc> < (@jamesmunns:beeper.com)> the "decompress" takes something that implements "lzss::Write" (instead of core::fmt::Write): https://docs.rs/lzss/latest/lzss/trait.Write.html
<re_irc> < (@jamesmunns:beeper.com)> so you could do the same trick, implement the "write" function that just increments the count by 1, instead of actually pushing a byte.
<re_irc> < (@jamesmunns:beeper.com)> Or just does nothing, because I think "compress" also counts the size :D
<re_irc> < (@yatekii:matrix.org)> was real easy in the end thank you!!
<re_irc> < (@korken89:matrix.org)> : Cool! Unfortunate that it's still not an MCU :(
<re_irc> < (@korken89:matrix.org)> I'd think that the killer market for riscv should be like cortex M territory
<re_irc> < (@korken89:matrix.org)> Extreme volumes and low margins
<re_irc> < (@korken89:matrix.org)> So if you don't pay license you should have a good advantage
<re_irc> < (@korken89:matrix.org)> It's probably coming like a tsunami though :D
<re_irc> < (@korken89:matrix.org)> The only sane ones I've found is the CH32 ones like CH32F307
<re_irc> < (@korken89:matrix.org)> STM32 copies with riscv core
<re_irc> < (@9names:matrix.org)> e907 is an mcu. on bl808 it has a app processor strapped on (not well integrated tbh), but bl616 is basically the same with just the e907.
<re_irc> < (@korken89:matrix.org)> Oh
<re_irc> < (@9names:matrix.org)> yeah if they're shipping i'm sure we'll see a ch with a similar config soon enough
<re_irc> < (@jamesmunns:beeper.com)> esp32-cx series are also riscv mcus
<re_irc> < (@korken89:matrix.org)> I have too look closer i found like an raspberry pi 4
<re_irc> < (@jamesmunns:beeper.com)> not cortex-m flavored at all, afaik :D
<re_irc> < (@9names:matrix.org)> yeah but they don't have CLIC afaik?
<re_irc> < (@korken89:matrix.org)> They don't :(
<re_irc> < (@korken89:matrix.org)> I already checked esp32
<re_irc> < (@jamesmunns:beeper.com)> ah, checking for clic + mcu format
<re_irc> < (@jamesmunns:beeper.com)> (now I get it)
<re_irc> < (@korken89:matrix.org)> I really want to try the new multi arch support for RTIC, but for that i need an MCU to test against 😅
<re_irc> < (@korken89:matrix.org)> (the codegen is now made hardware agnostic, in theory)
<re_irc> < (@jamesmunns:beeper.com)> aw, the wch569 doesn't use the CLIC either
<re_irc> < (@korken89:matrix.org)> I ordered CH32F307 as it has a good enough interrupt controller
<re_irc> < (@jamesmunns:beeper.com)> used the "PFIC"
<re_irc> < (@korken89:matrix.org)> It has its own CLIC like controller
<re_irc> < (@korken89:matrix.org)> Same features at least
<re_irc> < (@korken89:matrix.org)> Then comes the fun issue of having one bindings feature per riscv core we support until CLIC is standard 😅
<re_irc> < (@jamesmunns:beeper.com)> (the ch569 is a neat MCU with a USB3.0 host/device controller)
<re_irc> < (@korken89:matrix.org)> It's cool
<re_irc> < (@9names:matrix.org)> nice nice nice nice nice
<re_irc> < (@korken89:matrix.org)> CH32F307 has 2.0 HS and GigE Ethernet
<re_irc> < (@korken89:matrix.org)> But so far I'm only interested in getting RTIC running :D
<re_irc> < (@korken89:matrix.org)> I want it to be ready for when riscv becomes mainstream
<re_irc> < (@korken89:matrix.org)> Maybe i should try on esp32 as well, see how much we can support
<re_irc> < (@korken89:matrix.org)> I'm trying to find the docs on their interrupt controller :P
<re_irc> < (@korken89:matrix.org)> Seems too be preemptive
<re_irc> < (@korken89:matrix.org)> And it has basepri like functionality
<re_irc> < (@korken89:matrix.org)> I'll order a dev board for that as well:)
<re_irc> < (@korken89:matrix.org)> Worth experimenting
<re_irc> < (@korken89:matrix.org)> Does anyone know once that has SWD or JTAG port?
<re_irc> < (@korken89:matrix.org)> * one
<re_irc> < (@9names:matrix.org)> the riscv ESP's have builtin usb-jtag with probe-rs support, if that's what you're referring to. it's super convenient
<re_irc> < (@korken89:matrix.org)> Oh nice
<re_irc> < (@korken89:matrix.org)> No need for a probe then :D
<re_irc> < (@matoushybl:matrix.org)> They do have the builtin jtag but on many devkits they still use usb/uart converter for programming.
<re_irc> This one has the native jtag: https://github.com/esp-rs/esp-rust-board
<re_irc> < (@matoushybl:matrix.org)> They do have the builtin jtag but on many devkits they still use usb/uart converter for programming.
This one has the native jtag: https://github.com/esp-rs/esp-rust-board (can be bought on aliexpress or mouser)
<re_irc> < (@korken89:matrix.org)> Nice
vancz has quit []
vancz has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
emerent has quit [Ping timeout: 256 seconds]
emerent has joined #rust-embedded
<re_irc> < (@luojia65:matrix.org)> Happy new year! It's year of the rabbit now
starblue has quit [Ping timeout: 246 seconds]
<re_irc> < (@yatekii:matrix.org)> : how is the animal determined?
<re_irc> <Félix the Newbie> I think it's a cycle
<re_irc> < (@korken89:matrix.org)> Does anyone know is a static site generator that has a template for the rust website kind of look?
<re_irc> < (@korken89:matrix.org)> * of
<re_irc> < (@CyReVolt:matrix.org)> Félix the Newbie: yep, 12 years with one animal each, combined with 5 elements - so a 60-year cycle in total :-)
<re_irc> Now the year of the 🐅 (my year) just ended, and this is now the year of the water rabbit.
<re_irc> We are featuring a special version of the logo on https://coreboot.org accordingly - a hare being the coreboot mascot :-)
starblue has joined #rust-embedded
<re_irc> <dngrs (spookyvision@{github,cohost})> that's a very pretty logo
genpaku has quit [Remote host closed the connection]
genpaku has joined #rust-embedded
starblue has quit [Ping timeout: 256 seconds]
starblue has joined #rust-embedded
<re_irc> <Hexafox> Hey all o/
<re_irc> <Hexafox> I'm currently on a long term project to try and get rust on the nintendo ds.
<re_irc> <dngrs (spookyvision@{github,cohost})> I assume you've already found https://github.com/rrohrer/rs-nds ?