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
<vollbrecht[m]> For the spicy Friday evening entertainment [HackerNews](https://news.ycombinator.com/item?id=39213595) thread about Aerogu - a rust RTOS written for the ATSAMV71Q21 Arm Cortex M7 🍿
<ithinuel[m]> <ragarnoy[m]> "but afaik i can't recompile libc..." <- The GNU Arm Embedded Toolchain comes with lots of variants of the libc, you can search for `libc.a` in `/usr/lib/gcc/arm-none-eabi/12.2.1/.../arm-none-eabi/bin/ld: failed to merge target specific data of file /home/.../gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib`, you should find lots of them.
<ithinuel[m]> ithinuel[m]: The flags passed to the compiler & linker let the toolchain pick the right libc to link against.
<khionu[m]> Update: I've got it working, but my NDEF tag seems to be malformed. But the events work, the sequence of events appears to be correct!
<michaeldesilva[m> Any ideas why this should "freeze" up - note that the blue led on my board flashes a couple times then stays on. The USB device does not appear in `/dev/.cu*`... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/tPcpvezjMoPJDLhvXMCUIxxR>)
<michaeldesilva[m> * Any ideas why this should "freeze" up - note that the blue led on my board flashes a couple times then stays on. The USB device does not appear in `/dev/.cu*`. However, this usb-serial example in the HAL crate works, but the LED blinks for a long time before I can see the USB device https://github.com/... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/WnQRKSKsggZurNIfJIsvRRvC>)
<michaeldesilva[m> Also, has anyone been able to get Jtag working with rust?
Guest7282 has left #rust-embedded [Error from remote client]
Guest7282 has joined #rust-embedded
<michaeldesilva[m> * Also, has anyone been able to get Jtag working with rust? This is my vscode `launch.json` which works when I flash the GIGA R1 with the mbed bootloader + Arduino `.ino` C++ code. However, it keeps saying timeout to GDB server when I try the same with the `stm32h7xx-hal` bare metal bin flashed to 0x0800_... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/VCWJcTykLrIYYdPAdIXVSULG>)
<michaeldesilva[m> * Also, has anyone been able to get Jtag working with rust? This is my vscode `launch.json` which works when I flash the GIGA R1 with the mbed bootloader (in this case the bootloader is flashed to 0x0800\_0000 and the `ino` source to 0x0804\_0000)+ Arduino `.ino` C++ code. However, it keeps saying... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/OBvbgWZDEDjjsTdinqHkxOYN>)
<JamesMunns[m]> <michaeldesilva[m> "Also, has anyone been able to..." <- > <@michael.desilva:matrix.org> Also, has anyone been able to get Jtag working with rust? This is my vscode `launch.json` which works when I flash the GIGA R1 with the mbed bootloader (in this case the bootloader is flashed to 0x0800\_0000 and the `ino... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/oEYaLzXZPQvCxtexJRMJuaKK>)
Guest7282 has left #rust-embedded [Error from remote client]
Guest7282 has joined #rust-embedded
Congyu[m] has joined #rust-embedded
<Congyu[m]> Got into rust embedded programming just for a week. A lot of fun. After reading the 'Discovery' book chapter 5 modified it into a little game here: https://github.com/Congyuwang/microbit-tug-of-war . Used PWM for playing sound.
Guest7282 has left #rust-embedded [Error from remote client]
Guest7282 has joined #rust-embedded
GrantM11235[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7282 has left #rust-embedded [Error from remote client]
Ralph[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7282 has joined #rust-embedded
<ragarnoy[m]> <ithinuel[m]> "The flags passed to the compiler..." <- yeah but in my use case i need to find the correct one myself ?
<ithinuel[m]> ragarnoy[m]: What’s your MCU’s core ? that’d help figure which `march`/`mcpu` you need to pass
<ragarnoy[m]> <ithinuel[m]> "What’s your MCU’s core ? that’..." <- stm32l431cbyx
M9names[m] has joined #rust-embedded
<M9names[m]> <ragarnoy[m]> "stm32l431cbyx" <- that's an cortex-m4 with FPU
adamgreig[m] has quit [Quit: Idle timeout reached: 172800s]
<M9names[m]> <M9names[m]> "that's an cortex-m4 with FPU" <- if you've set the correct CFLAGS and are using gcc to link, it should pass the correct linker settings for you.
<M9names[m]> not sure what your current CFLAGS are but
<M9names[m]> "-mthumb -mcpu=cortex-m4 -mfloat-abi=hard" should be sufficient to get what you need IIRC
sirhcel[m] has quit [Quit: Idle timeout reached: 172800s]
IlPalazzo-ojiisa has joined #rust-embedded
<ragarnoy[m]> <M9names[m]> "if you've set the correct CFLAGS..." <- > <@9names:matrix.org> if you've set the correct CFLAGS and are using gcc to link, it should pass the correct linker settings for you.... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/tZeWMFzTxMXtFpvDRCYtjxYN>)
<ragarnoy[m]> <ragarnoy[m]> "> <@9names:matrix.org> if you've..." <- wait, adding mthumb might have changed things, now I have
<ragarnoy[m]> ```/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /build/newlib-pB30de/newlib-3.3.0/build/arm-none-eabi/thumb/v7e-m+fp/hard/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/dtoa.c:352: undefined reference to `__aeabi_dsub'
<ragarnoy[m]> ```
<ragarnoy[m]> * wait, adding mthumb might have changed things, now I have... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/jLeSllGTNeIDTGCrRGfCMStN>)
<ragarnoy[m]> <ragarnoy[m]> "wait, adding mthumb might have..." <- apparently i was also missing lgcc, but now I have this... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/ocRULLbpaPqbmjBSwJYWDtKL>)
<ithinuel[m]> ragarnoy[m]: htmm, are you trying to link a rust library in a C application or a C library in a rust application?
<ithinuel[m]> <ithinuel[m]> "htmm, are you trying to link a..." <- (asking because I did both and never had the issues you’re having, and I see some mixed signals)
<ragarnoy[m]> ithinuel[m]: i'm linking a c library to a rust application
<ragarnoy[m]> ragarnoy[m]: i'm linking an SDK for a radar antenna that is written in C
<ithinuel[m]> ragarnoy[m]: Is there any requirement to use GCC for the linking rather than rust’s llvm linker?
<ragarnoy[m]> ithinuel[m]: well, a lot of it is lack of comprehension on my part, but the static library was built with arm-none-eabi-gcc and is proprietary so i can't rebuild it
<ithinuel[m]> ragarnoy[m]: I’d expect to see the default linker and the `link-lib` flag: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib
<ragarnoy[m]> ithinuel[m]: there's also a lot of it here... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/gbsqGSGERFECJkZIOyRUtybK>)
<ragarnoy[m]> ithinuel[m]: is it any different from linking in the config.toml ?
<ithinuel[m]> ragarnoy[m]: (I'm away for lunch, will be right back)
<ithinuel[m]> <ithinuel[m]> "(I'm away for lunch, will be..." <- I’m back
StephenD[m] has joined #rust-embedded
<StephenD[m]> Are there any decent nostd libraries for serializing/deserializing a struct for flash storage?
<StephenD[m]> In an ideal world I'd also like to know the size of the output at compile time. Right now I've just been doing it all manually
<ithinuel[m]> <ithinuel[m]> "I’m back" <- Thanks for the snippet. What I’ll say is mostly a guess because when I did it, the C library was built on its own, not through build.rs/cargo.
<ithinuel[m]> You might need to pass the arguments to the build on the wrapper & bindings.
<ragarnoy[m]> ithinuel[m]: > <@ithinuel:matrix.org> Thanks for the snippet. What I’ll say is mostly a guess because when I did it, the C library was built on its own, not through build.rs/cargo.... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/CiYixtajriezBWMyBcNxEbVW>)
<ragarnoy[m]> ragarnoy[m]: the c library is the acconeer library i'm linking to
<ithinuel[m]> ragarnoy[m]: ```
<ragarnoy[m]> ithinuel[m]: basically the c library requires a log function that has varargs in it, which can't really be easily done in rust
<ragarnoy[m]> ragarnoy[m]: so i had to make a quick c file
<ithinuel[m]> ragarnoy[m]: The error that you’re having is because both gcc & llvm are trying to provide that function.
<ithinuel[m]> I can’t remember how I solved/avoided that issue 🤦
<ragarnoy[m]> ithinuel[m]: hmm
<ragarnoy[m]> ragarnoy[m]: worst part is i'm pretty sure that at some point i lost track of all the stuff and some of it is probably unneeded
<JamesMunns[m]> ragarnoy[m]: There's a rustc issue for this, there's a workaround where you can strip all of the duplicate symbols out of one of the archives
adamgreig[m] has joined #rust-embedded
<adamgreig[m]> serde+postcard, or zerocopy?
<ragarnoy[m]> JamesMunns[m]: what's the workaround ? also, is there an alternative to what i'm doing ? it seems super convoluted and overkill
<adamgreig[m]> not sure you can get compile-time size from serde+postcard, but with a repr(c) struct and zerocopy I expect core::mem::size_of (which is const) would work
<adamgreig[m]> postcard output size can depend on the data self because ints are variable-length encoded, but if you have a repr(c) struct I think it's fixed?
<JamesMunns[m]> ragarnoy[m]: I'm looking, it requires a little bit of scripting and binutils, it's not pleasant
<JamesMunns[m]> adamgreig[m]: postcard doesn't consider reprc at all
<JamesMunns[m]> there's an experimental Sized derive which can get you an upper bound
<adamgreig[m]> I was flicking between the size_of and postcard docs tabs and misread a bit about repr(c) as being part of postcard 😅
<JamesMunns[m]> it fails on "open ended" types like Vec or String, but heapless types can be counted
<JamesMunns[m]> adamgreig[m]: this works until you accidentally use `usize` in your messages.
<JamesMunns[m]> then it works on both sides, they just silently disagreen
<JamesMunns[m]> also if padding happens to differ between the two.
<JamesMunns[m]> s/disagreen/disagree/
<adamgreig[m]> yea, worth bearing in mind. if it's just for flash storage it's possibly only being written and loaded on the same architecture though
<adamgreig[m]> still, Stephen D do try serde+postcard first, it has way fewer things you need to worry about like that
<ragarnoy[m]> <ragarnoy[m]> "what's the workaround ? also, is..." <- i don't get why all of this is necessary, if something is compile in arm-none-eabi-gcc it can't be linked in rust without going through all these hoops?
<JamesMunns[m]> ragarnoy[m]: if you provide a symbol twice what is the linker supposed to do?
<ithinuel[m]> ragarnoy[m]: Why is `-lgcc` required ? (I can’t remember).
<ragarnoy[m]> JamesMunns[m]: yeah but why do i need to provide it if llvm already has it
<JamesMunns[m]> ragarnoy[m]: the issue is LLVM and GCC helpfully both provide the same symbols, because each parts need it
<ragarnoy[m]> ithinuel[m]: maybe it's not tbf it gave me a smaller/different error but maybe i'll revert to the old error when i fix the new one
<StephenD[m]> Cool, I'll give postcard a try. Thanks
<JamesMunns[m]> like A->C and B->C, where C is a common library symbol
<JamesMunns[m]> but it's really Cllvm and Cgcc
<JamesMunns[m]> and the linker sees two Cs, and goes "wtf?"
<JamesMunns[m]> s/Cs/`C`s/
<JamesMunns[m]> so the fix is EITHER:
<JamesMunns[m]> * give each a unique name, like `C_llvm` and `C_gcc`, not a problem anymore, OR
<JamesMunns[m]> * Remove one of them, hope they are ABI compatible
<JamesMunns[m]> I found this issue a year ago, I don't have it handy tho, I am still looking.
<ragarnoy[m]> ragarnoy[m]: if i remove the gcc linker i start with this small error:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/YtffaljoWhhebWqpNtrkOLdK>)
<ragarnoy[m]> ragarnoy[m]: then if i include libc, then i need to include no sys, but then i need to add the nostd flag, etc etc
<michaeldesilva[m> <JamesMunns[m]> "> <@michael.desilva:matrix.org..." <- Yes, it is a Jlink mini on the JTAG/SWD header. Do I need to enable... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/NlbWGWntMCGGSfslDYqjpSGd>)
<ithinuel[m]> <ragarnoy[m]> "then if i include libc, then i..." <- It may be a bit ugly but how about having a... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/BQKiMVCmBqhNTodbZqixwpQU>)
<ithinuel[m]> ithinuel[m]: and expose some no_mangle’d method to manipulate a `heapless::String<128>` from C?
<ragarnoy[m]> ithinuel[m]: yeah, but what about vsnprintf and snprintf ?
<ithinuel[m]> ragarnoy[m]: Oh, you mean for the conversion?
<JamesMunns[m]> ragarnoy this was the thread I was thinking of:
<FreeKill[m]> ragarnoy[m]: If this is what you're linking libc for, there are freestanding implementations you can use instead
<ithinuel[m]> FreeKill[m]: nothing a few `void print_uint32_to_str(void *str, uint32_t v)` can do (with variants for other types 😄
<ithinuel[m]> * v)` can’t do, * other types) 😄
jannic[m] has joined #rust-embedded
<jannic[m]> Is anyone at FOSDEM this year?
<ragarnoy[m]> <ithinuel[m]> "nothing a few `void print_uint32..." <- not that simple sadly... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/LtmGwARZWmdcrsGURmuiOqyZ>)
<ragarnoy[m]> ragarnoy[m]: i mean, it can be done but it's odd that i have to do all of those things
<ragarnoy[m]> <JamesMunns[m]> "ragarnoy this was the thread I..." <- > <@jamesmunns:beeper.com> ragarnoy this was the thread I was thinking of:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/pNgSAcsExuVHxvwZdtBFLKvB>)
<ithinuel[m]> jannic[m]: I noticed it too late, so I wont.
<ithinuel[m]> I’ll try to remember it in time for next year though 🤞
<ithinuel[m]> ithinuel[m]: Also keeping an eye on eurorust
<JamesMunns[m]> ithinuel[m]: I'll definitely be at RustNL in May!
<FreeKill[m]> ragarnoy[m]: I'm trying to read back but it's a little hard to follow - am I right that you can successfully build the c library, its just a symbol conflict when linking to a rust? Or have I misunderstood
<ragarnoy[m]> <FreeKill[m]> "I'm trying to read back but it's..." <- brb, i'll explain everything when i get back
notgull has joined #rust-embedded
notgull has quit [Ping timeout: 246 seconds]
<thejpster[m]> I saw this on the Arm discord from a few weeks ago:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/JpolnFScELrEhPZBmGKCRKBe>)
<ragarnoy[m]> <FreeKill[m]> "I'm trying to read back but it's..." <- I can build it if I include the libc to the linker
<ragarnoy[m]> ragarnoy[m]: But by including the libc I include other things
dodothattried[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7282 has left #rust-embedded [Error from remote client]
<adamgreig[m]> huh, that platform-support page is new
<adamgreig[m]> disappointingly it looks like all the updates in https://github.com/davidtwco/rust/pull/1 never got merged and instead someone else wrote https://github.com/rust-lang/rust/pull/119102 a few months later which did
<adamgreig[m]> ah I see, https://github.com/rust-lang/rust/pull/116004 got closed
<adamgreig[m]> I missed that somehow
Guest7282 has joined #rust-embedded
ainedixon[m] has quit [Quit: Idle timeout reached: 172800s]
<ragarnoy[m]> <JamesMunns[m]> "if you provide a symbol twice..." <- by the way, how can i use tinyrlib's snprintf and vsnprintf implementation to replace undefined symbols? Do i have to make the no mangle symbol and use the unstable feature to have var args in the code ?
<JamesMunns[m]> ragarnoy[m]: I have no idea, sorry.
<ragarnoy[m]> JamesMunns[m]: oh sorry i thought you were author on that crate i must have thought of someone else!
<thejpster[m]> We should probably just send our own PR to the repo if we want to clean up our targets.
K900 has quit [Quit: Idle timeout reached: 172800s]
Foxyloxy has quit [Quit: Textual IRC Client: www.textualapp.com]
<adamgreig[m]> yea, I'll do so with the changes from that PR
Foxyloxy has joined #rust-embedded
<ragarnoy[m]> <ithinuel[m]> "nothing a few `void print_uint32..." <- i replaced the implementation of several of the function, but the core hardfaults when a function from the c sdk is called
<ragarnoy[m]> any tips on how to investigate a hardfault caused by a C function called by rust code ?
<ragarnoy[m]> * hey, me again, any tips
<JamesMunns[m]> Gdb and single stepping?
<ragarnoy[m]> doez probe-rs gdb ?
<ragarnoy[m]> * probe-rs gdb ?
<JamesMunns[m]> It can provide a gdb server, yes
<JamesMunns[m]> I think their docs show how to set it up with vs code or I'd imagine you could use it in cli/tui mode
<ragarnoy[m]> <JamesMunns[m]> "I think their docs show how to..." <- i managed to get something running, and got... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/SvsseXUMbDGYEPHOzLHqwloD>)
<ragarnoy[m]> > <@jamesmunns:beeper.com> I think their docs show how to set it up with vs code or I'd imagine you could use it in cli/tui mode... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/CDTRviUDcsVMbvSvptrGCWlU>)
<ragarnoy[m]> it's a bit weird since it mentions a private function from the c library i'm interfacing but also giving the line of a compiler builtin:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/qaeErDeHelYNUCZXChesxcPv>)
mameluc[m] has quit [Quit: Idle timeout reached: 172800s]
emerent has quit [Ping timeout: 256 seconds]
emerent has joined #rust-embedded
bpye has quit [Quit: Ping timeout (120 seconds)]
bpye has joined #rust-embedded