NanoPython - Researching the Feasibility of Running Python Scripts on Arduino Using a Virtual Machine
Typ
Examensarbete på kandidatnivå
Program
Publicerad
2020
Författare
CAMPBELL, TOBIAS
STRÅLMAN, KARL
Modellbyggare
Tidskriftstitel
ISSN
Volymtitel
Utgivare
Sammanfattning
Virtualization today is a prominent method of both deploying and maintaining applications at
a low cost. Various types of virtual machines exist and are used in different fields of computer
science. Searching for new innovative ways to deploy tests, Swedish consultancy firm Broccoli wants to research the feasibility of running Python on an embedded system. This thesis
primarily focuses on language virtual machines, the compilation involved and researching the
feasibility of developing a Python virtual machine for a particular embedded system development board, an Arduino Uno. Starting with a subset of the Python grammar, a bytecode
compiler written in Java was developed with the ANTLR tool. Meanwhile, a virtual machine
running the compiler-generated bytecode was developed using C++. By adding small fragments
to the grammar and accordingly writing additional code to account for this, more functionality
was added to both the compiler and the virtual machine. By utilizing tests, functionality of
the project could be preserved. The compiler runs the whole process of language processing,
including lexing, parsing and code generation. It then generates code in a specific binary file
format. A binary file can then be interpreted by the virtual machine. This enables the execution
of simple Python scripts on both PC and the chosen system, without regard to optimization
for neither compilation nor execution. Although not perfect, the current implementation does
run on both systems. Some problems include the limited memory space of the Arduino and
the lack of support for important language-defining constructs. Despite the drawbacks, with
further improvements the current implementation may be used in the future as a means to
rapidly deploy tests, which is of interest to Broccoli.
Beskrivning
Ämne/nyckelord
Python , Java , C++ , ANTLR , Language virtualization , Virtual Machine , Compilation chain , Embedded Systems , Arduino , Programming Language Technology