An exploration of using Go to build a hardware MIDI player, complete with floppy drive, on a minimal Linux distribution, gokrazy. Without our standard system utilities, in this talk we'll explore Go's syscall interface, as well as Linux's other interfaces, such as netlink and kobject. There will also be sweet, sweet chiptunes.
In this talk, I'll be talking about the hardware MIDI project powered by Go I built in 2018, inspired by the mid-90s Roland MT-80S.
This MIDI player was built on a Raspberry Pi using a USB floppy drive. It's using the minimalist and Go-focused Linux distribution gokrazy. As gokrazy doesn't provide the usual system utilities, your project is expected to handle everything, this is a good project to explore the system interfaces. The three main interfaces I'll be exploring are:
- syscall: The unix syscall interface, golang.org/x/sys/unix. These are calls into the kernel, and while large, the syscall interface is extremely powerful for low level system administrative tasks.
- netlink: A family of RPC interfaces with the Linux kernel. The kernel implements this interface where function calls and directly passing structures in memory would be more difficult.
- kobject: A stream interface, related to netlink, where the kernel can inform userspace (that is, us!) about objects changing in the kernel, such as hardware devices being added or removed.
By pulling these interfaces together with Go, we can build a MIDI player that starts playing when a floppy disk is inserted. There will be chiptunes.