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: 244 seconds]
emerent has joined #rust-embedded
<re_irc> <thalesfragoso> dirbaio: Yeah, it favors the easy route, if you don't want to pass ownership then you do what you already have to do in the futures one
<re_irc> <thalesfragoso> It seems it doesn't require FusedFuture too, that looks a bit error prone though
<re_irc> <thalesfragoso> dirbaio: Can you ? These rules for extending the scope of temporaries are very confusing
<re_irc> <thalesfragoso> I thought it didn't work if it was used directly in function arguments
starblue has quit [Ping timeout: 256 seconds]
starblue has joined #rust-embedded
<re_irc> <thalesfragoso> Hmm, how come &UnsafeCell be derefereable ? Couldn't that cause data races ? Or derefereable doesn't mean race free ?
<re_irc> <thalesfragoso> +data
fabic has joined #rust-embedded
<re_irc> <Imran K> Hi all, I’m using "rp2040" pic board. I have written a simple led blinking program, but if I flash the binary file, the led does not blink. Does rp2040 support binary file?
<re_irc> <9names (@9names:matrix.org)> Try starting with https://github.com/rp-rs/rp2040-project-template, it's a safer way to get started with rp2040.
<re_irc> Also check the readme, should cover all the common ways of pushing new code onto a Pico.
<re_irc> <Imran K> 9names: Yeah it’s working, but I want flash binary format on the pico not executable format, because I'm writing a secure boot for "rp2040", so i want binary file for signature.
<re_irc> <Imran K> is this possible to flash binary format on the pico.
<re_irc> <Imran K> * binary format support
<re_irc> <9names (@9names:matrix.org)> It is possible to flash a binary file. How are you programming it now?
<re_irc> <Imran K> Yeah I can able to flash bin file using probe-rs-cli but led is not woking
<re_irc> <Imran K> * "probe-rs-cli" but led is not woking on pico.
<re_irc> <Imran K> * blinking
<re_irc> <Imran K> Executable format working.
<re_irc> <Imran K> This means binary format not support on the pico?
<re_irc> <9names (@9names:matrix.org)> I don't understand what you mean. An executable is a binary file.
<re_irc> How are you creating this bin file, what are you generating it from, which commands are you using to load it?
<re_irc> <Imran K> 9names: I’m converting elf to bin format using this command "rust-objcopy rp2040_blinky -O binary rp2040_blinky.bin"
gsalazar_ has joined #rust-embedded
<re_irc> <Lachlan> Perhaps your linker script is incorrect
gsalazar has quit [Ping timeout: 256 seconds]
<re_irc> <jspngh> I think the linker script should be okay if the elf file is working. But maybe you are passing the wrong address when flashing the bin file?
gsalazar_ has quit [Quit: Leaving]
gsalazar has joined #rust-embedded
fabic has quit [Ping timeout: 268 seconds]
fabic has joined #rust-embedded
fabic has quit [Ping timeout: 268 seconds]
fabic has joined #rust-embedded
starblue has quit [Ping timeout: 240 seconds]
starblue has joined #rust-embedded
<re_irc> <henrikssn> Is there a safe way to hand out multiple mutable references in Rust to a variable without using locks and not hitting UB?
<re_irc> <henrikssn> I think I am looking for an equivalent of "volatile" in C
<re_irc> <K900> You probably want one of the "Atomic*" types then
<re_irc> <henrikssn> Doesn't the atomic types use different instructions than a volatile primitive in C?
<re_irc> <K900> Not necessarily
<re_irc> <henrikssn> E.g. would AtomicU32::load be equivalent to a read of a volatile uint32 in C?
<re_irc> <henrikssn> And same thing for store
<re_irc> <K900> That is not guaranteed
<re_irc> <K900> But "volatile" in C is also not guaranteed to be thread safe
<re_irc> <K900> Whereas atomics are
<Lumpio-> It depends on the architecture, one some architectures a 32-bit normal load might be atomic for example so load might do that
<Lumpio-> Does it matter if it uses different instructions?
<re_irc> <K900> I feel like you should really explain what you're _actually_ trying to do
<re_irc> <K900> Instead of what C feature you think will help you do it
causal has quit [Quit: WeeChat 3.5]
<re_irc> <henrikssn> It has to do with DMA, and the underlying data might change at any time, so I want to prevent the compiler from caching it in registers
<re_irc> <K900> In that case you want "ptr::{read,write}_volatile"
<re_irc> <K900> Which are specifically designed for operating on I/O memory
<re_irc> <henrikssn> I assume there is no safe way of doing this?
<re_irc> <K900> There can't be, you're reading arbitrary pointers
<re_irc> <K900> You can use docs.rs/volatile which gives you a "safe" wrapper, but it's not _actually_ completely safe
<re_irc> <henrikssn> hmm
<re_irc> <henrikssn> assuming this is a u32 at a stable memory address
<re_irc> <henrikssn> how could a load/store be unsafe?
<re_irc> <K900> Lots of caveats possible
<re_irc> <K900> Alignment
<re_irc> <K900> etc
<re_irc> <henrikssn> aha, ok, to reformulate the problem: Say that I have a struct that looks like this:
<re_irc> static mut foobar: FooBar = ...;
<re_irc> struct FooBar {
<re_irc> foo: u32,
<re_irc> <henrikssn> I guess making them "AtomicU32" isn't completely solving this problem, right?
<re_irc> <henrikssn> aha, ok, to reformulate the problem: Say that I have a struct that looks like this:
<re_irc> #[repr(packed)]
<re_irc> static mut foobar: FooBar = ...;
<re_irc> struct FooBar {
<re_irc> <henrikssn> With "Volatile" I assume I need to create a separate struct which contains volatile references to foo and bar
<re_irc> <henrikssn> After reading this thread, I believe the only way to do this is to use "ptr::read/write_volatile" and be very careful not to ever create a reference to any of the fields https://internals.rust-lang.org/t/volatile-and-sensitive-memory/3188/98
<re_irc> <henrikssn> The moment you create a reference, rust is free to assume that the data follows the aliasing rules (which it doesn't) and UB will happen
<re_irc> <henrikssn> +(may)
fooker has quit [Ping timeout: 268 seconds]
fooker has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
fabic has quit [Ping timeout: 240 seconds]
jasperw has quit [Ping timeout: 248 seconds]
jasperw has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
fabic has joined #rust-embedded
dc740 has joined #rust-embedded
creich has joined #rust-embedded
fabic has quit [Ping timeout: 255 seconds]
WSalmon has quit [Read error: Connection reset by peer]
WSalmon has joined #rust-embedded
creich has quit [Quit: Leaving]
dc740 has quit [Remote host closed the connection]
<re_irc> <Lachlan> I'm trying to figure out what dependency is trying to pull in the alloc crate since I've suddenly started getting "error: no global memory allocator found but one is required; link to std or add "#[global_allocator]" to a static item that implements the GlobalAlloc trait" when compiling our firmware.
<re_irc> <Lachlan> Anyone have any ideas?
<re_irc> <Lachlan> Been looking through recent changes and dependency features to see if anything stands out, but no
<re_irc> <dirbaio> doesn't exactly show what uses alloc, but maybe you can find out with "cargo tree --format '{p} {f}'" and then searching for what has "std" or "alloc" cargo features enabled
explore has joined #rust-embedded
mightypork has joined #rust-embedded
mightypork has quit [Quit: ZNC - https://znc.in]
mightypork has joined #rust-embedded
causal has joined #rust-embedded
<re_irc> <adamgreig> henrikssn: yea, you can't have a reference open to something that dma will mutate in the background, so usually the approach is to swap buffers around so the user code interacts with one buffer while dma operates on another
<re_irc> <thalesfragoso> adamgreig: You can still use re-borrow semantics casting it to a *mut, pass it to a "FFI boundary" and do proper synchronization
<re_irc> <thalesfragoso> After the synchronization you can use the &mut again
<re_irc> <thalesfragoso> That's how you pass in buffer to the kernel, etc
<re_irc> <thalesfragoso> * buffers