Selected Solution
The selected solution revolves heavily around the existing capabilities of the Arduino tool chain.
Using the current Arduino tool chain is more efficient than making an entirely new tool and
minimizes the potential for licensing conflicts when the project is redistributed to students taking
Computer Organization at the University of Tennessee. The base tool chain offered simple,
native solutions to the problems that this project involved; finding the right solutions were a
matter of exploring the functionality and reverse engineering the tool chain to suit our needs.
Exporting to assembly, filtering the output, as well as importing and linking assembly files can
be done with existing tools.
The exporting feature compiles a user’s sketch (.ino.cpp) into assembly (.s). The major
components of the assembly exporting functionality were prototyping a compile statement,
implementing an execute call in Java, matching compile flags to variables, and updating to use
variables instead of hard-coded flags. To develop a prototype compile statement that would
compile sketch code to assembly, the team examined the existing Arduino IDE compile
statements that are used by the IDE to compile user code into an executable to run on Arduino
boards. The next step to implement the exporting functionality was to add the compilation
command from the previous step into the IDE. This added the minimum functionality to meet the
requirement that the IDE be able to export a project to assembly. After the ability to compile was
added into the IDE, the team matched some of the compile flags to variables used by the IDE.
This greatly increases the robustness and flexibility of the additions to the IDE. Finding the
variables to be used involved additional reverse engineering of the existing IDE to determine
where flags could be found when the IDE compiles to an executable. The final step was to
update the Java code to use these variables instead of hard-coded flags. This process of
achieving the minimum exporting feature also implements the filtering feature. Exporting the
user’s sketch code results in almost pure user assembly. It reduces approximately ninety-
percent of the non-user assembly that is outputted during exporting. This isn’t perfectly “pure” in
the sense that exported assembly still contains some extraneous output, especially the
assembly header and footer, but it is reduced enough that student users can be told to ignore
the extra assembly.
The idea behind importing is that users should be able to compile and link assembly files for
execution regardless of source. For this functionality to meet the design requirements, the
feature must be able to take an assembly file, with the .s extension, and do all of the standard
compilation steps to produce an executable that can run on the Arduino Due microcontroller.
This process includes the following components: compiling the assembly file itself along with
any operating system related Arduino libraries, generating an assembly map, producing a .elf
file, and producing the final binary executable. Each of these components breaks down to
separate, but related, system commands. To develop the overall feature to meet the
requirements, similar steps have been taken as discussed in the previous section. Each
command was implemented as generic Java statements compared to the original hard-coded
shell scripts. Implementing each of these components one-by-one into the IDE resulted in
meeting the minimum requirement for the importing feature.