
XinuPi: Porting a Lightweight Educational Operating System to the Raspberry Pi Eric Biggers Farzeen Harunani Tyler Much Dennis Brylow Department of Mathematics, Statistics, Department of Mathematics, Statistics, and Computer Science and Computer Science Macalester College Marquette University 1600 Grand Avenue 1313 W. Wisconsin Avenue Saint Paul, Minnesota 55105-7045 Milwaukee, WI 53201-1881 [email protected] {farzeen.harunani, tyler.much, dennis.brylow}@mu.edu ABSTRACT It is intended to be used for educational purposes, such as The Raspberry Pi is a credit-card sized computer, designed teaching programming with Python, and it normally runs to support hands-on computer science education activities a Linux-based operating system, such as the Debian-based with minimal hardware cost. The Pi's low price, powerful \Raspbian" or Arch Linux ARM [14]. There are currently ARM-based processor, and rich set of built-in peripherals two major versions of the Raspberry Pi: the Model A and has made it an attractive platform for the gamut of hob- Model B, which cost $25 and $35 respectively. byists, researchers, and educators. However, for those in- In aspects such as cost, convenience, and community, the terested in embedded systems education, the Raspberry Pi Raspberry Pi hardware is well-suited for exploring low-level presents a unique opportunity to build curricula introducing computer science concepts, such as operating systems, net- time-oriented, reactive, and embedded system software us- working, and embedded systems. However, lack of docu- ing a mass-produced embedded platform with broad appeal. mentation has limited software support for this platform Despite the growing popularity of the Pi platform for com- to either the very simple (standalone assembly language) puter science education, the device commonly runs a Linux- or the very complex (full-fledged Linux kernel), with very based software stack that is, in practice, opaque except to little available in the productive middle of the spectrum. experienced developers. In addition, important hardware on Over 1 million Raspberry Pi boards were sold as by Jan- the device remains poorly documented. This paper presents uary 2013[13], but key aspects of the hardware, such as the a port of the time-tested Embedded Xinu operating sys- USB controller (essential for network and keyboard support) tem to the Raspberry Pi, combining a commodity embed- and the mailbox subsystem (essential for programming the ded processor with a lightweight kernel designed to support graphics co-processor), remain effectively undocumented ex- hands-on pedagogy at the lowest levels of the software sys- cept by sparsely commented code within vendor-contributed tem stack. Linux device drivers. In cases where documentation is avail- able, such as Broadcom's BCM2835 ARM Peripherals [5], some of the descriptions contains critical errors and omis- Categories and Subject Descriptors sions that, in our experience, have limited their usefulness. K.3.2 [Computer and Information Science Education]: XinuPi, our port of Embedded Xinu[9] to the Raspberry Computer science education; C.3 [Special-Purpose and Pi, provides a cost-effective, usable, understandable plat- Application-Based Systems]: Real-time and embedded form for undergraduate computer science students to exper- systems iment with hardware/software interactions. XinuPi uses an elegant, well-documented kernel design with support for key Keywords hardware peripherals such as graphics, USB, and network- ing, yet is several orders of magnitude smaller than the most Raspberry Pi, Embedded Xinu, Embedded systems educa- compact Linux-based software stacks that run on this device. tion XinuPi offers a unique point in the curriculum design space, allowing low-cost, multi-use laboratories equipped with Pi 1. INTRODUCTION boards to support both the plethora of Python-, Scratch- The Raspberry Pi is a credit-card sized computer designed and Linux-based educational activities already in use and to be plugged into a keyboard and TV or HDMI monitor. low-level, embedded activities with access to GPIO pins, fine-grained clock facilities, a network stack, and the graph- ics processing unit. No hardware modifications are required to run XinuPi, so the same Raspberry Pi board can be easily retasked for higher-level activities with the swap of an SD Permission to make digital or hard copies of all or part of this work for card and a power cycle. personal or classroom use is granted without fee provided that copies are The source code of XinuPi, documentation, and class- not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to tested laboratory activities from previous ports of Embed- republish, to post on servers or to redistribute to lists, requires prior specific ded Xinu are all freely available under a BSD-style license permission and/or a fee. at http://xinu.mscs.mu.edu. Copyright 20XX ACM X-XXXXX-XX-X/XX/XX ...$15.00. 2. PRIOR AND RELATED WORK has an Ethernet port, but the actual hardware supporting The Raspberry Pi is now easy to obtain, and is used by a it, likely for cost reasons, is in fact a USB device (namely, broad spectrum of hobbyists, researchers and educators. Ap- the \SMSC LAN9512 USB 2.0 Hub and 10/100 Ethernet plications of Raspberry Pis range from computer-controlled Controller"). stage lighting[6], automatic coffee-brewing systems[16], and home entertainment systems[20]. Many computing educa- 3.2 Booting and Startup tors have expressed interest in using the Raspberry Pi in To boot the Raspberry Pi, one simply needs to apply 1 their classrooms[4], whilst others have designed entire classes power after inserting a SD card containing appropriate boot around the Pi. files. The SD card must contain an MS-DOS-style disk label Cambridge University has developed a series of hands- (partition table) with at least one FAT-formatted partition on Raspberry Pi exercises that builds a simple command whose root directory contains three \binary blobs" provided line interface[11]. Their target is a single-thread assembly by Broadcom (start.elf, bootcode.bin, and loader.bin) language executable which does not provide many of the core along with the actual kernel that gets started on the ARM features of an operating system, such as concurrent threads, processor (kernel.img). The reason for this somewhat in- device drivers, or interrupts. flexible boot method is that the VideoCore co-processor is Raspberry Pi educational resources include programming in charge of the boot process. However, an optional file con- environments such as Scratch and Python, which are fully fig.txt allows users to customize certain parameters, such implemented in the vendor-provided Raspian distribution, as the memory split between the ARM and VideoCore. as well as a user guide written by co-creators of the Pi After the VideoCore performs various tasks, kernel.img for beginners[15]. Similarly inexpensive embedded systems, is loaded at physical memory address 0x8000 and the ARM such as the Arduino board, are commonly used as teaching begins execution at that address. The kernel is expected to resources beyond simply systems education. For example, be raw binary and not in a format such as ELF. To make high school teachers are using the Arduino to take creative Embedded Xinu comply with this boot protocol, we use a approaches in teaching computational sciences. A recent ex- linker script that links the kernel to run at address 0x8000 ample is the LilyPad e-textile approach, in which students and places the entry point at that address, then use objcopy sew textiles together to create programs out of quilts[17]. to convert the kernel from ELF to raw binary. The Raspberry Pi also has a vibrant user community, as The ARM startup code then must perform at least the can be seen by the constant activity on the Raspberry Pi following tasks: Forum. Many of the forum moderators are creators or de- 1. Set up the ARM exception vector table, which is com- signers of the board, who often share technical knowledge mon to all ARM CPUs as described in [1], at physical with the community. Because the Pi is so new, lessons have memory address 0. The only handler strictly required not been fully tested before classroom implementation; the for basic operating system functionality (including pre- forum represents a place to test lessons and applications. emptive multitasking, but no memory protection etc.) Embedded Xinu has been used by a multitude of schools is the IRQ handler, described in more detail later. in a variety of classes to teach operating systems [9], net- working [10], compilers [19], embedded systems [24], hard- 2. Enable desired CPU features, such as unaligned mem- ware systems [8], and software testing [21]. As a research ory accesses, by reading and writing to the System platform, it has supported novel systems work ranging from Control Coprocessor (again, standard to the ARM ar- IP telephony [22] to distributed, many-core operating sys- chitecture as described in [1]). The ARM contains L1 tems [28]. instruction and data caches that are initially disabled While other groups have begun efforts to port Xinu to the and can be enabled if desired. Raspberry Pi[7], we believe our effort is the first successful project that ports all relevant functionality, including USB 3. Clear the .bss section of the kernel image for zero- and networking. initialized global variables. 4. Reserve memory for operating system use. In Em- 3. PORTING XINU TO THE PI bedded Xinu, we reserve space for the stack of the The following subsections describe the hardware details \nulluser" thread, which is the thread that runs the relevant to porting a lightweight operating system to the initial C startup code. We assign the rest of available Raspberry Pi.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-