0% found this document useful (0 votes)
5 views7 pages

Arduino Tool Chain Overview - Arduino Academy

The document provides an overview of the Arduino tool chain, explaining how it converts high-level instructions into machine language for microcontrollers. It details the process of compiling code, including the roles of the compiler, assembler, and linker, culminating in the creation of a .hex file that the microcontroller can execute. Additionally, it discusses the differences between programming in C and using the Arduino IDE, highlighting the abstractions and libraries that simplify the programming experience for users.

Uploaded by

Saravanan R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Arduino Tool Chain Overview - Arduino Academy

The document provides an overview of the Arduino tool chain, explaining how it converts high-level instructions into machine language for microcontrollers. It details the process of compiling code, including the roles of the compiler, assembler, and linker, culminating in the creation of a .hex file that the microcontroller can execute. Additionally, it discusses the differences between programming in C and using the Arduino IDE, highlighting the abstractions and libraries that simplify the programming experience for users.

Uploaded by

Saravanan R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

Arduino Academy
Tutorial 6: Arduino Tool Chain
Overview

Arduino Tool Chain Overview


Free Arduino Course
Today we’re going to talk about how the Arduino tool chain converts
instructions you type into the text editor into machine language the
microcontroller can understand.

A tool chain is simply a set of software tools that work together to


complete a task. for example, if we were going to hang a picture, the tool
chain might include a hammer, maybe a tape measure and some nails.

Arduino Hardware/Software Interface


When programming the Arduino (or anything else), it is possible to write
some pretty complex instructions and get the Arduino to do some really
cool things.

The problem is that a microcontroller (like the ATmega328 on the Uno) can
only execute simple, low-level instructions. These simple instructions
include things like add variable a to variable b or take variable b and put it in
register x. 4

And, to complicate matters, microcontrollers only speak in binary. For


those who don’t know, binary numbers are long strings of 1s and 0s. If you
need to brush up on binary numbers, see A Bit of Fun with Binary Number
Basics (http://www circuitcrush com/binary numbers basics/)

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 1/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

Basics (http://www.circuitcrush.com/binary-numbers-basics/).

Figure 1: Arduino and other microcontrollers only understand binary.

The statement here may make total sense to you if you’ve been working
with Arduino for a while. Or, if not, it may not make any sense at all. Either
way, just go with me here for a minute. This is just an illustration which
does not require complete understanding of the code.

Int Temp = analogRead(sensorPin);


If (Temp > 500)

{
//more complex instructions go here
}

How does a complex statement like this one actually run on a


microcontroller that only knows basic arithmetic, logic, moving and
shifting? How do these statements translate into the ones and zeros that
the microcontroller can actually understand?
4
Glad you asked. No, really, I am. This is what we’re going to answer now.

Microcontrollers are electronic devices, so to speak to one you need to


send electronic signals, as in figure 1. That’s where binary numbers come
into play. A zero represents low or off, usually 0 V or close to it, while a one
represents high or on usually either about 5 V or 3 3 V depending on the

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 2/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

represents high or on, usually either about 5 V or 3.3 V, depending on the


processor.

Become the Maker you were born to be. Try Arduino


Academy (https://learnarduinonow.com) for FREE!

A good way to think of binary numbers and digital signals is like a single
pole light switch. The light is either on or its off, there is nothing in
between. Zero is off and one is on.

4
Figure 2: a good way to think about digital signals.

Going from complex instructions to simple ones the microcontroller


understands requires several layers of software that translate the high-
level operations into simpler instructions.

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 3/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

How the Arduino Compiler Works


Enter the compiler. Compiling a program in Arduino is referred to as
verifying. The terms mean the same thing, so throughout these tutorials
we’ll use them interchangeably.

The compiler first transforms the code you write into assembly language.
The name of the compiler we’ll be using on our Uno is AVR-GCC. If you’re
new to this, that may sound kind of weird but try not to obsess over it. It’s
just a name.

The assembler, which come with the IDE with the compiler, then translates
the assembly language program into machine language. It then creates
object files, which combine machine language, data, and information it
needs to place instructions properly in memory. Often, the assembler
creates multiple files which will eventually be put together.

This is where the linker — another part of the compiler software package —
shines. The linker will take all the independently assembled machine
language programs and object files and put them together. This produces a
.hex file that the microprocessor can understand and run.

The two figures below, though they apply to C/C++ programming in


general, are a good illustration of this process.

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 4/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

Figure 3: Arduino code compilation process. The figure below is another


way to view it.

4
Figure 4: another way to visualize the Arduino code compilation process.

Another piece of software, called AVR Dude (for Downloader UploaDEr)


starts when we press the upload button. This software sends the .hex file
to the ATMega328 on the Arduino board. On the chip resides the
bootloader This bootloader was put there on purpose by the folks at

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 5/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

bootloader. This bootloader was put there on purpose by the folks at


Arduino and works with AVR Dude to get the .hex into the flash memory on
the chip.

All of this happens very quickly and seamlessly behind the scenes of the
Arduino IDE.

Figure 5: how the compiled code transfers to the Arduino board.

Programming in C vs Arduino
A few words are in order on this subject due to the enormous popularity of
Arduino boards and the C/C++ language in general.

Some of you use stand-alone or naked microcontrollers for your projects.


After all, this is how things are actually made and mass-produced in the
real world. And it’s cheaper. We talked about naked or stand-alone
microcontrollers vs Arduino in an earlier tutorial

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 6/10
3/25/24, 4:44 PM Tutorial 6: Arduino Tool Chain Overview - Arduino Academy

microcontrollers vs Arduino in an earlier tutorial.

Others use platforms or ecosystems such as the Arduino almost (or


entirely) exclusively.

Finally, some of you may use both depending on your goals and
background.

For hobbyists, the number of people who use platforms like Arduino has
exceeded those who only use naked microcontrollers.

When we talk about programming the Arduino, we’ll talk about the C/C++
languages. The truth is, sketches are written in a language similar to C,
though a sketch itself is not completely compatible with C.

In Arduino, the main() function is hidden from view and added for you when
you compile or “verify” your sketch. Also, there are two functions which the
Arduino ecosystem absolutely requires: setup() and loop(). The only
function C requires is main().

C also lacks built-in functions for using microcontroller I/O such as


digitalWrite().

To make learning simple, the Arduino IDE designers hide a lot of detail and
functionality behind layers of abstraction, many of which come in the form
of libraries. Note that the C programming language also uses libraries. The
linker adds them during the linking process.

Though there are a few slight differences, if you can become a competent
C programmer, you’ll also master the Arduino IDE and crush it on your
Arduino projects. And if you desire to port the code from Arduino to a
naked micro it will be a cinch

https://learnarduinonow.com/tutorial-6-arduino-tool-chain 7/10

You might also like