@meta@ Arduino development setup on Gentoo | rainerkeller.de
rainerkeller.de

Arduino development setup on Gentoo

2015-07-18

This article describes how to setup an Arduino development environment on Gentoo using only git resources.

Setup

Crossdev

If you don't have setup crossdev on your machine alreay this is the first step to do. These instructions are only a summary. If you need more details have a look in the documentation.

Create a portage overlay to allow crossdev to store its ebuilds.

/etc/make.conf

PORTDIR_OVERLAY="/usr/local/portage $PORTDIR_OVERLAY"
mkdir -p "/usr/local/portage/profiles"
echo "my_repo_name" > "/usr/local/portage/profiles/repo_name"
Then install crossdev
emerge sys-devel/crossdev

Install a toolchain for the device

USE="multilib -cxx" crossdev -v -s1 --gcc 4.6.4 --binutils 2.21.1-r1 --without-headers --target avr
USE="multilib cxx"  crossdev -v -s4 --gcc 4.6.4 --binutils 2.21.1-r1 --libc 1.8.0 --target avr
ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/avr/lib/ldscripts

Install additional tools

For transferring your program to the device you need avrdude and pyserial is needed in order to reset the device before uploading new software.

emerge dev-embedded/avrdude dev-python/pyserial

Getting the sources

To work with Arduino you need the core sources and some helper Makefiles. These are fetched from the source code repositories directly using git without installing any packages.

mkdir arduino-sdk
cd arduino-sdk
git clone https://github.com/sudar/Arduino-Makefile
git clone https://github.com/arduino/Arduino.git
cd Arduino
git checkout 1.6.5

Setting up a project

Create a new directory for your project. In this example an Arduino Pro Mini is used.

Makefile

ARCHITECTURE=avr
ARDUINO_VERSION = 165
BOARD_TAG = pro
BOARD_SUB = 8MHzatmega328
ARDUINO_PORT = /dev/{SERIAL_DEVICE}
ARDUINO_LIBS =
ARDUINO_DIR  = {PATH}/android-sdk/Arduino
include  {PATH}/android-sdk/Arduino-Makefile/Arduino.mk

Finally create your source code like this hello world example.

helloworld.ino

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.println("Hello World");
  delay(1000);
}

Building and uploading the program to the Arduino is done using this commands

make
make upload

The uploaded program is now sending Hello World via the serial terminal. To see these you have to use your favorite serial terminal program like kermit, minicom, gtkterm or other. A different way is to use socat for this:

socat - /dev/ttyUSB0,echo=1,crnl,raw,b115200
This should show the sent output.


Anbieterkennzeichnung

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.