This paper presents OpenSwarm, a lightweight easy-to-use open-source operating system. To our knowledge, it is the first operating system designed for and deployed on miniature robots. OpenSwarm enables these robotic platforms to execute multiple tasks simultaneously. It provides a hybrid kernel that natively supports both preemptive and cooperative scheduling. This makes OpenSwarm suitable for both computationally intensive and swiftly responsive tasks. OpenSwarm provides hardware abstractions to rapidly and systematically develop and test platform-independent code. The current version has a memory footprint of 12 kB ROM and 1 kB RAM. We demonstrate how it can be used to implement a controller for a canonical swarm robotics task. The performance is analysed and compared to a hardware-near implementation. We believe that OpenSwarm makes robots with severely limited hardware more accessible, and may help such systems to be deployed in real-world applications.