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
DepthDeluxe has quit [Ping timeout: 255 seconds]
DepthDeluxe has joined #rust-embedded
DepthDeluxe_ has joined #rust-embedded
DepthDeluxe_ has quit [Read error: Connection reset by peer]
DepthDeluxe has quit [Ping timeout: 246 seconds]
<re_irc> < (@anand21:matrix.org)> Hi All,
<re_irc> Is there any way to getting ownership of a only 1 peripheral from HAL,
<re_irc> Rather than getting the whole Peripherals?
<re_irc> I don't want to use global statics.
<re_irc> < (@ryan-summers:matrix.org)> You can just move it out of the peripheral atruct the HAL gives you. No need to do anything else with the other stuff if you don't need it
<re_irc> < (@ryan-summers:matrix.org)> * struct
<re_irc> < (@ryan-summers:matrix.org)> Note that this may be confusing if you're used to c/c++, but rust ownership means you can destructive objects into multiple parts :)
<re_irc> < (@ryan-summers:matrix.org)> * destructure
<re_irc> < (@anand21:matrix.org)> No The problem is, I need 1 peripheral at the staring of the code. And another peripheral at some other point, in other file.
<re_irc> < (@ryan-summers:matrix.org)> You're going to have to post some kind of example, I'm not following what you mean
<re_irc> < (@ryan-summers:matrix.org)> * Can you post some kind of example?
<re_irc> < (@anand21:matrix.org)> Ok This is the main.rs
<re_irc> fn main() -> ! {
<re_irc> let dp= nrf9160_pac::Peripherals::take().unwrap();
<re_irc> defmt::println!("Hi from Secure world");
<re_irc> < (@anand21:matrix.org)> Then in some other file under the same crate I again want to use the NVMC peripheral.
<re_irc> Now if try to get the
<re_irc> nvmc: Peripherals::take().unwrap().NVMC_S;
<re_irc> Here I get None. As i have already taken the peripherals previously
<re_irc> < (@ryan-summers:matrix.org)> Why not pass NVMC_S to the other file instead?
<re_irc> < (@ryan-summers:matrix.org)> If it's in another thread, I think you have to use some global object with access control
<re_irc> < (@anand21:matrix.org)> Yes that can be done. But I wanted to explore other options available.
<re_irc> < (@anand21:matrix.org)> I guess I have to use Global statics only. Right?
<re_irc> < (@ryan-summers:matrix.org)> The rust ownership RAIA would break if the peripherals could be "take()"n more than once, as that would imply that two drivers/owners could have simultaneous control over the same peripheral, which is fundamentally unsound
<re_irc> < (@ryan-summers:matrix.org)> So without directly passing or moving the object into some owned location that's accessible, it will be dropped and not recoverable (might be an unsafe method to instantiate it from a ptr as well)
<re_irc> < (@anand21:matrix.org)> Ok thank you for the suggestion.
<re_irc> I will explore the global static thing. And lazy initialisation of it later point of time.
<re_irc> < (@ryan-summers:matrix.org)> Also worth noting that's from the PAC and not the HAL. Might make it easier to conjure up the object from a pointer
<re_irc> < (@ryan-summers:matrix.org)> Eh, that just gets you the "RegisterBlock" instead of the peripheral itself unfortunately
<re_irc> < (@marmrt:matrix.org)> "steal()" the peripherals. What could go wrong?
<re_irc> < (@anand21:matrix.org)> I tried "steal()" It is unsafe version of "take()"
<re_irc> < (@marmrt:matrix.org)> Yes, and if you do "steal()" instead of the second "take()" you will get a second copy of the peripheral struct.
<re_irc> < (@marmrt:matrix.org)> To be clear, I think you should listen to Ryan, not me. Figure out the legal way to get the behaviour you want
<re_irc> < (@ryan-summers:matrix.org)> Unsafe stuff is fine, you just need to thoroughly document why it's explicitly okay. And also recognize you are paying in technical debt. You may introduce a subtle bug in the future and waste hours on it
<re_irc> < (@ryan-summers:matrix.org)> Technically speaking though, using "steal()" as you propose is completely sound in this case. It's just quite easy to make it not sound in the future
<re_irc> < (@anand21:matrix.org)> I agree to this as we are using rust just to make the use of tightly coupled type systems.
IlPalazzo-ojiisa has joined #rust-embedded
crabbedhaloablut has quit [Read error: Connection reset by peer]
crabbedhaloablut has joined #rust-embedded
dc740 has joined #rust-embedded
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
wadams has joined #rust-embedded
wadams has quit [Client Quit]
wadams has joined #rust-embedded
wadams has quit [Client Quit]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
wes_ has joined #rust-embedded
wes_ has left #rust-embedded [WeeChat 2.8]
wes_ has joined #rust-embedded
<wes_> hello everyone. brand new here
<wes_> can i ask questions about specific code snippets here?
wes_ has left #rust-embedded [WeeChat 2.8]
wes_ has joined #rust-embedded
<wes_> well, here goes anyways...
<wes_> i'm working with an RP2040 pico
<wes_> i've pulled some sample code from the rp-hal repo
<wes_> for some reason, because of `to_Hz()` i cannot get this to compile
<wes_> `let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());`
<re_irc> < (@k900:0upti.me)> My guess would be lower case "to_hz"
<re_irc> < (@xiretza:xiretza.xyz)> wes_: what's the error?
<wes_> method not found in `embedded_time::rate::units::Hertz`
<wes_> no dice on lowercase'ing it. the code (and `use` calls) come directly from an example. which works (compiles, flashes, LEDs blink) in the example project
<wes_> i'm coming from C, and i'm not at all comfy using Rust documentation. yet
<re_irc> < (@xiretza:xiretza.xyz)> probably different versions of dependencies then, compare the Cargo.toml files
<wes_> ah! good call
neceve has quit [Quit: ZNC - https://znc.in]
<wes_> amazing! that's all it was. 0.4.0 -> 0.5.0 and boom. all good. thank you
<wes_> is there a way to tell Cargo to use the most up-to-date versions of dependencies?
<re_irc> < (@grantm11235:matrix.org)> Generally, you don't want cargo to update from 0.4.0 to 0.5.0 automatically without telling you
<wes_> sure. makes sense.
<re_irc> < (@grantm11235:matrix.org)> If you are adding a new dependency, you can use "cargo add the-name-of-the-new-dep" from cargo-edit (https://crates.io/crates/cargo-edit)
<re_irc> < (@grantm11235:matrix.org)> Which will automatically add that dependency to your "Cargo.toml", using the latest version
<wes_> that's perfect. exactly what i want
<wes_> thanks
<re_irc> < (@jannic:matrix.org)> cargo-edit also has a subcommand "cargo upgrade": https://github.com/killercup/cargo-edit#cargo-upgrade
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
crabbedhaloablut has quit [Ping timeout: 255 seconds]
loki_val has joined #rust-embedded
<wes_> thanks for all the advice. my project is now up-to-date
<Socke> which crate would you recommend for doing small http requests on esp32? I'm especially concerned about memory and flash footprint
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
<re_irc> < (@yatekii:matrix.org)> Hey folks, can anyone tell me how I can lock a STM32F4 core easily? I wanna test if probe-rs can detect locked state ^^cc maybe?
<re_irc> < (@adamgreig:matrix.org)> locked as in no debug access due to protection, or as in sleep mode, or something else?
<re_irc> < (@yatekii:matrix.org)> Socke: always smoltcp :) but I wonder why you are concerned about the footprint on an esp32 which has an abundance of resources compared to every other MCU :P
<re_irc> < (@yatekii:matrix.org)> : as in no debug access :)
neceve has joined #rust-embedded
neceve has quit [Remote host closed the connection]
<re_irc> < (@yatekii:matrix.org)> maybe there is a utility that does this off the bat or a register I can write with probe-rs without much fiddling
<re_irc> < (@adamgreig:matrix.org)> if you lock it to disable debug access, you can't re-enable debug access
<re_irc> < (@yatekii:matrix.org)> : oh wat
<re_irc> < (@yatekii:matrix.org)> you cannot reenable it by erasing?
<re_irc> < (@adamgreig:matrix.org)> how would you erase it without debug access?
<re_irc> < (@yatekii:matrix.org)> on nRF devices ther is a second custom AP that can unlock it :)
<re_irc> < (@adamgreig:matrix.org)> on stm32 flash readout protection, there's level 0, 1, or 2; level 0 is normal, 1 is can't read flash while debug is connected or booted from ram, and you can revert to level 0 which mass erases the flash, level 2 disables the debug interface such that you can no longer lower the protection level
<Socke> yatekii: but smoltcp has no http support? I thought it's a tcp stack. using esp-idf for this btw
<re_irc> < (@yatekii:matrix.org)> Socke: ah sorry, consider me stupid :/
<Socke> :D
<re_irc> < (@yatekii:matrix.org)> : hmm ok I am not sure what I would want XD
neceve has joined #rust-embedded
<Socke> just coding the parsing myself in this case
<re_irc> < (@mabez:matrix.org)> Socke: If you're using esp-idf, can't use you use the idf http client/server?
<Socke> oh it has one?
<Socke> hmm looks like there's only an httpd, but no httpc. but I found EspSntp, this will come in handy later :)
<re_irc> < (@mabez:matrix.org)> Socke: There is a client here (and a new server): https://github.com/esp-rs/esp-idf-svc/blob/master/src/http/client.rs
<re_irc> < (@mabez:matrix.org)> Its behind an experimental feature flag which is why it doesn't show up on the docs I think
<Socke> NICE!
<Socke> damnit last hour of coding wasted :D
<re_irc> < (@mabez:matrix.org)> The plan is to remove the current httpd interface and replace with both of these :)
<re_irc> < (@mabez:matrix.org)> Socke: Sorry!! I'll PR the docs change now :)
<Socke> np, but thanks for the hint :)
loki_val has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
dc740 has quit [Remote host closed the connection]