Invalid syntax for [github owner="..." repo="..." latest]

Getting Started

Arduino Firmware

The following steps describe how to download, compile and upload the Homecontrol firmware to an Arduino device using Gentoo Linux 64bit. Have a look at the Arduino Linux Playground for basic steps to setup a build environment for other flavors of Linux.

Build Environment

Note if you already setup a proper build environment for your Arduino device, you can skip this section and proceed with Download, Compile & Upload.

To compile the Homecontrol firmware, we need to setup a cross compiler toolchain for AVR microcontrollers which can easily be done using the Gentoo cross-toolchain generator sys-devel/crossdev from portage. Unfortunately some crossdev versions are buggy and we encountered problems with the Arduino Ethernet library and the delay method when running the compiled firmware on the device. Following the discussion here we found a patch for sys-devel/crossdev-20120305 that fixes the mentioned problems. So we had to add the patch to the crossdev ebuild using a portage overlay before we can proceed as follows:

$ emerge \=sys-devel/crossdev-20120305

The crossdev tool will add another portage overlay and compile the required AVR packages like cross-avr/binutils, cross-avr/gcc and cross-avr/avr-libc with some additional USE flags. To also provide avr-g++, we had to add the cxx -nocxx USE flags to cross-avr/gcc by hand. This results in the following USE flags for the AVR toolchain:

$ cat /etc/portage/package.use/cross-avr
cross-avr/binutils -selinux -multilib
cross-avr/avr-libc -selinux -multilib
cross-avr/gcc cxx -nocxx -fortran -selinux -boundschecking -d -gtk -gcj -libffi -mudflap -objc -objc++ -objc-gc -multilib

Further we fallback to binutils-2.20.1 since there are known bugs in more recent versions:

$ crossdev -t avr --b 2.20.1

It seems that /usr/libexec/gcc/avr/ldscripts is not created properly. In this case it has to be created manually:

$ ln -s /usr/x86_64-pc-linux-gnu/avr/lib/ldscripts /usr/libexec/gcc/avr/ldscripts

This will emerge cross-avr/gcc-4.5.4, cross-avr/avr-libc-1.8.0 and cross-avr/binutils-2.19.1-r1 which we recommend to use for our purpose.

After we setup the AVR toolchain, we further need dev-util/cmake as cross platform make and dev-embedded/avrdude in order to upload the binary file to the Arduino device:

$ emerge dev-util/cmake dev-embedded/avrdude

Further it should be ensured that USB Modem and USB Serial Converter support is available in the current kernel:

Device Drivers
    [*] USB Support
        <M>   USB Modem (CDC ACM) support
        <M>   USB Serial Converter support

This creates a serial port device node under /dev/ttyACM*, /dev/ttyUSB* or /dev/ttyS* when the Arudino Ethernet board is connected via USB.

Download, Compile & Upload

If the build environment is setup properly, we can now get the source code of the latest Homecontrol firmware from Github:

$ mkdir -p ~/workspace/homecontrol/firmware
$ cd ~/workspace/homecontrol/firmware
$ git clone https://github.com/homecontrol/firmware code
$ cd code
$ git submodule update --init

Further we create a build directory, compile and upload the firmware using CMake:

$ mkdir -p ~/workspace/homecontrol/firmware/build
$ cd ~/workspace/homecontrol/firmware/build
$ cmake ../code
$ make
$ make upload

If everything completes without errors, the Homecontrol firmware was successfully uploaded to your Arudino board and is ready to use.

By default, we assume an Arduino Ethernet board and /dev/ttyACM0 as its serial port. This can be changed by setting ARDUINO_DEFAULT_BOARD and ARDUINO_DEFAULT_PORT accordingly in code/CmakeLists.txt or using the CMake configuration utility:

$ cd ~/workspace/homecontrol/firmware/build && ccmake ../code

A list of supported Arduino boards will be printed when cmake runs the first time.