<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>
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]
<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
<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]>
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.
<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
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]
<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