<igiona[m]>
* Did anybody encountered issues with the SimplePwm duty cycle on nrf devices?
<igiona[m]>
I'm puzzled 'cause on my nrf5340, when I set the duty to 0, the GPIO is high, and when I set to max_duty() it's low.
<igiona[m]>
I'm not sure if I'm too tired already, or it's actually a bug to be reported :D
<igiona[m]>
I tested both, embassy-nrf main and 0.2.0
<igiona[m]>
I'm pretty sure on my nrf53833 did work just fine a couple of months ago.
Makarov9 has joined #rust-embedded
Makarov44 has joined #rust-embedded
Makarov9 has quit [Ping timeout: 256 seconds]
Makarov44 has quit [Ping timeout: 256 seconds]
starblue has quit [Ping timeout: 272 seconds]
starblue has joined #rust-embedded
birdistheword99[ has joined #rust-embedded
<birdistheword99[>
Hi guys, I'm looking to write a library that I can use on my embedded device, that describes the layout of my settings in eeprom, and in a PC application that will read and write those settings. I am tripping up on the... (full message at
<dirbaio[m]>
Are you transmuting rust structs to bytes and writing them to eeprom?
<birdistheword99[>
Yes, I'm annotating them with [#repr(c)] and writing them as bytes into eeprom
<dirbaio[m]>
Heapless string itself is not repr(C)
<dirbaio[m]>
So you can't do that
<dirbaio[m]>
The layout is unstable. A future rustc version might decide to place the length at the end instead of st the start, for example
<birdistheword99[>
Ah Ok thats good to know, why does the compiler not warn that items in a struct annotated with #[repr(C)]' are not all #[repr(C)]' ? Is there an additional clippy lint that needs to be turned on perhaps?
<dirbaio[m]>
That's a very good q, I don't know. Maybe it should warn
<birdistheword99[>
* Ah Ok thats good to know, why does the compiler not warn that items in a struct annotated with #[repr(C)] are not all #[repr(C)] ? Is there an additional clippy lint that needs to be turned on perhaps?
<dirbaio[m]>
Anyway
<dirbaio[m]>
The solution is you need to make your own string struct
<dirbaio[m]>
{len: u32, chars: [u8; 32]}
<dirbaio[m]>
And make it repr(C)
<dirbaio[m]>
You can even omit the length and assume the string is padded with null bytes, that'd save some space in eeprom.
<dirbaio[m]>
And Since you're making the structs yourself you can use u32 to avoid the usize issue
<birdistheword99[>
Ah ok, that makes sense, thanks :)
<birdistheword99[>
Does heapless String have a method to convert from raw bytes back to String?
Lumpio[m] has quit [Quit: Idle timeout reached: 172800s]
ryan-summers[m] has quit [Quit: Idle timeout reached: 172800s]
TomB[m] has quit [Quit: Idle timeout reached: 172800s]
sroemer has quit [Ping timeout: 252 seconds]
scorpion2185[m] has quit [Quit: Idle timeout reached: 172800s]
HumanG33k has quit [Ping timeout: 276 seconds]
HumanG33k has joined #rust-embedded
<cr1901>
Is there any precedent for optionally auto-generating memory.x for applications (so ppl who don't know the offhand can get started more quickly)?
<JamesMunns[m]>
I think embassy provides it by default? or the nrf-hal crates used to automatically provide it (maybe behind a feature?)
Lumpio[m] has joined #rust-embedded
<Lumpio[m]>
Double from_ is a bit cumbersome, maybe time for a PR to heapless? 🙂
<cr1901>
Why would embassy need to provide memory.x? Is it a convenience, or are apps expected to use a different memory region allocation?
<JamesMunns[m]>
sorry, "embassy hals"
<cr1901>
Ahhh. And yes, nrf-hal does it.
<dirbaio[m]>
embassy does it for rp, stm32 but not nrf
<dirbaio[m]>
PRs welcome
<cr1901>
I was looking for ideas for msp430 :P
<dirbaio[m]>
it's a convenience
<dirbaio[m]>
* a convenience yep
<dirbaio[m]>
it's best if hte HAL allows disabling it in case you need a custom memory map
<cr1901>
How does embassy hals disable it, enabled-by-default feature?
<dirbaio[m]>
Cargo feature memory-x
<dirbaio[m]>
it's not enabled by default, you have to enable it
<dirbaio[m]>
but the examples enable it, and that's what most people copypaste from
bartmassey[m] has quit [Quit: Idle timeout reached: 172800s]
jannic[m] has quit [Quit: Idle timeout reached: 172800s]
tamme[m] has quit [Quit: Idle timeout reached: 172800s]
adamgreig[m] has quit [Quit: Idle timeout reached: 172800s]
therealprof[m] has quit [Quit: Idle timeout reached: 172800s]
Jubilee[m] has joined #rust-embedded
<Jubilee[m]>
hey everyone, can someone show me a non-simple example of them using linker scripts to position "marker statics" in the binary? ...and by non-simple I do actually mean the weirder, the better, actually, though I might have some followup questions.