Arduino-Lite Lightweight AVR library(2)

Arduino-Lite Lightweight AVR library(2)

This is the second article in the series, which introduces the installation and usage of the Arduino-Lite. Arduino-Lite is a lightweight high-performance firmware library for AVR mcus, which is developed based on the original Arduino project. We make it easy to use, just like the Arduino. Compared to the original library, Arduino-Lite generates smaller binaries and perform faster. Some brief introduction to the Arudino-Lite: Arduino-Lite, Lightweight AVR library(1)

1. What are included in Arduino-Lite?

Arduino-Lite hosted on Google Code consists of:

  • Source code of Arduino-Lite firmware library
  • WINAVR (avr-gcc) compiler set
  • Arduino-Lite compiling system
  • Tools
  • Samples and templates

Arduino-Lite users only need to download the package to develop, compile, burn/upload and even debug AVR programs, along with system default text editors(notepad, vim); no third-party library are required. Arduino-Lite, for sure, do not prevent you from using any software or libraries.

2. Download and configure Arduino-Lite

2.1 Get Arduino-Lite

The open source version of Arduino-Lite can be retrived from Google Code:。There are two ways to get Arduino-Lite:

  • Compressed Package
In the Download section of our Google Code project page, we released compressed packages of Arduino-Lite, what are named like After downloading, no installation steps are needed, just decompress to some folder.
  • SVN
Check out any revision anonymously from the svn repository hosted on Google Code.

  After downloading and decompression, the directory tree should like this:

  • src contains all source code of Arduino-Lite firmware library
  • User projects, templates and samples are placed under sketch directory
  • scripts contains some scripts related to the compilation process
  • bin contains tools and avr-gcc

2.2 Environment requirement

The Arduino-Lite firmware library is cross-platform, what can be compiled under almost all operating systems; but our compiling system is currently stick on windows. After some simple modification, our compiling system can also work well under Linux/MacOS. We will provide this support in the future. The compiling system of Arduino-Lite has been tested under the following operating systems:

  • Windows XP 32bit
  • Windows Vista 32bit and 64bit
  • Windows 7 32bit and 64bit

2.3 Configuration at the first time

While you are using this tool-set for the first time (just checked out from svn or decompressed from the downloaded package), please just execute the batch “buildenv.cmd” at the root directory of Arduino-Lite. “buildenv.cmd” is responsible to set up the working environment of Arduino-Lite automatically:

  • Set up bash environment (based on msys)
  • Decompress the WINAVR (avr-gcc) compilers
  • Configure environment variables (if needed)

You should see the following command prompt window:

After executing this batch file, Arduino-Lite is ready to use.

3. Develop with Arduino-Lite

3.1 Create an Arduino-Lite project

The compilation system of Arduino-Lite follows the simple and stupid philosophy. No more third-party tools, no more makefiles, workable development environment is available out of box. Construct projects by writing Makefiles, using IDEs like AVRStudio, Eclipse or Arduino IDE are also welcomed. The sketch directory of Arduino-lite is used to contain projects. In this example, we suppose the project is named “myAVR”. Some simple steps to achieve this: a. Decompress the and get a directory tree like this: (The “launchsh.cmd” should be seen at the sketch/template/ directory) is the template of Arduino-Lite projects, what contains ready-to-use Makefile and sample source code at src/main.cpp. The compilation system of Arduino-Lite use Makefile to compile source codes, which process are contained in a bash shell. You can launch a bash shell by executing “launchsh.cmd”. b. Rename the template directory to your project’s name, in this case, “myAVR”Utill now, a new Arduino-Lite project has been created, which will generate code for Atmega168 at 16MHz. The project contained by is a LED fading sample, will output at arduino pin 11. If your program need to work on different chip or frequency, please refer to the rest part of this article.

3.2 Add files to project

Just place source code under the src directory or its sub directories (.cpp, .c, .S, .h and .hpp files are supported), the compiling system will automatically compile and link them. Just write code, and same, no need to modify the Makefile script. For instance, the following figure is the project tree of one of RoboPeak projects. Arduino-Lite will compile the whole source tree automatically. Like a magic, isn’t it?

3.3 When and how to modify the Makefile script?

Makefile should be modified in the following situations:

  • Target device differs from the default configuration of the Makefile
By default, the Makefile generate binary for Atmega168 at 16MHz
  • Configure the upload/burn settings for target device
Arduino-Lite support serial port self-programming AVR bootloaders (Arduino compatiable) and programming blank AVR chips through RP USB Connector. If you need to configure the baud rate of the programmer, you need to modify the Makefile.
  • Configuration the fuse of AVR chips
While programming with the RP USB Connector, you can specify the fuse data in the Makefile
  • Customize the compilation process or referencing external libraries
If the compile-and-link-all model doesn’t fit your your requirement, or your project references libraries other than Arduino-Lite

Makefile scripts are located at the root directory of each projects, all codes need to be modified in which are marked by “TODO”s. The following example will make Makefile generate binary for Atmega48 at 1MHz, and use COM3 to upload firmware.

3.4 Compile the project

Arduino-Lite use the standard make command to construct project. In order to execute make, please run the launchsh.cmd batch file, which will launch the bash shell. Enter “make” and press the enter key in the bash shell will trigger the project to compile:

If the project is compiled properly without any error, the script will show you some metadata of the binary:

  • The number in the red rectangle shows the firmware size (in bytes), this will be helpful to indicate if the firmware can be fully burned/uploaded to the target device.
  • The number in the orange rectangle show the minim requirement of the memory (sram) . This parameter can be used to evaluate if the memory of the target device is enough.

3.5 Burn/upload binary to target device

3.5.1 Program Arduino and Arduino-compatible boards You can just use “make upload” to program avr chips with bootloader supporting STK500v1 protocol, including:

  • Most Arduino hardwares and its compatible boards delivered with the bootloader
  • Any avr chips with this bootloader

The source code and pre-compiled binary of the bootloader can be found under the src/bootloaders directory. Before burning or uploading, please insure:

  1. The target hardware has connected properly to the PC, and get the serial port of it (COM3 is the default)
  2. Confirm the baud rate of the bootloader (19200 is the default)
  3. If these parameters are not the same as the default one, please modify the Makefile

After the connection, enter “make upload” to upload the new firmware. The process should be like this:

NOTICE: You might need to reboot the AVR chip manually on some non-standard Arduino devices.

3.5.2 Program any AVR chip based circuit system Arduino-Lite compiling system integrated the support to AVR-Doper( and compatible programmers. You can use “make burn” to program any AVR chips or configure fuse. RoboPeak developed a driver-less AVR-Doper compatible programmer support the usb port: RoboPeak USB Connector. We will introduce and open source this project in later articles.

Arduino-Lite support following burn/upload commands. The usage of these command are written at the end of this article.

  • make burn
  • make fuse
  • make lock
  • make erase

3.6 Available compilation targets


  • “make” or “make all”
Compile current project
  • make clean
Clean compilation results


  • make upload
Upload hex to AVR chips via serial port (through bootloaders for STK500v2)
  • make usbupload
Upload hex to AVR chips via usb port (through HidBootloaders)
  • make burn
Burn hex to target AVR chips through RoboPeak USB Connector (or other Avr-doper-compatible programmers)
  • make erase
Erase the target AVR chips through RoboPeak USB Connector (or other Avr-doper-compatible programmers)
  • make fuse
Configure the fuse data of the target AVR chips through RoboPeak USB Connector (or other Avr-doper-compatible programmers)
  • make lock
Configure the lock bits of the target AVR chips through RoboPeak USB Connector (or other Avr-doper-compatible programmers)

Code analysis and debugging

  • make dump
De-assemble compiled efl files to AVR asm instructions
  • make dumpobj
De-assemble compiled object files (*.o) to AVR asm instructions

In the next article, we will introduce the new functions provided by Arduino-Lite.   ElecFreaks – electronic design, electronics components, development platform