rtstragedy2 [she/her, pup/pup's]

i’m back

  • 0 Posts
  • 115 Comments
Joined 6 months ago
cake
Cake day: August 6th, 2025

help-circle

  • I think I’ve finally turned a corner with embedded Rust, I tricked a Pi Pico 2 into playing NSF files!

    I’m scared of how many thousands of lines of code the NES emulator I had to write was, and for a while it felt like it was never going to be fast enough to run on a 150MHz processor, but some optimization that was within run-to-run variance on the benchmarks on my laptop must have really favoured the pico 2, and now there’s no dropouts!

    Lessons learned:

    • as far as I can tell, if you overflow stack on these microcontrollers you won’t get a fancy stack overflow error, it will just hard fault (although I suspect sometimes it won’t even fault and will just give you fun UB). Lost a day to that.
    • goddamn lifetimes and statics and interior mutability etc. caused me so much grief. There’s a crate called embedded_alloc which gives you access to Rc, Arc, Vec, etc by actually letting you define a heap. I highly recommend this although remember that when a Vec needs to grow it needs 3x it’s previous size in memory, because it creates a new Vec with 2x previous capacity, copies from the old Vec, then drops it.
    • I didn’t end up using both cores (yet) but Embassy doesn’t appear to support the doorbell IRQs or the inter-core FIFO queues, so if you want those you need to use rp-hal.
    • The embedded-sdmmc library certainly takes some getting used to. You need to implement long file name support yourself, no file sorting (do it yourself but use a master branch), use RawFile instead of File because it seems to be so ready to drop my files when I look the other way, etc.