Embedded Software Education: an RTOS-Based Approach
Total Page:16
File Type:pdf, Size:1020Kb
Embedded Software Education: An RTOS-based Approach James Archibald Doran Wilde Electrical and Computer Engineering Dept. Electrical and Computer Engineering Dept. Brigham Young University Brigham Young University [email protected] [email protected] ABSTRACT Under the best of circumstances, the creation of functional Embedded computer systems are proliferating, but the com- software for non-trivial applications is demanding. Virtu- plexities of embedded software make it increasingly difficult ally no substantive software programs have been found to be to produce systems that are robust and reliable. These chal- error-free when subjected to careful analysis [1]. Embedded lenges increase as embedded systems are connected to net- developers face all the challenges of conventional software works and relied on to control or monitor physical processes and more. For example, embedded software typically must in critical infrastructure. This paper describes a senior-level interact directly with hardware, it must respond to time- course that exposes students to foundational characteristics critical events in specified time windows, and it often relies of embedded software, such as concurrency, synchronization on concurrency (processes, threads, interrupts) to meet re- and communication. The core of the class is a sequence of sponse time requirements. laboratory assignments in which students design and imple- ment a real-time operating system. Each student-developed Given the formidable task facing firmware developers, it is RTOS has the same API, so all can run the same applica- not surprising that the creation of embedded software is tion code, but internal implementations vary widely. The quantifiably more demanding than conventional software [8], principal challenges that arise in the design and debugging nor is it surprising that the same kinds of mistakes turn of a multi-tasking RTOS tend to be instances of the general up repeatedly during design and development [24]. Given problems that arise in embedded software. In our experi- the importance of embedded systems, there is considerable ence, the activity of creating a working RTOS is effective in interest among researchers and practitioners in improving helping students acquire the knowledge and skills required the efficiency with which embedded software is created. Ef- to be successful embedded software developers. forts focus on a wide range of alternatives, ranging from improved tools and languages to optimized testing method- ologies. These approaches may well improve productivity Keywords and reduce error rates, but it is highly unlikely that they Embedded systems, embedded systems education, real-time will eliminate bugs in embedded software. operating systems, concurrency, real-time computing, soft- ware bugs An undergraduate education that prepares students to be- come embedded system developers should expose students to the fundamental challenges of embedded software, includ- 1. INTRODUCTION ing the use of typical constructs and related problems that Mobile and embedded devices are commonplace in modern too-often accompany their use. As practicing professionals, society, and embedded systems are increasingly deployed to graduates should understand the underlying issues so they support critical infrastructure. Consumers naturally expect can avoid problems in their own designs, and so they know their embedded devices to operate reliably; embedded sys- the most likely causes of behavioral anomalies in their sys- tems that provide essential functionality in an airplane or a tems during development and testing. It is widely accepted municipal water system will be held to the highest standards that students learn best about embedded systems through of dependable operation. Unfortunately, reports of vulnera- their own hands-on experience [10] [13] [18] [14]. bilities or outright failures in critical embedded systems are increasing in frequency and attracting the attention of the Within the dynamically evolving academic disciplines re- general public. lated to embedded systems, there is constant pressure to create new classes and to expand coverage of emerging top- ics, but changes are limited by faculty resources and the number of course that can be packed into an undergradu- This work is based on an earlier work: Preparing Students for ate curriculum [25]. In practice, the well founded desire to Embedded Software Development: An RTOS-based Approach. In expose each student to a broad spectrum of technical topics Workshop on Embedded and Cyber-Physical Systems Education, limits the extent to which they can focus on specializations WESE, © ACM, 2015. within their major discipline. As a result, many students will http://dx.doi.org/10.1145/2832920.2832926. end up working in a sub-discipline in which they have taken Copyright of this extended version retained by the authors. just one advanced undergraduate class. Educators thus fre- quently face this challenge (as we have): if our graduates ley, which they note was shaped by their research projects will go into the workplace as embedded software developers [21] [22]. They describe an advanced graduate class that having taken just one class with that focus, what is the best focuses on RTOS concepts, including scheduling and com- content we can provide in that course to prepare them? munication. Among other assignments in the class, students implement a simple RTOS. This paper describes our answer to that question: a senior- level course in which students work with a partner to design Marwedel describes an introductory course in embedded sys- and implement a real-time operating system (RTOS) or ker- tems for students from multiple disciplines that has been nel from the ground up. In a sequence of labs over the course fine-tuned over a period of almost ten years [19]. Relevant of the semester, students create interrupt service routines, topics covered in the class include scheduling, operating sys- then core kernel routines that perform context switching, tems for embedded systems, and typical properties of an and then other kernel functions that support synchroniza- RTOS. tion and communication between concurrent tasks. A final lab focuses on writing code for a time-critical application Koopman et al. describe embedded system education for un- that uses their RTOS. A central thesis of this paper is that dergraduates at Carnegie Mellon University. Students in the completion of this project sequence gives students crit- their first course develop application software for microcon- ical insight into and experience with the fundamental chal- trollers running an RTOS. In a later class, students more lenges inherent in embedded software. fully explore the capabilities of an RTOS in supporting real- time software. In class labs, students implement an embed- In the remainder of this paper, we discuss a sampling of ded RTOS and then write application code that runs on related work from the literature, we explore the challenges their OS. Topics addressed in the class include concurrency, of embedded software, we describe the RTOS-based course preemption, real-time synchronization and communication. that has been in place in our curriculum for over a decade, and we consider those aspects of the course that are most Sztipanovits et al. describe the embedded curriculum at Van- responsible for its success. derbilt University. They note the difficulty in a mid-sized engineering school of creating new classes for new areas of 2. RELATED WORK specialization. They describe an undergraduate course on real-time systems that emphasizes design, implementation, A survey of the literature on embedded system education and theoretical foundations, and that covers many of the confirms that a wide variety of approaches have been taken, same topics as the course we describe in this paper. depending on the technical nature of the associated degree program, whether the courses are graduate or undergrad- Caspi et al. discuss guidelines for a graduate curriculum on uate, and the mix of other (non-embedded) courses in the embedded software. One area of foundational knowledge curriculum [11]. We focus here on papers that make specific they identify is real-time computing, including design, val- mention of a course that involves the design or use of an idation and operating systems. They observe that classes RTOS, or that includes very similar content. with a real-time focus are among the most commonly taught in existing embedded systems curricula. Chen et al. describe a set of six short courses on embedded systems intended to address deficiencies in first-year grad- Ping describes five main areas of emphasis that embedded uate students [7]. One of those courses focuses on kernel systems curricula should address [20], one of which is op- implementation issues, including context switching, schedul- erating systems for embedded systems. The author states ing, message passing, and interrupt service routines. Stu- that students should master the basic concepts of an RTOS dents study the mechanisms of an embedded operating sys- and know enough to port an existing RTOS to a new target. tem so that they understand the services it provides, but they do not implement an RTOS. The authors note that Wolf and Madsen discuss key factors in education about it requires \sophisticated programming skills to develop a embedded computing [26]. They observe that, outside em- kernel." bedded system classes, students have virtually no experience with raw CPUs, where they are \free from operating system Hsu