← Back to context

Comment by stack_framer

1 day ago

Probably off topic, but what's the best way to get started with embedded development? I've been a web developer for over a decade, but I'd really love to try something much lower level, and I'm currently making my way through the Rust book. I've got a Raspberry Pi on the way, but I assume that's not truly embedded development.

I bought one of these on Amazon last week for $25:

https://www.waveshare.com/esp32-c6-touch-lcd-1.47.htm

I've been really impressed. It's basically a hackable Fitbit with no strap or battery. Full wifi, BLE, 6-axis motion. It's was really easy to get the C demos running. LVGL is awesome. Can't speak to Rust. I get enough of that complexity in my day job.

Other brands that look good for beginners are Elecrow and Makerfabs.

I specifically wanted to get into RISC-V, but they all have boards for other architectures as well.

I would recommend getting a ST nucleo board over raspberry PICO or ESP32. The nucleo boards have integrated SWD programmer which makes flashing easier. You can also use it to debug your code. Try to get one with onboard USB port (like https://www.st.com/en/evaluation-tools/nucleo-f767zi.html) so that you can build USB projects.

  • Of note neither the debugger nor user USB port on that board work with ARM Macs (guess how I found that out). You can connect it to a hub as a workaround but that may lead to data corruption (per the errata).

    Also worth noting that the discrete STLink V3 dongles also use the F7 for USB stuff.

    Also also worth noting that not all of the Embassy examples are set up to work with Nucleo boards. It's an odd choice but it is what it is.

Buy a dev board with an RP2040 in it, an electronics starter kit (resistors, capacitors, LEDs, diodes, breadboard, breadboard cables, etc.) and start writing some code!

If we're talking Rust, rp-hal is great for starting, and of course Embassy is great too, though maybe Embassy is better for later when you start running into the types of problems that it aims to solve.

rp-hal: https://github.com/rp-rs/rp-hal

Raspberry Pi lets you play with GPIO which is a big aspect of embedded (even if it's running Linux instead of FreeRTOS or whatever).

If you want to take things a bit closer to bare metal, check out ESP32 boards. Super cheap from China and you can find them with all sorts of cool form factors with lipo battery chargers, screens, etc.

  • Using a Raspberry Pi (or anything running Linux) is a completely different experience from bare metal. I wouldn't recommend it for learning fundamentals.

    If you want to understand how interacting with peripherals and hardware works, an RP2040 is a good option - it has great documentation and sensible peripherals. Or STM32s have huge numbers of examples in the wild.

    Ultimately the biggest difference - the thing you need to learn the most - is peripheral setup. Things like setting up the clock, setting up an I2C or SPI bus, reading and writing bytes from a UART etc. This stuff happens on every computer all the way up to a Raspberry Pi, but the bigger and more powerful the MCU the more it tends to be abstracted away by libraries and middleware.

    If you want to truly learn this stuff you have to get low down, strip away all the abstractions and get very familiar with the 1000+ page user manual. Doing that on the simplest microcontroller possible is a benefit, because you're not overwhelmed by complex peripherals and too-many-settings.

    I'd also recommend starting with C, rather than trying to mess around with Rust. Rust (and embassy) are great for building apps with very few runtime bugs, but debugging stuff in the Rust async world is a headache, and you've got an abstraction layer sitting between you and the chip.

    It's actually really powerful to realise that a peripheral is just 10 memory addresses, and to make it work you just need to define a C struct and point it to the start address. Suddenly you're talking to the peripheral and can configure it. None of that is obvious with layers of middleware and abstractions.

I don't think a regular Raspberry Pi counts as embedded, although from Embassy's documentation, there is a version of embassy for the Rapberry Pi Microcontroller.

https://docs.embassy.dev/embassy-rp/git/rp2040/index.html https://www.raspberrypi.com/documentation/microcontrollers/

  • I think you’re aware of this already but for everyone else:

    There’s different kinds of embedded. What traditionally was referred to as embedded is microcontrollers (e.g., 32-bit ARM Cortex M devices like the STM32 or an NXP IMX106x chip ). A configuration for a Cortex-M7 chip (that some may consider on the high end of traditional embedded) is a 600MHz clock, 1MB of RAM, and 4MB of flash memory. These run either bare metal or a real time operating system but don’t have an MMU.

    These days the definition is sometimes expanded to include devices that run full fledged OSes like Linux (embedded Linux) on devices like the RPI with much more memory than an MCU.

    To answer the original posters question a bit: get used to C and C++ and not using malloc() / new(), which includes a lot of the standard library.

    • I don’t think that is exactly accurate. But you know, like close enough, describes all my work. Just pointing out that something like an industrial system running win ce on PowerPC or x86 has been within the definition of embedded for a long time. Embedded Java was/is a thing. Both extremely non-central examples, but what’s new is how cheap the hardware is, embedded has always included more sophisticated OS’ and more than micros.

    • I'm still a noob but it seems like there's also a distinction between bare metal embedded and RTOS, which is higher level. I think STMs are more commonly run bare metal but esp32s use a version of FreeRTOS.

      Also libc is bloat :P

  • That’s right, the keyword for embedded development would be “microcontroller”. A normal Pi is an SoC which is more akin to a traditional desktop - embassy would not be the easiest tool to use for that.

I'm a fan of the RP2040 chip. It's a good trade-off between being simple and capable. There are more powerful chips like the STM32's, but frankly there are too many variants and their data-sheets are nightmarish. And there are simpler chips like the Atmel AVRs, but the tooling sucks. ESP chips are also good, but I haven't kept up with them so can't give much advice.

You'll want a dev board, which has the chip plus some supporting components on it. The Raspberry Pi Pico is a good choice because it's so widely used and well documented.

If you care about Rust, you'll also want to get the Debug Probe. Worth the money.

If you don't care about Rust, any Adafruit dev board should run CircuitPython, have good documentation, and likely some projects you can start with. The reason I don't recommend these for Rust is because many of their dev boards do not "break out"/make available the connections for a debug probe.

Edit: Having a project you want to do is good, but just making an LED blink can be magical, too, especially if you haven't done anything with hardware.

TLDR: - get in contact with people programming embedded chips in a local hackerspace - use https://wokwi.com/ to get started

I was in the same situation. I've been programming high-level languages for decades now and wanted to get my hands on embedded. I've got friends in my local hackerspace and while you can teach yourself programming those chips, it's good to know whom to ask when you get stuck. You can find a hackerspace near you here: https://wiki.hackerspaces.org/Hackerspaces

I've been programming C and Rust on Wokwi. I even simulates electronic components and stuff like switch-bounce-effects. It's very easy and can be used free. You can even use a local IDE like VSCode(ium) and. I've used it with one project and it speed up my project a lot. https://wokwi.com/

Hey! This is broad advice, but I recommend thinking of a problem you find would be interesting. Maybe tangential to a hobby or your job, or just something that sounds fun. Then make it happen.