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
cinemaSundays has joined #rust-embedded
NiaLinaLunaStorm has quit [Quit: Idle timeout reached: 172800s]
cinemaSundays has quit [Quit: Connection closed for inactivity]
duderonomy has joined #rust-embedded
vanner has quit [Quit: ZNC 1.9.0 - https://znc.in]
vanner has joined #rust-embedded
vanner has quit [Client Quit]
vanner has joined #rust-embedded
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bitts[m] has joined #rust-embedded
<bitts[m]> How can I call a function defined in an assembly file that is included with global_asm!? I tried declaring it with extern "C" {}, but linker throws undefined symbol?
<dirbaio[m]> That's how you do it yep. Here's one example:
<dirbaio[m]> Maybe .type or .global is required, not sure
<bitts[m]> I have both .type and .global, but what does options(raw) do? I dont have that..
<dirbaio[m]> It's so rust doesn't do anything with {} characters in the asm. Handy if you want to include_str a normal .s file without escaping the {}s. That's not what's causing your error..
<bitts[m]> Adding it did not help.. Hmm..
<dirbaio[m]> Can you post your code?
<dirbaio[m]> Seems OK yeah 🤔🤔
<dirbaio[m]> Try moving .global after the label?
<bitts[m]> Tried, did not help, also adding .size did not help
<dirbaio[m]> Wtf! Can you paste the linker error?
<bitts[m]> It is in a separate crate from where I am calling the arm_get_core_id, could that cause this?
diondokter[m] has joined #rust-embedded
<diondokter[m]> Doesn't the asm macro want each instruction in a separate string?
<diondokter[m]> (Also, if you're on nightly, you could try out the new and improved naked fns)
<dirbaio[m]> Rust skips linking a crate if you never use it. Do you have the global_asm in the same crate as the extern?
<dirbaio[m]> If you do then it should be OK because you're useing that crate for sure. If not then you have to make sure to add a dummy use
<bitts[m]> Yes, the rust code above is all in one file in one crate, then I use arm_get_core_id() from a different crate
<bitts[m]> diondokter: I'm using global_asm! which can read a standard assembly file. asm! takes separate strings yes
<diondokter[m]> Ah ok
<bitts[m]> Tried moving it all to the same crate, no dice.. Weird...
adamgreig[m] has joined #rust-embedded
<adamgreig[m]> fwiw asm can take one string or multiple strings or whatever too
<adamgreig[m]> iirc?
<adamgreig[m]> yea, it's fine, it's just you'd have to put newlines in so it makes for a potentially ugly multi-line string or loads or \r\n
<adamgreig[m]> the macro just offers the option of doing lots of string literals which it will glue together with newlines in-between
<diondokter[m]> adamgreig[m]: Ah that's probably it then
<adamgreig[m]> so like asm!("mov {0}, {1} \r\n add {0}, 5", out(reg) o, in(reg) i); works, and asm!("mov {0}, {1}", "add {0}, 5", out(reg) o, in(reg) i); is the same, or you could put an actual newline and split the literal over multiple lines, but you can't just have mov {0}, {1} add {0}, 5
<bitts[m]> If it was just that one function I would move it over to hand-coded asm!, but unfortunately there are a bunch of them in multiple files that I would prefer to just use as is
<diondokter[m]> Maybe you need to mark it as executable?
<bitts[m]> I already use global_asm! for some boot code, and that works fine, so it is not completely broken.
<diondokter[m]> Something something ax
<diondokter[m]> You function declaration is a lot less than this: https://github.com/rust-embedded/cortex-m/blob/master/cortex-m-rt/src/lib.rs#L520-L526
<diondokter[m]> * Your asm function declaration is a lot less than this: https://github.com/rust-embedded/cortex-m/blob/master/cortex-m-rt/src/lib.rs#L520-L526
<bitts[m]> Not going to object to that, but it is awfully similar to what dirbaio linked to above. But I can try to throw in some of that for sure!
<diondokter[m]> Oh didn't see that from Dario
<adamgreig[m]> it's worth a try, I worry the issue is some sort of linker related nuisance where your symbols just aren't ending up where you want them, but I don't see why not
<bitts[m]> Not sure if being on a mac could have something to do with it?
<adamgreig[m]> wouldn't expect so
<bitts[m]> Huh, for the curious, I had based my project off the raspberry-pi os tutorial (https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials) which is makefile based and calls cargo rustc. After setting up a new project using standard .cargo/config.toml etc, the global_asm! works as expected..
ouilemur has joined #rust-embedded
mameluc[m] has joined #rust-embedded
<dirbaio[m]> traits support async fn natively now
<mameluc[m]> idk if overkill but I wanted to return a Result with a future in it
<mameluc[m]> should probably skip that and just simplify
<mameluc[m]> my thinking was that all values for the timer might not be possible
<dirbaio[m]> honestly i'd just make it infallible
<mameluc[m]> sounds better, thanks
<dirbaio[m]> but if not, returning a uture that returns a result, and returning a result with a future inside should work equally well
<dirbaio[m]> s/uture/future/
<dirbaio[m]> and you can only do the former on stable
<dirbaio[m]> (unless you force impls to hand-implement futures to avoid TAIT)
<mameluc[m]> I was trying to figure out the language when I wrote that, there is a lot of "why did I do it like that" now when I go trough it all :D
<mameluc[m]> Lorawan requires a handful of hardware stuff, some "callbacks" and a bunch of constants so the traits are not so simple
<mameluc[m]> With the timer stuff it is all moot anyway bc I know what kind of ranges the timers should work on, something like 1s - 10s
Mathias[m] has quit [Quit: Idle timeout reached: 172800s]
duderonomy has joined #rust-embedded
halloy5295 has joined #rust-embedded
halloy5295 has left #rust-embedded [#rust-embedded]
vanner has quit [Quit: ZNC 1.9.1 - https://znc.in]
vanner has joined #rust-embedded
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sroemer has quit [Quit: WeeChat 4.4.2]
sroemer has joined #rust-embedded
sroemer has quit [Changing host]
sroemer has joined #rust-embedded
kenny has quit [Quit: WeeChat 4.4.4]
cinemaSundays has joined #rust-embedded
ouilemur has left #rust-embedded [WeeChat 4.5.1]