<rmsyn[m]>
e.g. 8-bit microcontrollers need 8 registers for the 64-bit interface, and only one for the 8-bit interface. So, they could override the default 8-bit interface to avoid temporarily converting to-from a 64-bit value
<JamesMunns[m]1>
This would mean that ever driver crate (e.g. a serial port that needs some delay) would need to have implementations for all of Timer8..Timer64
<rmsyn[m]>
right, which is why a single trait with all the different bit width interfaces might be better
<JamesMunns[m]1>
I'm not sure if I could imagine how you would make that all work, and allow that level of flexibility, but some code would make it much easier for me to understand!
<JamesMunns[m]1>
like, it can be fake code you can run in the playground, using std Instant/Duration under the hood for demonstration, but just defining all the pieces and wiring it up end-to-end is extremely useful for discussion, and to make sure we're all discussing the same concrete things!
<rmsyn[m]>
that makes sense, just wanted to float the idea before digging into actual implementation. I'll look back at old `embedded-hal` versions for whats is generally expected from the trait
<JamesMunns[m]1>
It's a tricky topic, that's why I suggest sketching it out first. It's very easy to suggest things that work well from one perspective, but end up being hard to use practically!
<JamesMunns[m]1>
(or make one aspect very easy, and other aspects much harder/impossible)
<rmsyn[m]>
right, I generally have the same experience writing library code. Unit tests are great for exercising the API (basically what you're suggesting). will see what comes together, and post back with results.
pronvis has joined #rust-embedded
<JamesMunns[m]1>
https://github.com/rust-embedded/embedded-hal/issues/359 is the best overall discussion I'm aware of right now, it's still sort of an open question of what API is possible! It could be something like embassy-time, which is generally a lot like std's Instant and Duration (measured since time of boot roughly), or something else. It would be good to note if you're proposing something other than that.
<JamesMunns[m]1>
rmsyn[m]: oh, and specifically on this, I even think having the body of the functions stubbed out with `todo!()` is totally fine for demonstrating that the API compiles (e.g. a compile-test vs a unit-test), as long as you mention roughly how it would be done in practice. This can help make iteration speed easier for you!
pronvis has quit [Ping timeout: 268 seconds]
<rmsyn[m]>
sure, I think this might take a bit of review over the differences among the current available options/approaches. looks like there are: `embedded-time`, `fugit`, (others?)
<rmsyn[m]>
`embassy-time` ...
<JamesMunns[m]1>
groundhog
<JamesMunns[m]1>
(similar API, but explicitly a rolling timer, vs embassy which is assumed to be "infinite range")
<rmsyn[m]>
embassy also uses a `u64` for its `Duration` type, no generics
<rmsyn[m]>
how does it achieve "infinite range" with a `u64`?
<JamesMunns[m]1>
Even at microsecond precision, that's room for like 500 years
<rmsyn[m]>
ok, so practically infinite, not actually (as in, no practical use-case cares)
<JamesMunns[m]1>
oh sorry, at NANOSECOND precision it's 500 years, at microsecond precision it's 500k years
<JamesMunns[m]1>
for reference, at 1mhz, a u32 rolls over after 71mins. This is probably good enough for an API that uses that for like single delays or so (if it is documented), but probably not acceptable for an API that tracks total time since boot!
<rmsyn[m]>
ok, was also thinking about edge-cases like users measuring events in pico- and femto-seconds. but those use-cases probably are tracking events for very long
<rmsyn[m]>
it also is inefficient for smaller microcontrollers
<JamesMunns[m]1>
IMO we will likely need to support at least down to microsecond precision (nanos would be nice), and maybe an hour for "short lived" timers/ranges, and probably 1-10y for "time since boot" ranges
<rmsyn[m]>
one of the biggest things that keeps popping up is to also avoid epoch rollover/overflow events
<JamesMunns[m]1>
yep. I used groundhog effectively, but I dunno if I would propose it as an e-hal option
<JamesMunns[m]1>
it was pretty much "promise to hold it right", e.g. if you had a 1mhz timer, just know that you should never try to measure a time delta of >71m
<JamesMunns[m]1>
but for example, embassy-time explicitly supports much smaller timers, like 16-bit ones, but it requires an interrupt every 1/2 period to accurately track rollovers + timer deltas.
<JamesMunns[m]1>
so at 1mhz + 32 bit hardware timer, it only fires that interrupt every ~35m, but at 1mhz + 16-bit timer, it has to fire every 35ms.
<JamesMunns[m]1>
er, 32.5ms, but you get the idea
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
AtleoS has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 264 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 252 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
pronvis has joined #rust-embedded
RobertJrdens[m] has joined #rust-embedded
<RobertJrdens[m]>
<cr1901> "RobertJrdens[m]: https://docs.rs..." <- Only for the special case of an HBF-FIR.
pronvis has quit [Ping timeout: 264 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
wassasin[m] has quit [Quit: Idle timeout reached: 172800s]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 260 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 246 seconds]
MathiasKoch[m] has quit [Quit: Idle timeout reached: 172800s]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 252 seconds]
pronvis has joined #rust-embedded
pronvis has quit [Ping timeout: 268 seconds]
therealprof[m] has joined #rust-embedded
<therealprof[m]>
I'm back from vacation. I noticed a few pings but I only briefly skimmed the backlog. Let me know if there's still something that still requires my attention.
pronvis has joined #rust-embedded
<David[m]12>
<firefrommoonligh> "Use macros if the syntax becomes..." <- James Munns: sure, let me know if you have any ideas
pronvis has quit [Ping timeout: 240 seconds]
<David[m]12>
David[m]12: I whipped up something quick by using `UnsafeCell<Option<T>>`, will send it over to see what you think a lil later
pronvis has joined #rust-embedded
vancz has quit []
vancz has joined #rust-embedded
a2800276 has quit [Remote host closed the connection]
zachariasfrings[ has quit [Quit: Idle timeout reached: 172800s]
bpye has quit [Quit: Ping timeout (120 seconds)]
bpye has joined #rust-embedded
Amanieu has quit [Ping timeout: 240 seconds]
chek_ has joined #rust-embedded
pkoevesdi[m] has joined #rust-embedded
<pkoevesdi[m]>
Hey, maybe someone here can help me with this: I have a working elf file ("external loader" from the STM world) and want to make an "flash algorithm" (rust world) out of it to flash rust programs into external memory with probe-rs / cargo. I get the error 'Failed to find 'FlashDevice' symbol in ELF file' and there I'm stuck. More details here: https://users.rust-lang.org/t/create-own-flash-algorithm-from-binary/108885/6 ?
danielb[m] has joined #rust-embedded
<danielb[m]>
target-gen can eat the keil FLM loaders but I guess the STLDR ones are just different enough by not including the FlashDevice info
<danielb[m]>
can you share the source of your loader?
<pkoevesdi[m]>
As a matter of fact, Idin't have the source (yet). I'll ask the programmer.
<danielb[m]>
I doubt he'll give it up if he's looking for $80+ donations
<danielb[m]>
I meant the source that you started working on and isn't working properly
<pkoevesdi[m]>
There are some other folders that contain the flm files.
<pkoevesdi[m]>
Yes, I have made some attempts directly in rust. It got stuck when trying to run target-gen test.
<pkoevesdi[m]>
I haven' prepared it (yet) to be pushed publicly.
<danielb[m]>
maybe target-gen test isn't working... you can build your project with cargo build and run target-gen elf on the output
<pkoevesdi[m]>
So, an approach could be to work myself in into Keil? Hmm, totally new construction site for me.
<pkoevesdi[m]>
I'm busy learning rust.
ni has quit [Quit: WeeChat 3.0]
<pkoevesdi[m]>
<danielb[m]> "maybe target-gen test isn't..." <- Thanks for the hint. Now I'm torn: go further that route to take the working external loader and try around with this - can needed symbols be added into the ready elf file, without recompiling everything becuse of the lacking source? Or go on working on the rust-sourced flash algoritm. With that: I got a working rust program that manges (read, write, erase etc.) the flash memory,
<pkoevesdi[m]>
but that attempt failed when trying to compile it into a flash algorithm. It compiled and got flashed (with target-gen test), but gut stuck in run time at a point, where it ran fine as a standalone program. I plan to prepare it to enable people (here) to look at it.
<pkoevesdi[m]>
Or, third route: start working with Keil / .flm...
<danielb[m]>
if there is no cmsis-pack for your device (and you said it's a custom one), there is no keil flm to work with
<danielb[m]>
what remains is to write your own, and there the language doesn't matter. the output needs to be an .elf that has the required symbols that target-gen can read
<pkoevesdi[m]>
danielb[m]: Ok, good to know, that the Keil route then will not be much better.
ni has joined #rust-embedded
<pkoevesdi[m]>
danielb[m]: If writing my own, I'd prefer rust, because the main user program and the boot loader is supposed to be in rust too, and my flash "demo" is already working in rust. Ok, so thanks to Your input, it seems most promising to go (back) to my rust source. Next weekend I'll make it to a readable repo with comprehensible error description, and maybe ask again for help here? Thank You very much!
<danielb[m]>
please ask in #probe-rs:matrix.org it's a bit more on-topic there
<danielb[m]>
but circling back a bit, what did you mean by "where it ran fine as a standalone program"? if you flash a flash algorithm, it will do nothing by itself
<pkoevesdi[m]>
So, all functions from the template work ok, but as soon as I run it with target-gen test, It gets stuck at runtime in the init function when configuring the rcc.
<pkoevesdi[m]>
But, I don't expect You people here to help without the full source. I'd like to make a working repo and then ask again here.
m5zs7k has quit [Ping timeout: 268 seconds]
m5zs7k has joined #rust-embedded
pronvis has quit [Remote host closed the connection]