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.]
causal has joined #rust-embedded
causal has quit [Ping timeout: 252 seconds]
causal has joined #rust-embedded
<re_irc> < (@firefrommoonlight:matrix.org)> : I just upgraded and am about to try
<re_irc> < (@firefrommoonlight:matrix.org)> Rel: How to you setup the dcache? https://docs.rs/cortex-m/latest/cortex_m/peripheral/struct.SCB.html#method.enable_dcache
<re_irc> < (@firefrommoonlight:matrix.org)> Ie, how do you get CPUID?
<re_irc> < (@firefrommoonlight:matrix.org)> Flashes/runs fine, btw
<re_irc> < (@jbeaurivage:matrix.org)> Hi all, I'm trying to implement an async API for SPI transfers with DMA, but I'm struggling to get it right. Wondering if some of you have advice/if I've overlooked something.
<re_irc> < (@firefrommoonlight:matrix.org)> async/await, or non-blocking?
<re_irc> < (@firefrommoonlight:matrix.org)> What MCU?
<re_irc> < (@jbeaurivage:matrix.org)> async/await on SAM MCUs. Specifically, testing on an ATSAMD51. From what I understand, writing to the chip's DATA register clocks a byte on the MOSI line, and the slave simultaneously sends back a byte on MISO. I think I'm struggling to get the futures to poll in the right order, but debugging is pretty hard.
<re_irc> < (@jbeaurivage:matrix.org)> Here's the bit that's supposed to launch the transfers:
<re_irc> write_res.and(read_res).map_err(Error::Dma)?;
<re_irc> let tx_fut = write_dma::<_, S>(&mut self._rx_channel, spi_ptr.clone(), source);
<re_irc> let (write_res, read_res) = futures::join!(rx_fut, tx_fut);
<re_irc> let rx_fut = read_dma::<_, S>(&mut self._tx_channel, spi_ptr, sink);
<re_irc> < (@jbeaurivage:matrix.org)> My logic is that the RX channel should be polled first, and would stall until bytes actually start coming in. Then TX should be polled, which will get MOSI and SCK going. In reality I don't think that's what's happening
dc740 has quit [Remote host closed the connection]
<re_irc> < (@firefrommoonlight:matrix.org)> Dcache sorted: "cp.SCB.enable_dcache(&mut cp.CPUID);"
<re_irc> < (@firefrommoonlight:matrix.org)> Although:
<re_irc> "cortex_m::peripheral::SCB::icache_enabled()" and dcache_enabled() are showign false, even after setting them in "cortex_m", and in the STM32 FLASH_ACR reg
<re_irc> < (@firefrommoonlight:matrix.org)> Is there any reason (other than perhaps slightly increased power use) to not enable the data cache, instruction cache, and prefetch on Cortex-M4? Of note, I'm a bit fuzzy on how the STM32 FLASH_ACR register setting for this value interacts with the "cortex_m" features
<re_irc> < (@firefrommoonlight:matrix.org)> AFAIK they're present on some Cortex-M4s but not others, but are fundamentally more of an ARM than STM32 thing?
starblue has quit [Ping timeout: 248 seconds]
starblue has joined #rust-embedded
<re_irc> < (@9names:matrix.org)> : Good way to check if your memory corruption is due to cache coherence issues I guess?
<re_irc> < (@firefrommoonlight:matrix.org)> Thx
<re_irc> < (@firefrommoonlight:matrix.org)> Also of note, the FLASH_ACR (STM32 regs for ICACHE and DCACHE, as well as prefetch) are staying set, but the cortex-M ones aren't
<re_irc> < (@firefrommoonlight:matrix.org)> I'm also a bit unclear if maybe the cortex-m ones are just for M7?
<re_irc> < (@adamgreig:matrix.org)> Yea, cm4 doesn't have icache or dcache, they're cm7
<re_irc> < (@adamgreig:matrix.org)> Which is probably why icache_enabled is returning false
<re_irc> < (@adamgreig:matrix.org)> FLASH_ACR is a totally separate ST thing to do with reading the flash
<re_irc> < (@adamgreig:matrix.org)> There's the ST ART which is the flash cache/predictor but iirc is enabled by default
<re_irc> < (@adamgreig:matrix.org)> (here icache and dcache specifically means the cortex-m internal caches, which are optional for a c-m CPU and never present in cm0/3/4, and always(?) present in cm7; SoC vendors like ST can add other caches outside the core like the ART or other memory system stuff but they're called something else and operated using proprietary mmio regs, not cpu regs)
vancz has quit [*.net *.split]
a2800276 has quit [*.net *.split]
Ekho has quit [*.net *.split]
limpkin has quit [*.net *.split]
rektide has quit [*.net *.split]
eigenform has quit [*.net *.split]
limpkin has joined #rust-embedded
eigenform has joined #rust-embedded
rektide has joined #rust-embedded
vancz has joined #rust-embedded
a2800276 has joined #rust-embedded
Ekho has joined #rust-embedded
Rahix has quit [Quit: ZNC - https://znc.in]
Rahix has joined #rust-embedded
<re_irc> <michael.desilva> Hi al,
<re_irc> Is it incorrect to assume one could do this:
<re_irc> fn toggle_led<E, T>(pin: &mut T)
<re_irc> where
<re_irc> <michael.desilva> +Ofcourse "Gpio14<esp_idf_hal::gpio::Output>" is its own concrete type though.
<re_irc> <michael.desilva> +I suppose type-erasure via a custom Trait object could also work?
Rahix has quit [Quit: ZNC - https://znc.in]
Shell has quit [Remote host closed the connection]
Shell has joined #rust-embedded
<re_irc> < (@jaxter184:matrix.org)> at risk of sounding stupid, did it not work to just change "&led_onboard" to "&mut led_onboard"?
<re_irc> <michael.desilva> nope, the base type is still the same.
Rahix has joined #rust-embedded
<re_irc> < (@datdenkikniet:matrix.org)> That's not correct: &T != &mut T. I think the error message (in it's entirety, not just the last note) explain what's wrong (which is in line with what jaxter184 is saying)
<re_irc> < (@datdenkikniet:matrix.org)> Also important to note is that the error occurs at the _call site_, not where you define your function (so your function definition, without knowing the details of ToggleableOutputPin) is most likely fine and should do what you expect it to do
<re_irc> < (@datdenkikniet:matrix.org)> * function, so your function definition (without
<re_irc> <michael.desilva> Oh this works " toggle_led::<anyhow::Error, Gpio14<esp_idf_hal::gpio::Output>>(&mut led_onboard);"
<re_irc> <michael.desilva> * "toggle_led::<anyhow::Error,
<re_irc> <michael.desilva> I was failing to specify E, T in the caller, and the "&mut" was needed too ofc
<re_irc> <michael.desilva> Otherwise I would give
<re_irc> found reference `&Gpio14<esp_idf_hal::gpio::Output>`
<re_irc> = note: expected mutable reference `&mut Gpio14<esp_idf_hal::gpio::Output>`
<re_irc> < (@marmrt:matrix.org)> I think you should remove the error completely, as the function doesn't return a "Result<>" it cannot return an error anyway
<re_irc> < (@marmrt:matrix.org)> Unless there's some error handling in the function not shown
<re_irc> <michael.desilva> Separate question re. https://github.com/esp-rs/esp-idf-svc/blob/master/src/http/server.rs#L518
<re_irc> How can I access details of the request?
<re_irc> // setup http server
<re_irc> let server_config = HttpServerConfiguration::default();
<re_irc> < (@datdenkikniet:matrix.org)> That's not correct: &T != &mut T. I think the error message (in it's entirety, not just the last note) explains what's wrong (which is in line with what jaxter184 is saying)
<re_irc> <michael.desilva> "pub struct EspHttpRequest<'a>(&'a mut httpd_req_t);" should mean I can access the inner .0 right?
<re_irc> error[E0609]: no field `0` on type `esp_idf_svc::http::server::EspHttpRequest<'_>`
<re_irc> --> src/main.rs:255:18
<re_irc> |
<re_irc> <michael.desilva> These methods should be available hmm https://github.com/esp-rs/esp-idf-svc/blob/master/src/http/server.rs#L518-L543
<re_irc> <michael.desilva> Hmm "EspHttpConnection" seems more promising.
<re_irc> < (@dirbaio:matrix.org)> : is that what the end user would write, or code inside the HAL?
<re_irc> <michael.desilva> the server works but I want to access further inner details of the request.
starblue has quit [Ping timeout: 252 seconds]
starblue has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc> < (@jbeaurivage:matrix.org)> : That's HAL code. I suppose I'm second guessing my use of futures::join here. I'm getting some weird behaviour like interrupts never firing, blocking the rx future from completing
<re_irc> <michael.desilva> Figured it out. I was missing a trait in my imports to enable Request handling.
<re_irc> < (@jbeaurivage:matrix.org)> * completing. I'm also pretty sure that the DMA transfers themselves work fine, I've had no problem with UART and SPI DMA transfers
<re_irc> <michael.desilva> The trap I was falling for was looking at the master branch and not the latest release tag. 🤦♂️
<re_irc> < (@firefrommoonlight:matrix.org)> : Thanks for the explanation!
<re_irc> < (@firefrommoonlight:matrix.org)> Also of note, the L5 and U5 (M-33) don't have the same ST Flash ACR Dcache, ICache and Prefetch, but a differnet setup
<re_irc> < (@firefrommoonlight:matrix.org)> It seems these features, whether ST or ARM, seem to fall along CPU divisions
<re_irc> < (@adamgreig:matrix.org)> ACR is just the access control register btw, not a particular feature of the flash peripheral
<re_irc> < (@firefrommoonlight:matrix.org)> Oh that makes sense why it's located there!
<re_irc> < (@firefrommoonlight:matrix.org)> (wait states are there too)
<re_irc> < (@jaxter184:matrix.org)> oh, wow, that futures crate seems very handy
<re_irc> < (@jaxter184:matrix.org)> i was trying to write an interrupt-based digital encoder thing, and I ended up with three separate tasks (two to read GPIOs and send a signal to the third, which would do the calculation), but using "futures::select" seems like itd let me use just one
<re_irc> < (@caemor:matrix.org)> are there any i2s or pdm mics that anyone uses in rust yet? a quick search only revealed the hal-abstraction: https://crates.io/crates/embedded-i2s but without any crates implementing it yet
<re_irc> < (@firefrommoonlight:matrix.org)> I've been using the ST ones. Lang doesn't matter
<re_irc> < (@firefrommoonlight:matrix.org)> Which MCU are you using them with?
<re_irc> < (@firefrommoonlight:matrix.org)> I've been using the ST ones.
emerent has quit [Ping timeout: 252 seconds]
emerent has joined #rust-embedded
<re_irc> < (@caemor:matrix.org)> its for an riscv pulpissimo platform
<re_irc> < (@caemor:matrix.org)> * a
causal has quit [Quit: WeeChat 3.7.1]
seer has quit [Quit: quit]
seer has joined #rust-embedded
hwj has joined #rust-embedded
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
hwj has quit [Ping timeout: 260 seconds]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
nohit has quit [Read error: Software caused connection abort]
nohit has joined #rust-embedded
seds has quit [Read error: Software caused connection abort]
seds has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]