conplan has quit [Remote host closed the connection]
starblue has quit [Ping timeout: 240 seconds]
starblue has joined #rust-embedded
conplan has joined #rust-embedded
_gth_ has joined #rust-embedded
_gth_ has quit [Client Quit]
gth has quit [Ping timeout: 246 seconds]
<re_irc>
<raphi ⚡️> Hello, I would like to use rust for an other platform (C-Based). I compile rust into a c-library and include this libray on the other platform. For i386 Architecture, everything works fine. But it should compile to arm7 too. The C-Based platform compiles with gcc 6.3.0 and i always has the error, that eabi version 5 isn't supportet. I tried every rust arm-target and also try to make an own arm-target. No look...
<re_irc>
... yet. Does everyone know, how to change the eabi-version on arm-targets?
<re_irc>
< (@k900:0upti.me)> Uhh, what do you mean by a "C library"?
<re_irc>
< (@k900:0upti.me)> Are you compiling Rust to C source or something?
<re_irc>
<raphi ⚡️> crate_type = ["staticlib"] and using #[no_mangle extern "C" to define the function-interface
<re_irc>
< (@grantm11235:matrix.org)> Or compiling to a static library and calling it from a C program?
<re_irc>
< (@grantm11235:matrix.org)> ha, you beat me
<re_irc>
< (@k900:0upti.me)> Clang can produce EABI4
<re_irc>
< (@k900:0upti.me)> So I'm assuming LLVM can too
<re_irc>
< (@k900:0upti.me)> But you might need to dive pretty deep into rustc to make it do that
<re_irc>
<raphi ⚡️> there is the "-Cllvm-args" rustflag (with arount 2000 options), but i didn't find a eabi setting. Or is there a way to direct define an llvm option somehow?
<re_irc>
Thank's. i left a comment there. Actually i programm same Code in Rust und C++ - just because this issue :(
<re_irc>
But it's not seem to be an easy solution to fix that
jr-oss has joined #rust-embedded
<re_irc>
<raphi ⚡️> > fascinating
<re_irc>
i'm compiling with nightly (don't no if this make a difference)
<re_irc>
< (@grantm11235:matrix.org)> The documentation for the "--meabi" parameter says that if it isn't set, it will use the default for the triple. So there must be some way to set it in a custom triple
<re_irc>
< (@grantm11235:matrix.org)> Can you set the eabi to version 5 in gcc?
<re_irc>
< (@grantm11235:matrix.org)> Later versions of gcc have an "-meabi" option, but I don't see it in the 6.3 manual
<re_irc>
< (@osten_music:matrix.org)> Heya, I'm looking for some advice. I have circular DMA transmitting and updating a DAC, basically as fast as it possibly can, via SPI. I would like to limit the speed in which this operates, in the context of seconds, rather than ticks.
<re_irc>
Basically I need to have a determined and accurate sample rate, but this method of circular DMA its hard for me to know exactly what that sample rate is, and if it deviates or fluctuates.
<re_irc>
I've tried using a secondary hardware timer, updating periodically setting a flag, e.g. at 10kHz, but having these two interrupts causes a dramatic slowdown, so I would like to somehow limit it within the DMA context directly.
<re_irc>
I can measure the time difference between transmit complete interrupts, getting a timestamp from the RTC, but from my attempts this is kind of unreliable, maybe the resolution of the RTC is too low.
<re_irc>
< (@osten_music:matrix.org)> I could use a hardware timer to generate the information for the DAC, pushing it onto a buffer thats then passed to the circular dma routine. Its possible, but I think its not the fastest way of doing it
<re_irc>
< (@osten_music:matrix.org)> it causes a slowdown
<re_irc>
<raphi ⚡️> > Later versions of gcc have an "-meabi" option, but I don't see it in the 6.3 manual
<re_irc>
i can, but there are other precompiled libraries compile with version 0. So than, there will be a conflict :/
<re_irc>
< (@osten_music:matrix.org)> maybe counting the number of bits being sent, and then calculating the transmitting frequency? I'm not sure exactly what to include in that equation though
<re_irc>
<raphi ⚡️> > The documentation for the "--meabi" parameter says that if it isn't set, it will use the default for the triple. So there must be some way to set it in a custom triple
<re_irc>
i thougth, the os oder 'none' of armv7a-none-eabi should set the correct eabi. But it wont' change anything
<Darius>
osten: I would have thought you care about jitter and less so about raw performance
<re_irc>
< (@osten_music:matrix.org)> yes thats true, it needs to be stable
<re_irc>
< (@osten_music:matrix.org)> so then maybe the hardware timer + circular DMA is the best I can do then
<re_irc>
< (@osten_music:matrix.org)> I wonder how the I2S drivers manage it
<re_irc>
< (@osten_music:matrix.org)> When you configure it I2S to run at eg. 44100, will there be gitter?
<re_irc>
< (@osten_music:matrix.org)> * jitter?
<Darius>
I haven't used it but I assume you setup a clock and divisor and feed it samples and it does the pacing
<re_irc>
< (@justacec:matrix.org)> Thought I would check here to see where I might hit up a chat channel for the rp2040 PIO. I am curious how to define more than 1 program in the asm file, compile it using the pio_proc! macros and then instruct each state machine to use specific programs. My reading of the documentation in the pio_proc and the pio_rs, and the rp2040_hal have not fruited me much on this. I have seen examples where the...
<re_irc>
... same program was used on each state machine in the sync examples, but that is not quite what I was looking for.
conplan has quit [Remote host closed the connection]
<re_irc>
< (@diondokter:matrix.org)> Does anybody know of crate that bridges "log" + Rust's assert to "defmt"? Seems like a lot of people roll one in their own project if using defmt is optional
<re_irc>
< (@alex:matrix.sempto.net)> I'm unable to get defmt-rtt to work. Probe-run works and outputs the correct place in the program if I stop it with Ctrl + C, but I do not see any output from "defmt::info!("init");"
<re_irc>
My target is pi-pico the debugger is pi-pico with dapper mime and I'm using RTIC if it matters.
<re_irc>
< (@diondokter:matrix.org)> Try to see if "defmt::println!" works. If it does, then your setup works
<re_irc>
< (@diondokter:matrix.org)> You may not be able to see the info because you haven't set the "DEFMT_LOG" environment variable
<re_irc>
< (@diondokter:matrix.org)> :
<re_irc>
< (@alex:matrix.sempto.net)> defmt::println! works
<re_irc>
< (@alex:matrix.sempto.net)> And yes, turns out the problem was unset DEFMT_LOG
<re_irc>
< (@alex:matrix.sempto.net)> Thank you!
<re_irc>
< (@diondokter:matrix.org)> Np
vancz has quit [Ping timeout: 248 seconds]
vancz has joined #rust-embedded
vancz has quit []
vancz has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
vancz has quit [Quit: No Ping reply in 180 seconds.]
vancz has joined #rust-embedded
dc740 has joined #rust-embedded
emerent has quit [Ping timeout: 246 seconds]
emerent_ has joined #rust-embedded
emerent_ is now known as emerent
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc>
< (@allexoll:matrix.org)> Hi everyone, is there some reason odd_number % 2 == 0? i'm running into some weird behaviour in my DMA implementation, when i'm checking if the buffers are aligned. if a u16 buffer is not aligned, it's giving me some weird results:
<re_irc>
defmt::println!("src_ptr: 0x{:x}", src_ptr as usize);
<re_irc>
< (@allexoll:matrix.org)> to me it seems that ...19 % 2 would equal 1, not 0 ?!
<re_irc>
< (@allexoll:matrix.org)> (where "W" is u16)
<re_irc>
< (@allexoll:matrix.org)> and "src_ptr" is "*const W". is there a impossibility to misalign types in rust? I don't understand how an odd number % 2 would result in zero 😕
<re_irc>
< (@grantm11235:matrix.org)> My guess is that there is some Undefined Behavior going on
<re_irc>
< (@grantm11235:matrix.org)> If you post your code, I can take a look at it
<re_irc>
< (@allexoll:matrix.org)> it seems to only happen in --release mode, so UB might be possible
<re_irc>
< (@allexoll:matrix.org)> relevant part is the "copy_exact" function in src/dma.rs when called from "dma_copy_u16_1024_misaligned_src" in "self-tests/dma-m2m.rs"
<re_irc>
< (@allexoll:matrix.org)> ah I think the issue is with the creation of the unaligned slice with "from_raw_parts_mut" :
<re_irc>
"data must be non-null and aligned even for zero-length slices. One reason for this is that enum layout optimizations may rely on references (including slices of any length) being aligned and non-null to distinguish them from other data"
<re_irc>
< (@allexoll:matrix.org)> yes
<re_irc>
< (@allexoll:matrix.org)> new question then, anybody knows of a way to create an unaligned u16 slice? if that's not possible at all I'm fine with it too because that means that my test case is irrelevant as well!
<re_irc>
< (@grantm11235:matrix.org)> A "&mut [u16]" is always aligned
<re_irc>
< (@allexoll:matrix.org)> there goes my issue
<re_irc>
< (@allexoll:matrix.org)> Is that specific to rust or specific to llvm? I'm pretty sure some architecture allow for unaligned access?
<re_irc>
< (@grantm11235:matrix.org)> It is specific to (safe) rust
<re_irc>
< (@grantm11235:matrix.org)> You can have unaligned raw pointers, but references are always aligned
<re_irc>
< (@allexoll:matrix.org)> All right, thanks for the explanation ! if it needs to be unsafe then it's the user's risk
<re_irc>
< (@grantm11235:matrix.org)> Technically you can create raw pointer safely, but using them requires "unsafe"
<re_irc>
< (@grantm11235:matrix.org)> So if you have a function that takes a raw pointer and uses it for dma, make sure to mark the function as unsafe
<re_irc>
< (@grantm11235:matrix.org)> Technically you can create raw pointers safely, but using them requires "unsafe"
<re_irc>
< (@allexoll:matrix.org)> I'm unsure what would be the use case for that
<re_irc>
< (@allexoll:matrix.org)> maybe i'll encounter something like that when doing dma from/to peripheral <=> memory, but for m2m I don't think that's needed
Darius has quit [Quit: Bye]
Darius has joined #rust-embedded
<re_irc>
< (@alex:matrix.sempto.net)> Does anybody happen to have an example on how to secure the data in postcard with a CRC?
cr1901 has quit [Remote host closed the connection]
<re_irc>
< (@alex:matrix.sempto.net)> If I understand it correctly it needs to be done in a flavor, but I thought I'd ask here before trying to implement it myself
cr1901 has joined #rust-embedded
cr1901 has quit [Remote host closed the connection]
<re_irc>
< (@jamesmunns:beeper.com)> You could do it as a flavor, or use something like a heapless vec as the output buffer, calculate the CRC, and push that to the end of the buffer
IlPalazzo-ojiisa has quit [Quit: Leaving.]
<re_irc>
< (@jamesmunns:beeper.com)> (author of postcard here, btw), happy to answer questions, don't have a CRC example offhand
<re_irc>
< (@alex:matrix.sempto.net)> : Then I can use the cobs crate to cobs encode, right?
<re_irc>
< (@jamesmunns:beeper.com)> Yeah, you probably want:
<re_irc>
Cobs(Crc32(Data)) if that makes sense
<re_irc>
< (@jamesmunns:beeper.com)> So you can either do that with stacked flavors, or:
<re_irc>
- Serialize
<re_irc>
- Cobs encode
<re_irc>
- Push Crc32
<re_irc>
< (@jamesmunns:beeper.com)> (then backwards for deser)
<re_irc>
< (@alex:matrix.sempto.net)> Yeah, I'd probably do that, sounds easier than implementing a flavor
<re_irc>
< (@alex:matrix.sempto.net)> I'm a bit new to Rust and navigating the type system is still a bit of a struggle
<re_irc>
< (@alex:matrix.sempto.net)> Well... It is the majority of the struggle to be honest.
<re_irc>
< (@jamesmunns:beeper.com)> Yeah, either approach works :)
<re_irc>
Flavors make some things easier, but also have some tradeoffs, but both approaches are valid!
<re_irc>
< (@jamesmunns:beeper.com)> Feel free to me if you have any questions using postcard :)
<re_irc>
< (@alex:matrix.sempto.net)> And thanks for making postcard by the way :) I needed something that was both reasonably efficient with the data on the line and well suited for microcontrollers. Postcard has worked really well for that
cr1901_ has joined #rust-embedded
cr1901_ has quit [Remote host closed the connection]
cr1901 has joined #rust-embedded
<re_irc>
< (@alex:matrix.sempto.net)> : Wait I just realize a potential problem with that approach: I can't use CobsAccumulator if I do that, right?
<re_irc>
< (@alex:matrix.sempto.net)> * realized
<re_irc>
< (@alex:matrix.sempto.net)> Since it will not expect the crc at the end of the cobs decode
<re_irc>
< (@jamesmunns:beeper.com)> Not directly, no, but cobs accumulator is also only like 100 lines of code
<re_irc>
< (@jamesmunns:beeper.com)> So I would just copy and paste it into your project and add a CRC check and error condition
cr1901 has quit [Remote host closed the connection]
cr1901 has quit [Remote host closed the connection]
cr1901 has joined #rust-embedded
<re_irc>
< (@orclev:matrix.org)> So, I feel like I'm going crazy here. I'm trying to debug some code and getting an index out of bounds exception, but I'm not seeing how it's remotely possible. I've got a bit vector declared as follows:
<re_irc>
touched: BitArr!(for 68, in u8, Lsb0),
<re_irc>
for y in self.touched.iter_ones() {
<re_irc>
then later on I have this:
<re_irc>
what's driving me nuts, is when I hit the index out of bounds it's reporting that the value of y is 68, which shouldn't be possible, because the highest index for touched _should_ be 67 as the length of touched is 68.