Following Handmade Hero as an Embedded Systems Project

Hello all.

My ideal job is as an embedded systems programmer.

As a project that builds skills and develops knowledge that I hope will be of use for future careers in this field, I would like to implement Handmade Hero in an embedded environment.

My current thinking is some sort of embedded Linux environment. I'm unsure as to the what features I should use that will be useful to put down on a resume for an embedded systems job e.g. linux framebuffer for graphics, ALSA for audio, kernel threads or pthreads for threading, etc.

As I'm currently inexperienced in this area, I was looking for some suggestions as to the best development board/environment to use and features to implement that will be good to have when looking for a job in the embedded field. I know this may be too much to ask, but a breakdown of the hardware/software used and relevant skills learnt would be great.

Edited by Lachlan on Reason: Initial post
If you're talking about linux kernel, framebuffer & alsa then development with that won't be much different than on regular desktop distro. Some people might say that does not count as "embedded" development. So you might as well use regular desktop Linux distro - Ubuntu, or whatever is your choice, as all the things there will be the same.

If you're talking about bare-metal programming then that's a different story. That would count as embedded development, or at least require same skills. If you don't want to go with x86 hardware, then Raspberry Pi would be a good choice - it has very large community and it is easy to find support for rpi than for some random arm board. They have good documentation and various tools available. And they have wide range of hardware - from multi-core 64-bit armv8 on pi4 down to single core armv6 on pi0. You can easily run regular linux distro there with kernel & all the goodies, or switch to bare-metal and write custom code that boots from their bootloader. And just today they released even smaller and more limited board - Pi Pico which is 133Mhz dual-core Cortex-M0+ MCU (no Linux there, just custom code).
Thanks, I wasn't aware of the various architectures across the different Raspberry Pi boards. I have decided to start with the recent Raspberry Pi 4B.

I have two more closely related questions:
  1. Is there a way to build and flash without having to manually transfer the SD card every time? Ideally, I would like some 'USB' type connection that transfers the image to the board.
  2. In terms of debugging like Casey does in HandmadeHero, can this be achieved from the host machine in a bare metal environment? I have seen mentions of JTAGs or is there some other way that you would recommend?

Edited by Lachlan on
If you're running regular Linux and want to just customize kernel/userspace, then easiest way is to do NFS boot over network. Newer Pi's don't need sdcard at all for this. All you do is connect to network, and provide NFS setup on other machine in same network where you have Pi's root filesystem unpacked, and it'll use files from there. See:
https://www.raspberrypi.org/docum...ware/raspberrypi/bootmodes/net.md
https://www.raspberrypi.org/docum...berrypi/bootmodes/net_tutorial.md

This is very common how embedded devices are developed - as you can easily modify files on your host/development machine and just trigger reboot on device to use them next time.

If you want to write custom OS, then simplest way would be to use serial port. Write small bootloader than you flash to sdcard and use it permanently. And this small bootloader will request actual boot kernel/files sent over serial port. Then you connect serial port with USB to TTL cable to your PC where you run server that provides these files over serial port. For examples see:
https://github.com/dwelch67/raspberrypi/tree/master/bootloader01
https://github.com/mrvn/raspbootin
https://github.com/robey/c3r3s

As for debugging, the simplest thing would be to write code that can do gdbserver compatible protocol. Then you'll be able to use regular gdb to debug remotely from your host PC. Here's an example of such implementation (no idea how good or full-featured it is): https://github.com/dwelch67/raspberrypi/tree/master/armjtag
I don't know much about JTAG, never used it, but here's some information on it: https://github.com/dwelch67/raspberrypi/tree/master/armjtag

Also for debugging you can leverage qemu - as it has support for rpi emulation. Probably not all the hardware, but for basic stuff like bootloader/serial port setup you can easily debug that without real hardware, just with emulation.

Edited by Mārtiņš Možeiko on