Makecode and CODAL: Intuitive and Efficient Embedded Systems Programming for Education
Total Page:16
File Type:pdf, Size:1020Kb
MakeCode and CODAL: Intuitive and Efficient Embedded Systems Programming for Education James Devine Joe Finney Peli de Halleux Lancaster University, UK Lancaster University, UK Microsoft, USA [email protected] [email protected] [email protected] Michał Moskal Thomas Ball Steve Hodges Microsoft, USA Microsoft, USA Microsoft, UK [email protected] [email protected] [email protected] Abstract Across the globe, it is now commonplace for educators to engage in the making (design and development) of embed- ded systems in the classroom to motivate and excite their students. This new domain brings its own set of unique re- quirements. Historically, embedded systems development requires knowledge of low-level programming languages, lo- Figure 1. Example projects undertaken within education: cal installation of compilation toolchains, device drivers, and Rishworth School sent a micro:bit to space [19] (left); The applications. For students and educators, these requirements micro:bit placed in a custom-built rocket car for teleme- can introduce insurmountable barriers. try [20, 21] (right). We present the motivation, requirements, implementation, and evaluation of a new programming platform that enables novice users to create software for embedded systems. The 1 Introduction platform has two major components: 1) Microsoft MakeCode Recent years have witnessed expansive growth in the popu- (www.makecode.com), a web app that encapsulates an entire larity and ubiquity of embedded systems. This growth can beginner IDE for microcontrollers; and 2) CODAL, an effi- be primarily attributed to the emergence of new application cient component-oriented C++ runtime for microcontrollers. domains ranging from wearables, to home automation, indus- We show how MakeCode and CODAL provide an accessible, trial automation, and smart grids ś a phenomenon broadly cross-platform, installation-free programming experience referred to as the Internet of Things (IoT). As the IoT con- for the BBC micro:bit and other embedded devices. tinues to grow, it has become more pervasive ś far beyond the realm of domain experts and into the everyday lives of CCS Concepts · Software and its engineering → Em- the public. This has led to growth in non-expert developers bedded software; Runtime environments; Integrated and vi- actively creating software for embedded systems. Small to sual development environments; medium sized businesses now create new products through Keywords education, classroom, embedded systems rapid prototyping of embedded devices. Hobbyist makers cre- ACM Reference Format: ate novel technical projects to inspire themselves and society. James Devine, Joe Finney, Peli de Halleux, Michał Moskal, Thomas And now, more than ever before, educators are making exten- Ball, and Steve Hodges. 2018. MakeCode and CODAL: Intuitive sive use of physical computing devices as a direct means to and Efficient Embedded Systems Programming for Education. In teach and inspire a generation of students ś and to prepare Proceedings of 19th ACM SIGPLAN/SIGBED Conference on Languages, them for a society where IoT will be the norm. These new Compilers, and Tools for Embedded Systems (LCTES’18). ACM, New developers all share a common characteristic: they are not York, NY, USA, 12 pages. https://doi.org/10.1145/3211332.3211335 professional software developers [9, 10, 16]. To address this trend, in 2015 a consortium of industry and academic partners came together to develop the BBC micro:bit ś an embedded device designed specifically for education. One million of these devices were delivered to UK school children in 2016. The micro:bit is a highly capable IoT device containing a 32-bit ARM Cortex-M0 processor, in- LCTES’18, June 19ś20, 2018, Philadelphia, PA, USA tegrated light level, temperature, acceleration and magnetic © 2018 Copyright held by the owner/author(s). ACM ISBN 978-1-4503-5803-3/18/06. sensors, touch sensitive inputs, and USB and 2.4GHz radio https://doi.org/10.1145/3211332.3211335 communications. 19 LCTES’18, June 19ś20, 2018, Philadelphia, PA, USA J. Devine, J. Finney, P. Halleux, M. Moskal, T. Ball, S. Hodges Figure 1 highlights two example educational projects based Table 1. Example microcontroller devices in relationship on the BBC micro:bit. The first is a data gathering experiment, to a typical PC. Device abbreviations: Uno (Arduino Uno), where multiple sensor data was recorded to non-volatile micro:bit (BBC micro:bit), CPX (Adafruit Circuit Playground memory as the device was launched into near space (32.5km Express), PC (Personal Computer). altitude), along with an externally interfaced camera and Word CPU GPS unit. The second highlights a live data telemetry appli- Device RAM Flash Size Speed CPU cation, where acceleration data was streamed in real-time via Uno 2 kB 32 kB 8 16MHz AVR Bluetooth Low Energy to enable the profiling of chemical- micro:bit 16 kB 256 kB 32 16MHz ARMv6-M rocket powered model vehicles. These projects are highly CPX 32 kB 256 kB 32 48MHz ARMv6-M sophisticated and were undertaken by high school educators PC 16 GB 1 TB 64 3GHz x86-64 and their students. 1 We introduce an open-source platform for embedded permitted by policy and/or access to the necessary technical devices such as the micro:bit that enables the development support is not present. An effective solution must therefore of embedded applications by non-expert programmers. This provide a fully transparent, platform agnostic, zero installation platform consists of two major components: 1) Microsoft experience to developing embedded software. MakeCode (www.makecode.com), a web app providing a beginner IDE for embedded systems; and 2) CODAL Optimization for Code Efficiency: The projects of Figure 1 (Component-Oriented Device Abstraction Layer), an efficient are enabled by small, highly resource-limited programmable C++ runtime with high-level programming abstractions. MCUs, which may have as little as a few kilobytes of RAM In the remainder of the introduction, we present the major and FLASH memory. Table 1 compares the core capabilities design challenges in bringing embedded systems into edu- of the class of MCU-based devices typically used in the edu- cation, briefly describe the architecture of our solution, and cation domain to a typical PC. Note that these devices have a give an overview of the paper and our results. proportionally large amount of processing power, relative to their storage. Consider the BBC micro:bit vs. a typical PC: the 1.1 Design Challenges micro:bit has about 100 times less CPU power, but 106 times Enabling novice programmers to successfully develop em- less RAM, and 106 times less storage. A language/runtime bedded applications is a non-trivial task. Throughout our should therefore not only seek to provide high code density and research we have identified a number of design challenges spatial efficiency, but actively trade off temporal for spatial that we address through MakeCode and CODAL. efficiency where possible. High Level Languages: Programming languages for micro- Asynchronous and Concurrent Programming: It is al- controller units (MCUs) have not kept pace with advances ready well understood that novice programmers benefit from in hardware. Despite active research in the field, the C/C++ event-based programming paradigms [17, 18, 26]. This is in- languages remain the standard for embedded systems: they creasingly relevant for embedded systems due to the typically provide a familiar imperative programming model, with com- asynchronous nature of their hardware. MCUs still follow pilers that produce highly efficient code, and enable low level Moore’s law, but this additional capacity is not typically in- access to hardware features when necessary. The Arduino vested in speeding up processors. Instead, more independent project (www.arduino.cc), started in 2003, and ARM’s Mbed peripherals (such as Bluetooth/WiFi radio modules, audio platform (www.mbed.org) both rely heavily on a C/C++ pro- inputs/output processors, etc.) are integrated onto the same gramming model [6, 24]. However, the limitations of using package as the CPU as a system-on-chip. Such peripherals C/C++ as an application programming language for inexpe- often operate independently of the main CPU. An effective rienced developers are well understood [8]. To address this, language/runtime should directly support an asynchronous higher level languages such as JavaScript, Python, and even interaction model designed to cooperate with the independent visual programming languages are required. nature of peripherals while remaining highly intuitive to the programmer. Zero Installation Architecture: The development environ- ment for existing embedded systems typically requires the Intuitive and Extensible APIs: Intuitive APIs and program- installation of code editors, custom device drivers, com- ming models are required to support novice users, yet it is piler toolchains, and even additional programming hardware equally important that these APIs remain complete enough (such as a JLink programmer). For many, particularly in the to realise the ambitious projects that may be undertaken as field of education, this presents a high adoption barrier asin students advance: simplification via the reduction of func- many schools, custom hardware and software is simply not tionality is not a valid approach. An effective solution must provide APIs that are consistent, easy to understand/use, and 1 MakeCode is open-source at https://github.com/microsoft/pxt; CODAL