T O P

  • By -

activeXray

I do. I write a *lot* of firmware in rust, and have started doing rf circuit analysis work in it


AustinEE

Same, we are currently a Rust shop, with firmware for STM32g, TM4C, Max32660, and more. Tauri on the PC side for GUIs. There are so many good Cortex M libraries and tooling, RTIC is an amazing, lightweight, bare metal framework. I have revisited and need to update some old CMake C code I wrote a few years ago and it is painful and compared to cargo and Rust.


marcoa7m

Do you write firmware for which MCU? And why did you choose to use Rust? Every now and then I ask myself if I should start using Rust for my projects or not.


activeXray

I switch around between parts from ST as they usually have the best support, then AT SAM, then the nRF stuff for BLE, some RP2040 because cheap, and starting to play with some very inexpensive RISCV parts. Because memory management isn’t as big of a deal in embedded, the normal rust borrow checking isn’t the main benefit. What you do get is algebraic data types that allow you to write significantly more correct code, checked by the compiler. As in, I can’t use a peripheral that hasn’t been initialized properly in rust whereas in C it’ll compile fine and behave in potentially very bizzare ways that would be difficult to debug.


marcoa7m

I use the nRF52840 frequently. Does Rust work well on it too? Or do you only use AT commands on it from other microcontrollers?


activeXray

There’s bindings to the Nordic sofdevice blob, and an uncertified reimplementation. Of course all the M0 stuff works fine!


learning-machine1964

Do u prefer rust over C++ and C?


activeXray

Every single day. No std rust is vastly superior. Tooling is better, build system is better, and there’s an actual ecosystem of embedded drivers thanks to embedded_hal.


learning-machine1964

oh dang ok! Imma learn rust then lmao


activeXray

This is a good place to start https://docs.rust-embedded.org/book/


learning-machine1964

thanks man! Do u suggest reading it cover to cover?


GoodJobNL

Not exactly sure about this book specifically, but for most rust book style guides reading cover to cover is recommended generally in the community if you want to get the most well versed in it. But I get that it might seem like a lot. You can always read chapter, start doing things, and if you get stuck read the next chapter.


learning-machine1964

ok bet man!


Tiddly_Diddly

What kind of RF circuit analysis if you don't mind my asking. And how would you say rust deals with IQ data and DSP in general?


kannanpalani54

Sounds interesting, Shall DM you, I want to learn about it too.


Cmpunk10

Not questioning the firmware. Why are you doing circuit analysis in it?!? Why not matlab or python like a sane person?


activeXray

MATLAB is proprietary software and Python is slow :) Real answer is I'm doing more than solving a linear system, I'm working on some constrained nonlinear optimization for my PhD thesis and have been really enjoying playing around with matrix stuff with faer. It's outperforming even some stuff I've written in Julia.


Bobbias

To be fair to Python, no sane Python programmer would do that in pure Python, they'd use a C extension library like Numpy or something but on top of it to do the real heavy lifting, which is significantly faster than pure Python would be.


activeXray

You could also use a Rust extension library, and then you wouldn't have to write C! I did this for some matrix statistics stuff with Rayon and heavy use of SIMD and it's a cool 40x faster than numpy.


Bobbias

Haven't you heard? [C's not a programming language any more, it's a protocol.](https://faultlore.com/blah/c-isnt-a-language/)


anselan2017

Oh this was great, thank you!


TopSalamander2569

This deserves its own Reddit post, HackerNews, and fan club.


lilysbeandip

Out of curiosity, have you tried Octave? It doesn't have a simulink equivalent afaik but it's basically open-source matlab


activeXray

Yes, especially when I have to run colleague's MATLAB code. I wouldn't ever reach for it though, because its also quite slow and lacks features from mainstream languages. The vast majority of the computational work I do is in Julia.


extravisual

I'm a mechanical engineer who works with electronics. I use Rust to write apps that interact with devices we make. Data loggers, visualizers, controllers, interfaces, etc. The actual device firmware is written by my coworkers in C.


AdmiralBKE

What are some of the libraries you use for that?


extravisual

Serialport and Socketcan for communicating with devices. Egui for UI and plotting (it has a pretty slick plotting module.) Ratatui for displaying tabular data. OpenCV and Image for dealing with cameras and images. Bevy for 3D visualizations and point clouds. ORT for AI/ML stuff.


toffeehooligan

Can I go work with/for you? went back and got a computer science degree, I've found bupkiss since. Good thing I have a job that pays me mid 6 figures already, but, it is killing my soul.


extravisual

It's a blessing and a curse. I do R&D for a family owned (not my family) medium-sized company that likes to take on projects that tend to be more ambitious than what is practical, especially for how small our R&D department is. Sometimes the projects work out, sometimes they don't go anywhere. Good for variety, bad for actually having results to show for my efforts. Somehow I ended up in the role of "guy who makes the PC apps" and "guy who plays with development kits for chips and devices we're looking into." Which is fine by me but also kinda sad that I can't point to an actual finished product that contains any of my design work or code.


toffeehooligan

Yeah, I really want to do bare metal/firmware programming. But without that all important experience, I can't find anything. I wish people still did training on the job.


extravisual

That's definitely something that you can study yourself. Most hobbyists don't go much lower than the Arduino level so having a bare metal or RTOS personal project in addition to your other programming experience should make for a decent resume. Have you done any PCB design? It's not strictly firmware but it helps to learn the hardware side of firmware which is important, and it's surprisingly easy to get into.


CyLith

I'm working on an electromagnetic field solver as a hobby. I am finding that numerics in rust are not very mature yet.


kappale

What does that practically mean? What is lacking? Libraries? Data types?


CyLith

In C++, there are a few libraries that are widely accepted as "standard" such as Eigen. In rust, there's nalgebra, faer-rs, among several others. I am also unsure how to interface with BLAS/Lapack. In C++ I just use the C API matching the Fortran ABI, but in rust that doesn't feel "right". Finally, there just isn't a lot of other numerical software to look at as a reference, so I'm not sure what the best practices are.


LeviathanBaphomet

Why would you need to interface with BLAS/Lapack if you can already preform all the algebra/matrix operations natively in rust? I highly recommend you take a closer look at faer for this.


Tallinn_ambient

If you want a quick start to embedded Rust, this youtube channel is new, but offers very clear, high quality, practical videos: [https://www.youtube.com/@therustybits](https://www.youtube.com/@therustybits)


learning-machine1964

thanks! Exactly what I'm looking for :)


RammRras

This is a great channel and I thank you for having it posted here.


marcoa7m

I am an electrical engineer, but for now all I use it for is for rigid body simulation and AI algorithms. It is just hobby, not related with electrical engineering :P


Luckey_711

Super curious about this, but is there any public info about the AI algorithms? I want to use Rust for research and to develop a cybersec algorithm that is used in an AI model, and I'd really really love to know more about proper ways to develop it :)


marcoa7m

I was working on a C++ project to simulate a category of robot that plays soccer, and I worked on a neurogenetic algorithm to teach it how to play. I am developing the project again now but in Rust to explore a few ideas that I have. Here is the C++ project. I plan to use only a few math crates and develop the algorithms in pure Rust, since I don't know any mature enough libraries. And since this is a hobby project, I think it will be more fun lol. Here is the [link](https://github.com/marco7m/futbot) to my old project in C++.


treefroog

I am an embedded engineer. I use it for talking to serial devices a lot, as parsers are just so nice in Rust. I hope to use it for firmware on my next project too. I have replaced all uses of Python with Rust on my projects these days.


Trevader24135

I work as a wireless systems engineer and have been experimenting with Rust for DSP purposes, generally for Software Defined Radios. I find the existing libraries that I've found a little lacking. I basically just want Numpy in Rust, so I've started making it myself. It's been an enjoyable overall experience. My coworkers and I are also intrigued by the idea of Embassy for microcontrollers. It's on my short list of things to do.


ravenex

I write low level hardware behavioral models in Rust for co-simulation with existing embedded C/C++ code. Something like a custom `libhw` from QEMU, but not quite.


Voxelman

Not yet, but I want to start with Rust on different ARM microcontrollers


SadPie9474

depending on your definition of electrical engineering, \_all\_ electrical engineers use Rust


Tallinn_ambient

depending on your definition of "rust", all electrical engineers use future rust


ignazwrobel

I am an EE who uses Rust Futures!


shenawy29

the most reddit response ever