The author set out to create a tiny operating‑system kernel written entirely in Swift that could run on the QEMU emulator without any underlying operating system. Using Embedded Swift — an experimental subset of the language intended for bare‑metal environments — the project targeted the aarch64‑none‑none‑elf triple, which represents a 64‑bit ARM CPU with no OS or C runtime provided. The initial goal was simply to print a message and halt, serving as a learning exercise to understand what is required for a program to start when there is no standard library or kernel services available.
To make the Swift code run on bare metal, the author supplied a custom toolset.json that disables the standard library, enables the Embedded and Volatile experimental features, turns off stack protection, and instructs the Swift compiler to use the LLD linker with ‑nostdlib, ‑static and a hand‑written linker script. The linker script places the executable’s entry point at 0x40080000, defines a stack, and explicitly keeps ELF metadata sections to avoid orphan‑section errors. An assembly file boot.S sets up the stack for core 0, jumps to a Swift function marked with the @c attribute (kernel_main), and then halts. Inside kernel_main the author provides the missing C functions putchar and memmove: putchar writes a byte to the memory‑mapped PL011 UART register at 0x09000000, while memmove copies bytes forward or backward to handle overlapping regions, both written in Swift with @c and @unsafe attributes.
When built with `swift build --triple aarch64-none-none-elf --toolset toolset.json --build-system native` and launched via `qemu-system-aarch64 -machine virt -cpu cortex-a57 -nographic -kernel .build/aarch64-none-none-elf/debug/kernel`, the emulator prints “Hello, Embedded Swift 😊” and then stays in an infinite loop. A later revision added a polling loop that reads the UART flag register to echo typed characters, giving a simple REPL‑like prompt. The kernel remains a learning exercise: it does not clear the .BSS section, uses a deliberately large 128 kB stack, relies on polling instead of interrupts for I/O, and lacks any scheduler or memory management, but it demonstrates that Swift can be used for low‑level firmware when the necessary glue code is supplied.