Project

General

Profile

Getting started

Introduction

This page will present the first steps required to get started with the Dooba SDK.
If you're just starting out, you've come to the right place. We will explore the following:

This guide will provide practical instructions and concrete examples, trying to keep things as real as possible.
We'll stick to the "separate workspace" setup, which is explained in more detail here: Setting up a separate workspace.

Also, the example application we will build will target the ioNode and make use of the eloop library to keep things minimal.
You can read more about why and how to use eloop here: The main loop.

Before we start (prerequisites)

First things first. Let's talk prerequisites.
We're going to need an avr8 toolchain (avr-gcc etc..) as well as avrdude.

AVR8 toolchain

For this, you have two options:
1. install it from your operating system's package manager (YUM, APT, etc...)
2. use the prebuilt toolchain we provide

In most cases the simplest solution will be to use our pre-packaged toolchain:

# Download the Toolchain
wget http://source.dooba.io/attachments/download/1/avr8-toolchain.tgz

# Extract
tar xvzf avr8-toolchain.tgz

# Add 'bin' directory to PATH (through ~/.bashrc)
echo "export PATH=`pwd`/avr8/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc

avrdude

This one should be available in most package managers (YUM, APT, etc...).
Simply install it from there.
If it's not available in your package manager, you can install it directly from here: http://download.savannah.gnu.org/releases/avrdude

Setting up the SDK

First, clone the repository.

You can place it wherever you want.
The general recommendation is to place it in your home folder if your user will be the only one using the SDK on your system.
If your system has multiple users who will use the SDK, then it's probably better to place the SDK in /opt.

Then, to be sure we can run dbuild (the SDK's build system) from the command line, create a link to it in /usr/bin.

Below is a simple example to get the SDK setup:

# Fetch the SDK
git clone git://dooba.io/DoobaFirmware

# Enter the SDK directory
cd DoobaFirmware

# Create a symlink to dbuild
sudo ln -s "`realpath ./dbuild`" /usr/bin

Congratulations, that's it! We are now ready to start building stuff using the Dooba SDK :)

Building a first application

Let's create a very simple application: blinking a LED.
This example application will target the ioNode and use the eloop library to keep things as simple as possible.

Some more extensive examples are available in the tutorials:

Create the app directory

For that, we'll create a folder for our application in our workspace.

# Let's create a workspace (unless you already have one) in our home folder
mkdir work
cd work

# Create a directory for our application
mkdir hello_world

Write the app definition

Now, we need to create two files in that test_app directory.
First, we need a definition file for our application - this needs to be called dfe.conf and should contain the following:

# Hello World Application

# Name
name: hello_world

# Type - Application
type: app

# Target - ioNode (ATMEGA1284P @ 10MHz)
mmcu: atmega1284p
freq: 10000000L

# Dependencies
deps:
  - eloop
  - ionode

Write some code

Then, we can write our application's code. Let's create another file called hello_world.c in our application's folder:

#include <util/delay.h>
#include <ionode/ionode.h>

// Initialization
void init()
{
    # Initialize ioNode
    ionode_init();
}

// Main loop
void loop()
{
    // Turn LED ON & Wait half a second
    ionode_act_led(1);
    _delay_ms(500);

    // Turn LED OFF & Wait half a second
    ionode_act_led(0);
    _delay_ms(500);
}

Build it

Our application is now ready - let's try to build it.
Run the following from the root of your workspace:

dbuild -v

If all went well, an out folder should have been created in your workspace.
This out folder contains all build artifacts, including your final firmware images in out/bin.
Our app can be found here:

out/bin/hello_world.hex

If you want to know more about the build system, check this out: building with dbuild.
Also, you can read about the source tree to get a better understanding and discover more possibilities.

Flashing our application

To flash our application, we need to connect the ioNode to a USB port on our computer, and immediately (within 4 seconds) run the following command:

avrdude -c arduino -P /dev/ttyUSB0 -p atmega1284p -U flash:w:out/bin/hello_world.hex

Note: on many systems, accessing the USB directly requires elevated privileges. If you get an error while running the command above, try to run it with sudo.