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
M762spr[m] has joined #rust-embedded
<M762spr[m]> Just got some nRF52840 dongles in the mail to play with!
<M762spr[m]> Is it possible to program them via probe-rs over USB (plugging the dongle into my PC) or does it have to go through SWD and a programmer?
<i509vcb[m]> If you can setup an image that mcuboot (which is what it ships with) can boot then probably
<i509vcb[m]> But you'd ideally want a debugger
<i509vcb[m]> And one that can track the target voltage
Noah[m] has joined #rust-embedded
<Noah[m]> M762spr[m]: probe-rs only concerns debuggers :)
<M762spr[m]> Makes sense. I guess that's what I'm used to anyway but the prospect of just plugging it in and playing with it would be nice. At least they put a TC connector on there
<M762spr[m]> This is probably a question for a nRF (assuming there is one) but how does the loading of sorter ices work in the rust ecosystem? De we just load them the normal way with nRF tools and then make sure to flash past that with memory.x?
<M762spr[m]> s/sorter/softdevices/, s/ices//
<i509vcb[m]> There is also room on the bottom for soldering a 1.27mm IDC socket if you have the room there (and don't want the other pins)
<i509vcb[m]> s/socket/header/
<M762spr[m]> Thanks! That may be worth doing since the little retainer sockets for the tag connects never stay on...
<i509vcb[m]> I think it conflicts with the headers if you want it on a breadboard though
<i509vcb[m]> Actually a second
<i509vcb[m]> Those two are also SWD if you want to solder on headers on the bottom and then just dupont wire to it
<M762spr[m]> Thanks!
<M762spr[m]> For now I only need it to send some BLE messages so having it dangle on a programming cable won't be too bad but eventually I know I'll want to hook some stuff up to it.
<M762spr[m]> Looks like embassy has a nrf-softdevice repo. Shout out to the Embassy guys that make things so easy for the rest of us! 🫡
sroemer has joined #rust-embedded
sroemer has quit [Changing host]
sroemer has joined #rust-embedded
_whitelogger has joined #rust-embedded
M9names[m] has quit [Quit: Idle timeout reached: 172800s]
_whitelogger has joined #rust-embedded
<thejpster[m]> I just use nrfdfu-rs with my dongle
pcs38 has joined #rust-embedded
<RobinMueller[m]> cr1901: To be honest, I had a look at the interrupts again, and I saw that almost all of them are disabled by default. So I think this is not a big of a concern I initially thought.. One other issue: I am thinking of introducing a bootloader + main app combo on the FRAM of the MSP430. Do you know if the mspdebug tool erases the full FRAM? There is only one IVT, so I probably need to do some black magic with copying around
<RobinMueller[m]> reset vectors, for example to ensure that my app only boots to the bootloader
<RobinMueller[m]> * one IVT and no VTOR offset register like on cortex-m4, so, * the bootloader. do you have experience with something like that?
Matt[m] has joined #rust-embedded
<Matt[m]> s/However, the DEST_ADDR and the data included from `include_bytes!` overlap. `core::ptr::copy` is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `mempy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler assuming I can't write to that location so therefore there would never be any
<Matt[m]> overlap?/However, the `DEST_ADDR` and the data included from `include_bytes!` overlap. `core::ptr::copy` is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `memcpy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler assuming I can't write to that location so therefore there would
<Matt[m]> never be any overlap?/
<Matt[m]> s/DEST_ADDR/`TARGET_ADDR`/, s/mempy/memcpy/
<Matt[m]> s/However, the DEST_ADDR and the data included from `include_bytes!` overlap. `core::ptr::copy` is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `mempy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler assuming I can't write to that location so therefore there would never be any
<Matt[m]> overlap?/However, the `TARGET_ADDR` and the data included from `include_bytes!` overlap. According to the docs `core::ptr::copy` should have `memove` semantics but it is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `memcpy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler
<Matt[m]> assuming I can't write to that location so therefore there would never be any overlap?/
<Matt[m]> s/However, the DEST_ADDR and the data included from `include_bytes!` overlap. `core::ptr::copy` is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `mempy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler assuming I can't write to that location so therefore there would never be any
<Matt[m]> overlap?/However, the `TARGET_ADDR` and the data included from `include_bytes!` overlap. According to the docs `core::ptr::copy` should have `memmove` semantics but it is emitting a `memcpy` intrinsic and so the copy fails. I can hand-roll a reverse copy loop but I'm trying to understand why the compiler is emitting `memcpy` rather than `memmove`. My only thought is that `include_bytes!` returns a `& 'static`, so is the compiler
<Matt[m]> assuming I can't write to that location so therefore there would never be any overlap?/
<RobinMueller[m]> cr1901: are 20 bit-address read/writes supported in principle? I am trying to access FRAM beyond 0x10000 and encounter weird behaviour...
<thejpster[m]> @Matt: Plausible. Can you not configure the linker to locate the blob where it needs to be, instead of having to move it?
<Matt[m]> <thejpster[m]> "@Matt: Plausible. Can you not..." <- I had that same thought, but I don’t think it will make a difference? The compiler has already emitted code before we link, so the address wouldn’t matter?
<Matt[m]> In any case the address in the linked script is correct, so can statically infer that it is an overlapping copy.
<Matt[m]> s/linked/linker/
<Matt[m]> * In any case the address in the linker script is correct, so it can statically infer that it is an overlapping copy.
<Matt[m]> * In any case the address in the linker script is correct, so it can statically infer that it is an overlapping copy/move.
<Matt[m]> <thejpster[m]> "@Matt: Plausible. Can you not..." <- I don’t think so, I’m passing the blob eventually as the -kernel parameter to qemu. So I need a small bit of code to place the payload at the correct address in memory.
<thejpster[m]> Ah. Interesting.
<dirbaio[m]> What do you mean with "doesn't work"?
<dirbaio[m]> U8's have an align of 1, so the layout of that struct is the same whether it's packed or not.
<jason-kairos[m]> I'm saying that I (either observed, or fooled myself into thinking) similar enums containing u8 fields having an alignment of 4 on arm cortex m0 with [repr(C)] and an alignment of 1 with [repr(packed)]
<jason-kairos[m]> * I'm saying that I (either observed, or fooled myself into thinking) similar enums containing u8 fields behaved as if they had an alignment of 4 on arm cortex m0 with \[repr(C)\] and an alignment of 1 with \[repr(packed)\]
<jason-kairos[m]> * I'm saying that in the past I (either observed, or more likely, fooled myself into thinking) similar enums containing u8 fields behaved as if they had an alignment of 4 on arm cortex m0 with \[repr(C)\] and an alignment of 1 with \[repr(packed)\]
<jason-kairos[m]> is there some place I can view a table of LLVM's alignment/etc. by target triplet?
<jason-kairos[m]> * I'm saying that in the past on a ARM Cortex M0+ platform I (either observed, or more likely, fooled myself into thinking) similar enums containing u8 fields behaved as if they had an alignment of 4 on with \[repr(C)\] and an alignment of 1 with \[repr(packed)\]
<jason-kairos[m]> * I suppose I'm saying that in the past on a ARM Cortex M0+ platform I (either observed, or more likely, fooled myself into thinking) similar enums containing u8 fields behaved as if they had an alignment of 4 on with \[repr(C)\] and an alignment of 1 with \[repr(packed)\]
<jason-kairos[m]> * I suppose I'm saying that in the past on a ARM Cortex M0+ platform I (either observed, or more likely, fooled myself into thinking) similar enums containing u8 fields behaved as if they had an alignment of something other than 1 (perhap 4?) on with \[repr(C)\] and an alignment of 1 with \[repr(packed)\]
<jason-kairos[m]> alternatively, is there some easy way to extact struct layout information from elf/object files?
JamesMunns[m] has joined #rust-embedded
<JamesMunns[m]> You can use align_of! and offset_of! In your rust code at least
<JamesMunns[m]> (and size_of!)
<jason-kairos[m]> I think it might be just tough to access than information to compare layouts directly
<jason-kairos[m]> s/just//
<jason-kairos[m]> s/just//, s/than/that/
vollbrecht[m] has joined #rust-embedded
<vollbrecht[m]> type information alone cannot be enough, for example tage the rust ffi c_char. Its dependend on the platform you are using.
<vollbrecht[m]> If you know use a dyn lib and call into it, that information how that other thing was made is not available to your types.
<vollbrecht[m]> s/tage/take/, s/c_char/c\_char/
<vollbrecht[m]> * type information alone cannot be enough, for example take the rust ffi c_char. Its dependend on the platform you are using.
<vollbrecht[m]> If you now use a dyn lib and call into it, that information how that other thing was made is not available to your types.
<jason-kairos[m]> I think gdb might be able to be coaxed into doing it in a statically linked binary (as is normal for embedded)... (full message at <https://catircservices.org/_irc/v1/media/download/AVtdWCu09y___8eOxYRhxgvVARUAPy5uHs-hke-4f1t1t-_l-eZK2BFwSK-rbntIvLloB1HBhucRhwGSadXHbhS_8AAAAAAAAGNhdGlyY3NlcnZpY2VzLm9yZy9DaHZ0VUJGdEtRVmlFTHBia2drVmRad0k>)
<jason-kairos[m]> * I think gdb might be able to be coaxed into doing it in a statically linked binary (as is normal for embedded)... (full message at <https://catircservices.org/_irc/v1/media/download/AacX8CMNtnzSQI1Km8rv5AlaEJZlFKcOP4gpjlC0wb2qrTORcKpvrHPYPWTyI2qa9oXztwxSuuzvcled2hzcnse_8AAAAAAAAGNhdGlyY3NlcnZpY2VzLm9yZy9TT2ROeVRhY2dpYXhIU2ZuZnFmVWJHTkM>)
<jason-kairos[m]> the symbols exist (they probably contain all of the layout information), I can tab complete them and search them.
<jason-kairos[m]> But for some reason it does not allow me print them
<jason-kairos[m]> okay - got lucky, talked with a gdb maintainer, and it's a bug - wohoo!
pcs38 has quit [Quit: leaving]
<jason-kairos[m]> Why isn't repr(c) the same as repr(packed)?
<jason-kairos[m]> I've wrangled the debugger into printing offsets for both C (gcc) and Rust (llvm)
ivche_ has joined #rust-embedded
ivche has quit [Ping timeout: 272 seconds]
ivche_ is now known as ivche
Ekho has quit [Remote host closed the connection]
Ekho has joined #rust-embedded
sroemer has quit [Quit: WeeChat 4.5.2]
<cr1901> RobinMueller[m]: 20 bit addresses would require LLVM support, and telling Rust about RAM, ROM, and I/O addrspaces. Tbh, I've never actually seen MSP430X code in the wild, so I don't know how TI's C compiler handles "data ptr len" != "code ptr len".
<cr1901> With AVR at least, all the addrspaces are the same width (16 bits) _I think_?
<cr1901> TLDR: Yea it's possible in principle, but I would "do what Rust AVR does and abstract the addrspace stuff away". Not clear to me how TI/other MSP430X users handle your issue of "go beyond 0x10000"
<RobinMueller[m]> cr1901: I suppose I will have to work with the first 65 kB (or more like 49 kB because of memory map setup) of the FRAM
<jason-kairos[m]> Has anyone here ever used or made a crate/type/etc. that automatically serializes and deserializes data - and adds/checks a CRC
<jason-kairos[m]> I currently use BinarySerde for reading and writing settings to and from flash. But often find myself wanting a version and a CRC code. Doing it manually is 'fine' but some day I'd like to automate it (or find a crate that does)
<jason-kairos[m]> * Has anyone here ever used or made a crate/type/etc. that automatically serializes and deserializes data in a struct - and adds/checks a CRC?
<jason-kairos[m]> I currently use BinarySerde for reading and writing settings to and from flash. But often find myself wanting a version and a CRC code. Doing it manually is 'fine' but some day I'd like to automate it (or find a crate that does)
<jason-kairos[m]> * Has anyone here ever used or made a crate/type/etc. that automatically serializes and deserializes data in a struct - and adds/checks a CRC?
<jason-kairos[m]> I currently use BinarySerde for reading and writing settings to and from flash. But often find myself wanting to attach a version number and a CRC code. Doing it manually is 'fine' but some day I'd like to automate it (or find a crate that does)
<dngrs[m]> jason-kairos[m]: James Munns and adamgreig have been through this a few times
<dngrs[m]> at least James is currently at RustWeek tho
<dngrs[m]> dunno about adam
<dngrs[m]> * dunno about Adam
adamgreig[m] has joined #rust-embedded
<adamgreig[m]> (I'm also at rustweek)
<RobinMueller[m]> cr1901: have you ever implemented a multi-app boot, something similar like https://www.ti.com/lit/an/slaa600e/slaa600e.pdf?ts=1747228511901 using Rust?
<cr1901> RobinMueller[m]: Never implemented it, but I started implementing flash writing for MSP430, saw the crap jannic had to go through for RP2040, and decided its not something I want to do right now: https://github.com/rp-rs/rp-hal/issues/257#issuecomment-1212345394
<cr1901> Actually, I need to review this code again: https://github.com/jannic/rp2040-flash/blob/master/src/lib.rs There's actually _less_ inline asm than I remember...
<RobinMueller[m]> cr1901: This FRAM seems to have simple RAM like access for writes as well. I think it is just that only having one single IVT makes everything more tricky. Especially if I still want to use a regular dev workflow which overwrites the IVT (and therefore messes up the bootloader)
<RobinMueller[m]> s/as well//
<RobinMueller[m]> s/as/(or/, s/well/is this not the case? It did work like that for information memory)/
<RobinMueller[m]> * cr1901: This FRAM seems to have simple RAM like access for writes (or is this not the case? It did work like that for information memory). I think it is just that only having one single IVT makes everything more tricky. Especially if I still want to use a regular dev workflow which overwrites the IVT (and therefore messes up the bootloader). There is the option to remap the IVT to RAM, but that basically makes application
<RobinMueller[m]> compiled for app slot A/B unusable because those would have their IVT at a different location, for the bootloader to be copied to RAM..
<RobinMueller[m]> * cr1901: This FRAM seems to have simple RAM like access for writes (or is this not the case? It did work like that for information memory). I think it is just that only having one single IVT makes everything more tricky. Especially if I still want to use a regular dev workflow which overwrites the IVT (and therefore messes up the bootloader). There is the option to remap the IVT to RAM, but that basically makes application
<RobinMueller[m]> compiled for app slot A/B unusable for regular flashing because those would have their IVT at a different location, for the bootloader to be copied to RAM..
<cr1901> slot A/B?
<jason-kairos[m]> Do both x86 and ARM cortex M0 (eg. STM32) represent integers the same in memory?
<jason-kairos[m]> * in memory? (did some serialization stuff, and have backwards integers)
ithinuel[m] has joined #rust-embedded
<ithinuel[m]> Cortex-M0 are typically using little endian.
<ithinuel[m]> * Cortex-M0 are typically using little endian.
<ithinuel[m]> 0x1234_5678 would be in memory as 0x78 at address 0, 0x56 at 1 etc.
<ithinuel[m]> From a quick google search it seems like x86 are the same.
<RobinMueller[m]> cr1901: basically, I have a bootloader and 2 applications inside executable FRAM. the bootloader determines which app to boot depending on a parameter in FRAM, and then boots that app
<cr1901> RobinMueller[m]: To be clear, I've never used the FRAM series.
<cr1901> From what I'm reading, I think the IVT remapping is explicitly for bootloaders. I think regardless, you will have to flash the IVT-in-flash anyway before you jump to either application A or B.
<cr1901> (Basically, I'm don't understand your explanation for why mapping the IVT to RAM for the bootloader is not an option)
pcs38 has joined #rust-embedded
<RobinMueller[m]> cr1901: I have to flash the IVT at the regular FRAM address? my plan was (and maybe that does not work?) that I will not touch the bootloader and the FRAM vectors anymore for a regular update process. in the TI bootloader, the bootloader and FRAM vectors are also read-only, but they use a proxy jump table (see p.8 of the docs I sent) to allow this. They suggested that redirection with SYSRIVECT would be an alternative option
<RobinMueller[m]> with enough RAM available.
<RobinMueller[m]> * RAM available. I understood this as: Instead of using a proxy-jump table, copy the respective application vectors to the top of RAM, enable the redirection bit, and jump to the app.
<RobinMueller[m]> * RAM available. I understood this as: Instead of using a proxy-jump table, copy the respective application vectors to the top of RAM, enable the redirection bit
norineko has quit [Remote host closed the connection]
norineko has joined #rust-embedded
adamgreig_ has quit [Ping timeout: 260 seconds]
adamgreig_ has joined #rust-embedded
pcs38 has quit [Quit: leaving]
jfsimon has quit [Read error: Connection reset by peer]
<cr1901> RobinMueller[m]: Did you send a doc? I don't see any (I'm on the IRC side of the bridge)
<cr1901> oooh that link
<cr1901> A proxy jump table, presumably with inline asm should work. But I'd have to build my own A/B/bootloader application to know for sure. And right now, I only have the bandwidth to make sure that msp430 isn't breaking in nightly. I also don't have FRAM hardware
<cr1901> RobinMueller[m]: Basically, what you want to do should be possible, but I don't know how to go about it without building my own and seeing what issues I run into myself.
<cr1901> Btw, is jannic on the matrix side of the bridge?
jannic[m] has joined #rust-embedded
<jannic[m]> Yes, I am
<cr1901> jannic[m]: Since you did the rp2040 flashing code, is it okay if I pick your brain when I get around to doing a flasher for msp430 :P
<cr1901> (whenever that is...)
<jannic[m]> You are welcome to ask, but I fear most of the implementation is very rp2040 specific.
<RobinMueller[m]> cr1901: I already started implementing a bootloader, let's see if I can make it work :) I'll go with the re-direct route first though. In my case, I do not want a download slot / application slot distinction, but two active images where a preferred one can be selected via persistent parameter, and the redirect is more suitable for that I think. The proxy table example assumes just one active slot if I understand correctly
<cr1901> RobinMueller[m]: Ack, that works. I can also take a peek and then cross-ref with jannic[m] or other ppl who built a bootloader (i.e. "is it UB to copy a function to RAM and jump to it?")
rom4ik has quit [Quit: Ping timeout (120 seconds)]
rom4ik has joined #rust-embedded
ivche has quit [Ping timeout: 265 seconds]
ivche has joined #rust-embedded
ivche_ has joined #rust-embedded
ivche has quit [Ping timeout: 272 seconds]
ivche_ is now known as ivche
WSalmon has quit [Remote host closed the connection]
WSalmon has joined #rust-embedded