starblue3 has quit [Ping timeout: 250 seconds]
starblue3 has joined #rust-embedded
fabic has quit [Ping timeout: 252 seconds]
edm has quit [Ping timeout: 248 seconds]
dreamcat4 has quit [Ping timeout: 250 seconds]
edm has joined #rust-embedded
dreamcat4 has joined #rust-embedded
<re_irc> <@firefrommoonlight:matrix.org> OK. Got the H7 Nucleo to play tones on my headphones by setting a timer that toggles the DAC output between a fixed value and 0. Next up: Sin waves, which from a google search, I think are done via LUTs for performance reasons
<re_irc> <@firefrommoonlight:matrix.org> Probably using a timer to identify how far you are in a given cycle
edm has quit [Ping timeout: 250 seconds]
darknighte has quit [Read error: Connection reset by peer]
SanchayanMaity has quit [Read error: Connection reset by peer]
dreamcat4 has quit [Ping timeout: 250 seconds]
SanchayanMaity has joined #rust-embedded
darknighte has joined #rust-embedded
edm has joined #rust-embedded
dreamcat4 has joined #rust-embedded
fabic has joined #rust-embedded
_whitelogger has joined #rust-embedded
nohit has joined #rust-embedded
richardeoin has quit [*.net *.split]
jasperw has quit [*.net *.split]
jasperw has joined #rust-embedded
richardeoin has joined #rust-embedded
emerent has quit [Ping timeout: 250 seconds]
emerent_ has joined #rust-embedded
emerent_ is now known as emerent
ni has quit [Quit: WeeChat 2.8]
ni has joined #rust-embedded
GenTooMan has quit [Ping timeout: 250 seconds]
ni has quit [Client Quit]
ni has joined #rust-embedded
<re_irc> <@mathias_koch:matrix.org> What is the easiest way to move the stack pointer back to a valid location in a Hardfault handler, when using flip-link and encountering a stack-overflow, in order to do a panic/log before rebooting? And is it possible without nightly?
<re_irc> <@nihal.pasham:matrix.org> the easiest way is to write to `msp` directly but am assuming the problem is figuring out a valid location with flip-link turned-on
<re_irc> <@nihal.pasham:matrix.org> as with flip-link turned-on the stack's upper bound is random
<Lumpio-> Is it not available as a linker symbol?
<re_irc> <@mathias_koch:matrix.org> Couldn't i just put it anywhere within my valid stack, if my only goal is to do a log + system reset, and i no longer care about any other contents of the stack?
<Lumpio-> If you never plan to return again, you could probably do that.
<re_irc> <@mathias_koch:matrix.org> That would be the plan
<Darius> doing that means you would probably destroy your stack trace
<re_irc> <@mathias_koch:matrix.org> i am using panic_persist, so the plan would be to just move the stack pointer to a valid location, and call an explicit panic
<Darius> you could reserve some memory for an emergency stack
<re_irc> <@nihal.pasham:matrix.org> Hi, something I've been working on (at work) - https://github.com/nihalpasham/rustBoot
<re_irc> <@nihal.pasham:matrix.org> We're finally ready to go public with `rustBoot`. I think we have the design hashed-out but its still early days and there's a lengthy roadmap ahead. I'd love to hear your thoughts. Feel free to chime-in on the repo if you're interested in security.
dcz has joined #rust-embedded
GenTooMan has joined #rust-embedded
fabic has quit [Ping timeout: 252 seconds]
<re_irc> <@jamesmunns:matrix.org> Congrats! One question though: "GPL2 or MIT" seems like a pretty big spread, license wise. Is it possible to use rustBoot without the GPL2 components?
<re_irc> <@jamesmunns:matrix.org> (usually when I see "OR" in the license text, the user is free to choose either, but if core parts of the bootloader are GPL2, then I don't think it's possible for the user to choose MIT without violating the terms of GPL2)
emerent has quit [Read error: Connection reset by peer]
emerent has joined #rust-embedded
<re_irc> <@nihal.pasham:matrix.org> afaik, we can, I managed to contain (pretty much) all of the derived work that rustBoot depends on in the `rustBoot_update` crate. So, barring that crate everything else shouldn't have conflicts if the user chooses to go either way.
<re_irc> <@nihal.pasham:matrix.org> but I'm no expert on licensing, is it better to avoid the dual-license option and pick one in this case (i.e. just go with GNU GPL v2.0)?
<re_irc> <@nihal.pasham:matrix.org> one more point - as MIT doesn't require modifications be open sourced whereas the GPL does - I thought I'd leave the option say if a user wants a way out
<re_irc> <@jamesmunns:matrix.org> If you have it split out by crate like that, you can make the top level crate MIT, but the rustboot_update crate GPL.
<re_irc> <@jamesmunns:matrix.org> that way if you have it as a transitive dependency, you'd know you definitely have GPL code
<re_irc> <@jamesmunns:matrix.org> and it would be clear to the user they would have to rewrite/replace that crate if they wanted to avoid the gpl2 dependency.
<re_irc> <@jamesmunns:matrix.org> In general: Once you link in gpl2 code into your binary: the whole binary is now gpl2 licensed.
<re_irc> <@jamesmunns:matrix.org> I thiiiiiiink gpl2 has the dynamic linking exception? (maybe that's just lgpl2), which means if your bootloader is gpl2, and your app isn't, that's probably okay.
<re_irc> <@dirbaio:matrix.org> yeah the mix is somewhat weird, it means the whole can only be used under the GPL, unless you rewrite the GPL parts
<re_irc> <@jamesmunns:matrix.org> but the bootloader itself would definitely by gpl2
<re_irc> <@dirbaio:matrix.org> dynamic linking exception is only LGPL yup
<re_irc> <@dirbaio:matrix.org> Does a GPL bootloader make the application GPL too?
<re_irc> <@jamesmunns:matrix.org> if you ship them together as one binary.
<re_irc> <@jamesmunns:matrix.org> (iirc)
<re_irc> <@jamesmunns:matrix.org> it comes down to "distribution"
<re_irc> <@jamesmunns:matrix.org> but honestly, not a lawyer here
<re_irc> <@9names:matrix.org> MIT is Gpl compatible, so others can use the code as Gpl if they want as long as they also comply with MIT, which just means they provide the licence text and attribution
<re_irc> <@jamesmunns:matrix.org> but I definitely know if you statically compile a gpl2 component into a binary (like a bootloader), then the whole binary is definitely gpl2.
<re_irc> <@jamesmunns:matrix.org> and if that's a non-optional component of rustboot, rustboot should probably be gpl2. Though as I said, you could mark that by just making the crate component gpl2, and people should know if they have ANY transitive deps with gpl2 code, their binary should be gpl2
<re_irc> <@jamesmunns:matrix.org> (you might get some grumpy people who only look at the top level deps and see MIT tho, but that's kind of on them, IMO)
<re_irc> <@jamesmunns:matrix.org> If it's on a feature flag though, for example, and you note in the readme/features section that "activating the update feature includes gpl2 code", then that's pretty much the best you can do.
<re_irc> <@dirbaio:matrix.org> btw looking at GPL code and then implementing the same thing from scratch on your own doesn't make your code GPL
<re_irc> <@jamesmunns:matrix.org> Now we are into opinions that are out of my pay grade :D
<re_irc> <@nihal.pasham:matrix.org> dirbaio:matrix.org: hmm, that's what I did
<re_irc> <@dirbaio:matrix.org> so if it's indeed written from scratch, "inspired by" some other code then you can just say it's MIT
<re_irc> <@nihal.pasham:matrix.org> but I always assumed that ports were considered derived works and the same licenses apply. If I understand you correctly, that's not true
<re_irc> <@jamesmunns:matrix.org> 1:1 port into a new lang would be considered derived works, IIRC.
<re_irc> <@dirbaio:matrix.org> hmm
<re_irc> <@dirbaio:matrix.org> if it's c2rust-ed or something similar, sure
<re_irc> <@jamesmunns:matrix.org> (dropping out, I'm just full of guesses now)
<re_irc> <@dirbaio:matrix.org> if it's new code from scratch implementing the same "algorithm" then no
<re_irc> <@dirbaio:matrix.org> an "algorithm" or "idea" can't be copyrighted, it can only be patented
<re_irc> <@dirbaio:matrix.org> if it's "ported" by having both programs open side by side and "translating" stuff manually then uhhhhh... grey area maybe??
<re_irc> <@nihal.pasham:matrix.org> it was the former, the `update logic` is functionally the same but its design is actually different (i.e. includes many of rust's ideas compile-time state-transition checks, sealed states etc. )
<re_irc> <@9names:matrix.org> thats pretty safe then
<re_irc> <@dirbaio:matrix.org> yeah
<re_irc> <@9names:matrix.org> honestly, there's very little likelyhood of enforcement action here anyway, but you do want to keep the lawyers away where possible
<re_irc> <@nihal.pasham:matrix.org> ok, that great news. yeah, I'd like to err on the side of caution. I'll have a chat internally and switch to the MIT license as that's what we were aiming for in first place.
<re_irc> <@nihal.pasham:matrix.org> dirbaio:matrix.org: - is there any language that I should include as a note in the repo to highlight this point - you know just in-case.
<re_irc> <@dirbaio:matrix.org> easy to confirm with a quick google of "algorithms copyright"
<re_irc> <@dirbaio:matrix.org> for example https://www.copyright.gov/circs/circ31.pdf
<re_irc> <@dirbaio:matrix.org> > Section 102 of the Copyright Act (title 17 of the U.S. Code) clearly expresses this principle: β€œIn no case does copyright protection for an original work ofauthorship extend to any idea, procedure, process, system, method of operation, concept, principle, or discovery, regardless of the form in which it is described, explained, illustrated, or embodied in such work.”
<re_irc> <@dirbaio:matrix.org> ie copyright (thus the GPL) applies to a particular piece of code, not to the algorithm/idea behind it
<re_irc> <@dirbaio:matrix.org> and anyway the "idea" of "let's have 2 flash partitions with some header to describe what's in each" is soooo widespread that you could've as well learned it from somewhere else
<re_irc> <@dirbaio:matrix.org> :D
<re_irc> <@9names:matrix.org> there's certainly enough prior art that you could defeat a patent, but that's not the same as copyright law
<re_irc> <@nihal.pasham:matrix.org> well, I learnt something today. thanks! got to go be a lawyer for sometime πŸ˜‡
<re_irc> <@dirbaio:matrix.org> IANAL though :D
<re_irc> <@9names:matrix.org> i yeah i am definitely not a lawyer either, you should definitely talk to one if you need legal advice
<re_irc> <@nihal.pasham:matrix.org> was just kidding. yep, will do but thank you for the info.
<re_irc> <@mathias_koch:matrix.org> mathias_koch:matrix.org: Could anyone confirm, that this would indeed be a viable solution?
<re_irc> <@mathias_koch:matrix.org> My naive idea would be something along the lines of
<re_irc> <@mathias_koch:matrix.org> ```rust
<re_irc> <@mathias_koch:matrix.org> #[exception]
<re_irc> <@dirbaio:matrix.org> that looks quite scary, the compiler might put code before the `rewind_stackpointer()` call
<re_irc> <@dirbaio:matrix.org> like the function preamble, or maybe reordering stuff
<re_irc> <@dirbaio:matrix.org> it's probably UB
<re_irc> <@dirbaio:matrix.org> i'd do it with a naked fn + inline asm, it's nightly-only though
<re_irc> <@dirbaio:matrix.org> have the asm rewind SP, then call a rust fn that does the rest
<re_irc> <@dirbaio:matrix.org> or in stable you can put it in a .s file then link it in with the `cc` crate, no longer pure rust though
<re_irc> <@mathias_koch:matrix.org> That sounds like one way. And what would my asm be then? :p
<re_irc> <@dirbaio:matrix.org> ```rust
<re_irc> <@dirbaio:matrix.org> #[naked]
<re_irc> <@dirbaio:matrix.org> #[no_mangle]
<re_irc> <@dirbaio:matrix.org> #[cfg_attr(target_os = "none", link_section = ".HardFault.user")]
<re_irc> <@dirbaio:matrix.org> that'll set SP to 0x12345678
<re_irc> <@dirbaio:matrix.org> based on a similar thing I have on my firmware that does work, but the SP thing is untested
<re_irc> <@dirbaio:matrix.org> maybe you can get it to use the `_stack_start` from the linker script with something like `ldr sp, =_stack_start` or something, dunno the exact syntax
<re_irc> <@mathias_koch:matrix.org> why the `#[cfg_attr(target_os = "none", link_section = ".HardFault.user")]`?
<re_irc> <@dirbaio:matrix.org> that's what the CMRT macros do https://github.com/rust-embedded/cortex-m-rt/blob/master/macros/src/lib.rs#L284
<re_irc> <@dirbaio:matrix.org> dunno, maybe it's so that it builds fine for non-embedded
<re_irc> <@dirbaio:matrix.org> if you don't care about that then maybe just `#[link_section = ".HardFault.user"]` will work
<re_irc> <@mathias_koch:matrix.org> Ahh, okay.. cool
fabic has joined #rust-embedded
<re_irc> <@mathias_koch:matrix.org> dirbaio:matrix.org: Is there any way to bring along the `frame: &::cortex_m_rt::ExceptionFrame` from the hardfault to `RealHardFault'?
<re_irc> <@dirbaio:matrix.org> Yes, just copy what the macro does
<re_irc> <@dirbaio:matrix.org> I think it's a ptr to the top of the stack or something
<re_irc> <@dirbaio:matrix.org> I don't know what happens to the frame if it's a stack overflow though
<re_irc> <@dirbaio:matrix.org> The HW will fail to push it
GenTooMan has quit [Ping timeout: 250 seconds]
GenTooMan has joined #rust-embedded
<re_irc> <@mrbraindump:matrix.org> I have again a question about a device crate: I try to use interrupts from the device crate ( https://docs.rs/crate/mkl25z4/0.0.3 ). I use the syntax mentioned in the documentation (https://docs.rs/mkl25z4/0.0.3/mkl25z4/attr.interrupt.html ) but i get the following error: ```
<re_irc> <@mrbraindump:matrix.org> | ^^^^^^^^^---------
<re_irc> <@mrbraindump:matrix.org> 11 | use mkl25z4::interrupt;
<re_irc> <@mrbraindump:matrix.org> | | |
<re_irc> <@mrbraindump:matrix.org> If i import the Interrupt module it still does not wor
<re_irc> <@mrbraindump:matrix.org> Is there anything out of date?
<re_irc> <@come_744:converser.eu> > Re-exports
<re_irc> <@come_744:converser.eu> > `pub use self::Interrupt as interrupt;`
<re_irc> <@come_744:converser.eu> https://docs.rs/mkl25z4/0.0.3/mkl25z4/index.html
<re_irc> <@come_744:converser.eu> Seems strange…
<re_irc> <@come_744:converser.eu> Can the enumeration replace the macro in a way?
<re_irc> <@come_744:converser.eu> It seems the `interrupt` you want is equivalent to `cortex_m_rt::interrupt`
<re_irc> <@mrbraindump:matrix.org> come_744:converser.eu: yes but in the doc it says "NOTE: This attribute is exposed by cortex-m-rt only when the device feature is enabled. However, that export is not meant to be used directly -- using it will result in a compilation error. You should instead use the device crate (usually generated using svd2rust) re-export of that attribute. You need to use the re-export to have the compiler check that...
<re_irc> ... the interrupt exists on the target device."
<re_irc> <@come_744:converser.eu> Have you enabled the feature `rt` in your `Cargo.toml` for `mkl25z4`?
starblue3 has quit [Ping timeout: 250 seconds]
<re_irc> <@mrbraindump:matrix.org> come_744:converser.eu: you mean with [dependencies.mkl25z4]
<re_irc> <@come_744:converser.eu> ```toml
<re_irc> <@come_744:converser.eu> [dependencies]
<re_irc> <@come_744:converser.eu> mkl25z4 = { version = "...", features = ["rs"] }
<re_irc> <@come_744:converser.eu> Maybe?
<re_irc> <@mrbraindump:matrix.org> ah i see i will try that thank you
<re_irc> <@come_744:converser.eu> No problem, if it does not work I apologize I am still a begineer ^^
<re_irc> <@mrbraindump:matrix.org> ah sadly it does not, but I will try to enable it somehow :) that might be a good hit, thank you
GenTooMan has quit [Ping timeout: 240 seconds]
<re_irc> <@come_744:converser.eu> 😩 Sorry, tell me when you manage to make it work, I want to know the solution! πŸ˜„
GenTooMan has joined #rust-embedded
<re_irc> <@jorgeig:matrix.org> how are you using it? do you have some code?
<re_irc> <@lulf_:matrix.org> jorgeig: Hey, I'm looking into using rust-lorawan with stm32wl55 (though eventually in the context of using embassy as the PAC/HAL). newam mentioned you might already be working on something similar. Just wanted to check if you had started something already or if you're planning to.
<re_irc> <@jorgeig:matrix.org> I'm planning to, either at the end of this week or next week
<re_irc> <@jorgeig:matrix.org> will try with this: https://crates.io/crates/lorawan
<re_irc> <@jorgeig:matrix.org> it looks like it has the basics down, which is already a lot
<re_irc> <@lulf_:matrix.org> Cool... I've been integrating that with sx127x earlier: https://github.com/drogue-iot/drogue-device/blob/main/device/src/drivers/lora/sx127x/sx127x_radio.rs - its working nicely on the stm32l0 lora-discovery. I've been wanting to bring it to wl55 as well
<re_irc> <@lulf_:matrix.org> And the wl55 has more ram, so it will be even easier πŸ˜…
<re_irc> <@lulf_:matrix.org> jorgeig: Anyway, let me know if you'd like to share the burden :)
<re_irc> <@jorgeig:matrix.org> sure! as soon as I start working on it I'll let you know
fabic has quit [Ping timeout: 250 seconds]
<re_irc> <@mrbraindump:matrix.org> jorgeig:matrix.org: yes, here it is: https://pastebin.com/TEGR3bwJ
<re_irc> <@mrbraindump:matrix.org> Could it be that there is no dependecy to the rt feature in this crate? The crate is a year old and could be deprecated in cause of some cahnges
<re_irc> <@newam:matrix.org> mrbraindump:matrix.org: do you have a full git repo? makes it a little easier to try things out
<re_irc> <@mrbraindump:matrix.org> newam:matrix.org: give me a second.
starblue has joined #rust-embedded
<re_irc> <@mrbraindump:matrix.org> newam:matrix.org: https://github.com/Mrbraindump/rust-blink here it is.
<re_irc> <@newam:matrix.org> 404? is it private
<re_irc> <@mrbraindump:matrix.org> newam:matrix.org: ah wait
<re_irc> <@mrbraindump:matrix.org> now it should work
<re_irc> <@newam:matrix.org> Got it to compile with `cargo build --target thumbv7em-none-eabihf`
<re_irc> <@newam:matrix.org> ```console
<re_irc> <@newam:matrix.org> $ cargo --version
<re_irc> <@newam:matrix.org> cargo 1.54.0 (5ae8d74b3 2021-06-22)
<re_irc> <@newam:matrix.org> rustfmt went a little crazy on the file; but all the real (non whitespace) changes occured at the bottom
<re_irc> <@newam:matrix.org> ```rs
<re_irc> <@newam:matrix.org> use mkl25z4::interrupt;
<re_irc> <@newam:matrix.org> #[interrupt]
<re_irc> <@mrbraindump:matrix.org> newam:matrix.org: the processor i want to work it on is a m0+, does that still work with that target?
<re_irc> <@newam:matrix.org> Compiles with `cargo build --target thumbv6m-none-eabi` as well, I just made a (bad) assumption about the target πŸ˜‡
<re_irc> <@newam:matrix.org> Just note it does not compile if you just do `cargo build` since it tries to link symbols that `x86_64- ...` doesn't like.
<re_irc> <@newam:matrix.org> You can change the default build target in `.cargo/config.toml` if you would like.
<re_irc> <@mrbraindump:matrix.org> ah i see, thank you very much!
<re_irc> <@newam:matrix.org> no problem, glad I could help! The compiler messages for that problem are difficult to sort out.
fabic has joined #rust-embedded
<re_irc> <@mrbraindump:matrix.org> absolute noob question coming now: i can merge that now by pull request?
<re_irc> <@newam:matrix.org> It is possible without a pull-request, but it is a bit annoying when working with two separate.
<re_irc> <@newam:matrix.org> I'll open a pull request so you can do that.
<re_irc> <@newam:matrix.org> There you go, merge it in the UI there then you should be able to do a `git pull` and see the changes in your local copy.
<re_irc> <@mrbraindump:matrix.org> newam:matrix.org: nice that worked :)
<re_irc> <@newam:matrix.org> For reference, the way to do that without a pull request is `git pull https://github.com/newAM/rust-blink.git` which is roughly equivalent to a `git merge <branch>` but using a different repository instead of a different branch.
fabic has quit [Ping timeout: 244 seconds]
<re_irc> <@mrbraindump:matrix.org> ah i see
SomeWeirdAnon has joined #rust-embedded
dcz has quit [Ping timeout: 250 seconds]
<re_irc> <@barafael:matrix.org> I am getting linker errors with this cargo workspace... I feel like I have seen that before, but I can't solve it myself. Anyone could take a look?
<re_irc> <@barafael:matrix.org> https://github.com/barafael/lego-rover-brain
<re_irc> <@barafael:matrix.org> the last error line I have is "cannot find linker script memory.x"
<re_irc> <@newam:matrix.org> I think for a workspace the `.cargo/config.toml` must go in the root (I am not sure about that - I may be wrong).
<re_irc> <@newam:matrix.org> if you need separate `memory.x`'s I think you have to use `build.rs` scripts.
<re_irc> <@newam:matrix.org> Though it looks like they are different targets, so you may be able to get away with `.cargo/config.toml` with condition `memory.x's` for each target
<re_irc> <@barafael:matrix.org> same targets, just one crate is a lib
<re_irc> <@newam:matrix.org> gotcha, yeah, just moving `.cargo/config.toml` to the root should make it work then (I hope)
<re_irc> <@barafael:matrix.org> nope, don't think so
<re_irc> <@newam:matrix.org> oh, and the `memory.x` would have to be in the root too then
<re_irc> <@barafael:matrix.org> ah ok, perhaps I should move the lib project out of the workspace? I am starting to think this doesn't need to be a workspace anyway
<re_irc> <@barafael:matrix.org> moving the memory.x to top made it compile - nice, thanks!
<re_irc> <@newam:matrix.org> Generally I would say keep it in a workspace, it allows you for flexibility when it comes to testing.
<re_irc> <@newam:matrix.org> workspaces are handy, they're just a big difficult to work with for embedded.
<re_irc> <@barafael:matrix.org> argh, one project uses defmt + rtt + rtic, but that needs a different linker file. Don't know...
<re_irc> <@newam:matrix.org> You can include `defmt` and use the features to disable the logging so that linking `defmt.x` works for all targets.
<re_irc> <@barafael:matrix.org> hmm, nice
<re_irc> <@barafael:matrix.org> thanks for your help!
GenTooMan has quit [Ping timeout: 252 seconds]
<re_irc> <@newam:matrix.org> no problem!
GenTooMan has joined #rust-embedded
GenTooMan has quit [Ping timeout: 240 seconds]
GenTooMan has joined #rust-embedded
GenTooMan has quit [Ping timeout: 250 seconds]
GenTooMan has joined #rust-embedded