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
emerent has quit [Ping timeout: 240 seconds]
emerent has joined #rust-embedded
starblue has quit [Ping timeout: 268 seconds]
starblue has joined #rust-embedded
<re_irc> <ignormies> hey guys, I'm still having some issues with timing for SPI writes, even using the faster "blocking::spi::Write".
<re_irc> Here are two screenshots of my signal, one built with "--release" and one without. The one with "--release" is obviously better, but still broken.
<re_irc> And here is a gist (https://gist.github.com/BryceBeagle/8904eab9aef4d3418680479f478f5516) with a minimal reproduction of the issue
<re_irc> Does anyone know where to begin diagnosing?
<re_irc> <ignormies> hey guys, I'm still having some issues with timing for SPI writes, even using the faster "blocking::spi::Write".
<re_irc> Here are two screenshots of my signal, one built with "--release" and one without. The one with "--release" is obviously better, but still broken.
<re_irc> And here is a gist (https://gist.github.com/BryceBeagle/8904eab9aef4d3418680479f478f5516) with a minimal reproduction of the issue
<re_irc> Does anyone know where to begin diagnosing? I am using an "stm32f103" bluepill
<re_irc> <GrantM11235> Is that the clock signal or the data signal?
<re_irc> <ignormies> That is the data signal, but I am sending "&[0b10101010, 0b10101010]" as a way of diagnosing timing
<re_irc> <ignormies> * timing, so it looks kinda like a clock signal
<re_irc> <ignormies> hey guys, I'm still having some issues with timing for SPI writes, even using the faster "blocking::spi::Write".
<re_irc> Here are two screenshots of my signal, one built with "--release" and one without. The one with "--release" is obviously better, but still broken, with a huge gap between words.
<re_irc> And here is a gist (https://gist.github.com/BryceBeagle/8904eab9aef4d3418680479f478f5516) with a minimal reproduction of the issue
<re_irc> Does anyone know where to begin diagnosing? I am using an "stm32f103" bluepill
<re_irc> <GrantM11235> Is it connected to a regular spi device, or is it neopixels or somthing?
<re_irc> <ignormies> neopixels
<re_irc> <GrantM11235> I guess you will need to use dma. Here is an example https://github.com/stm32-rs/stm32f1xx-hal/blob/master/examples/spi-dma.rs
<re_irc> <GrantM11235> The stm32f1 spi doesn't have a FIFO buffer, so the HAL has to wait for the first byte to finish before it can configure the next byte to be sent
<re_irc> <ignormies> oh interesting. I guess that makes sense. Maybe I should use the stm32f401 blackpill I have lying around instead -- does that have a buffer?
<re_irc> Why does "--release" chop out so many instructions here tho?
<re_irc> <GrantM11235> Are you running the cpu at the full 72mhz?
<re_irc> <ignormies> let clocks = rcc.cfgr
<re_irc> .use_hse(8.MHz())
<re_irc> <ignormies> (at least that was the conclusion I came to, but I'm still not 100% understanding of the clocks)
<re_irc> <ignormies> let clocks = rcc.cfgr
<re_irc> .use_hse(8.MHz())
<re_irc> <GrantM11235> The reason that "--release" helps is that it enables optimizations which allows the cpu to send the next byte faster once it sees that the last byte was sent
<re_irc> <GrantM11235> I'm a bit surprised that the cpu can't react in time though
<re_irc> <GrantM11235> I mis-remembered the datasheet. The stm32f1 _does_ have a single word buffer
<re_irc> <GrantM11235> So there should be plenty of time to keep the spi fed without any gaps
<re_irc> <ignormies> yeah, according to the reference manual, the TXE flag is set at the _start_ of the transmission for the previous word, not the end
<re_irc> <GrantM11235> ignormies: Are you sending that with a single "write" call?
<re_irc> <ignormies> here's a gist of what I'm doing:
<re_irc> <ignormies> but yeah, single call
<re_irc> <GrantM11235> Are you using full LTO?
<re_irc> <ignormies> uhhh, not sure. whatever is default
<re_irc> <GrantM11235> The default for "--release" is "thin" lto. I'm not sure if it would make a difference though
<re_irc> <GrantM11235> You can try adding this to your cargo toml
<re_irc> [profile.release]
<re_irc> lto = 'fat'
<re_irc> <ignormies> 🎉
<re_irc> <ignormies> Thanks so much for the help GrantM11235 ! After some tinkering it looks like using "opt-level" >=2 _and_ "lto = 'fat'" is necessary for me to drive the SPI at the speed I need on this chip
<re_irc> <GrantM11235> I'm surprised that "lto = 'fat'" makes such a difference. Maybe someone needs to add some "#[inline]" tags somewhere
<re_irc> <GrantM11235> But for embedded there is really no reason not to use "lto = 'fat'" all the time
<re_irc> <GrantM11235> Hmm, I'm not seeing any difference at all between fat and thin lto
<re_irc> <ignormies> GrantM11235: actually, are you sure "thin" is the default? Looks like "thin" works just as well as "fat" for me. this (https://doc.rust-lang.org/cargo/reference/profiles.html#release) has "lto" defaulting to "false" for the "release" profile
<re_irc> <GrantM11235> Oh, I was accidentally reading the docs for rustc instead of cargo https://doc.rust-lang.org/rustc/codegen-options/index.html#lto
<re_irc> <GrantM11235> With lto off, I am seeing non-inlined calls to stuff like "stm32f1::stm32f103::spi1::sr::TXE_R::new"
<re_irc> <Trevor Gross> Hey all, is there any official work toward a HAL for xilinx parts (Zynq specifically), or any guidelines for work with FPGA/Cortex combo parts? https://git.m-labs.hk/m-labs/zynq-rs exists and actually has a lot of work, but I'm wondering why it's not under the embedded wg's umbrella
<re_irc> <Trevor Gross> https://github.com/xilinx-rs is available if something official is within scope :)
<re_irc> <GrantM11235> I don't think there are any HALs that are officially part of the wg
<re_irc> <Trevor Gross> I think I just realized that - the documentation for https://github.com/atsamd-rs/atsamd is so complete that it seems very official
<re_irc> <Trevor Gross> Is there any reason HALs aren't under the workgroup, other than just adding more things to maintain?
<re_irc> <GrantM11235> It looks like this will be fixed in the next version of stm32f1xx_hal
<re_irc> <GrantM11235> Trevor Gross: The HALs aren't really developed by the working group, they are developed by individual devs who may or may not be in the wg
<re_irc> <GrantM11235> HALs are naturally very opinionated, and it is better to avoid having an "official opinion" (in my unoffical opinion 😁)
explore has joined #rust-embedded
dc740 has quit [Remote host closed the connection]
m5zs7k has quit [Ping timeout: 264 seconds]
m5zs7k has joined #rust-embedded
<re_irc> <alex (@alex:matrix.sempto.net)> 9names: Sorry, saw that a bit late. Basically I require something to read electric meters using serial, then read some water sensors and also do some pulse counting to read a water meter
<re_irc> <alex (@alex:matrix.sempto.net)> So I have built a board with 8 RJ12 connectors and a pi pico
<re_irc> <alex (@alex:matrix.sempto.net)> Oh and a RS485 interface to report the results back to the server
<re_irc> <alex (@alex:matrix.sempto.net)> So basically I need to be able to switch those connectors either to UART mode, pulse counting mode or GPIO (high/low) detection.
<re_irc> <alex (@alex:matrix.sempto.net)> Not sure if I'll manage to do it in rust though. It feels like I'm trying to fly without learning to walk first.
explore has quit [Quit: Connection closed for inactivity]
<re_irc> <9names (@9names:matrix.org)> that certainly is a lot for just getting started! nice practical problem though, and each of the parts shouldn't be insurmountable, I think it's not a bad first project.
<re_irc> <alex (@alex:matrix.sempto.net)> 9names: Well, not the first rust microcontroller project, just the first one on the pico.
<re_irc> The first one was a lot more imperative and C like.
<re_irc> <alex (@alex:matrix.sempto.net)> So I guess I either need to learn how to use the type system or switch back to the simpler less elegant style
<re_irc> <alex (@alex:matrix.sempto.net)> hardcode more stuff, like connector 1 is always UART, etc
starblue has quit [Ping timeout: 252 seconds]
starblue has joined #rust-embedded
neceve has quit [Quit: ZNC - https://znc.in]
neceve has joined #rust-embedded
<re_irc> <jannic> Seems like https://github.com/rust-embedded/riscv-rt/issues/102 is needed for "riscv-rt" to work on current nightly.
<re_irc> <jannic> In the past, the lines read "KEEP(*(.trap))", the "KEEP" was removed but the parentheses stayed. With a recent nightly update lld became more picky and now rejects the lines.
causal has quit [Quit: WeeChat 3.6]
neceve has quit [Changing host]
neceve has joined #rust-embedded
<re_irc> <almindor> jannic: Nice fix, thanks! could you just please add a CHANGELOG entry as well?
neceve_ has joined #rust-embedded
neceve_ has quit [Client Quit]
causal has joined #rust-embedded