wiki:ArduinoHowto
Last modified 12 months ago Last modified on 05/23/11 18:00:55

Arduino Duemilanove: quick start howto

Quick steps to flash a BeRTOS image on Arudino Duemilanove.

NOTE: This howto has been tested on Ubuntu 10.04 (Lucid).

Download the required packages

Get the BeRTOS source code, available at the download section. In this howto we'll use the latest weekly snapshot.

  $ wget http://download.bertos.org/snapshot/bertos-current.tar.bz2

Untar the BeRTOS source:

  $ tar xvjf bertos-current.tar.bz2

Start the BeRTOS wizard and create a full project in 10 clicks

Run the following command to start the wizard:

 $ ./wizard/bertos.py

wizard welcome screen

Choose a name for your project (in this example we use arduino):

wizard: new project

Confirm the BeRTOS version to use the BeRTOS version that you have just downloaded:

wizard: choose the BeRTOS version

The project will use a predefined board, not a custom hardware, so we can confirm "Predefined board" for our project type:

wizard: predefined board / custom board

Choose Arduino Duemilanove:

wizard: arduino

Let's start with a banchmark project: BeRTOS context switch.

wizard: context switch benchmark

Choose the "Base" setup:

wizard: base setup / advanced setup

Select the project output (check Create CodeLite? project if you want to manage this project using the CodeLite) IDE:

wizard: project output

Confirm the setting summary:

wizard: settings summary

The project is finished and ready to be deployed on Arduino!

wizard: project created

Build the project

Move on your project directory and build everything:

$ cd ~/arduino
$ make
Building revision 1
arduino: Compiling bertos/benchmark/context_switch.c (C)
arduino: Compiling bertos/kern/signal.c (C)
arduino: Compiling bertos/kern/kfile.c (C)
arduino: Compiling bertos/struct/heap.c (C)
arduino: Compiling bertos/mware/formatwr.c (C)
arduino: Compiling bertos/mware/event.c (C)
arduino: Compiling bertos/drv/timer.c (C)
arduino: Compiling bertos/cpu/avr/drv/timer_avr.c (C)
arduino: Compiling bertos/kern/proc.c (C)
arduino: Compiling bertos/cpu/avr/drv/ser_avr.c (C)
arduino: Compiling bertos/drv/ser.c (C)
arduino: Compiling bertos/mware/hex.c (C)
arduino: Compiling arduino/main.c (C)
arduino: Compiling bertos/mware/formatwr.c (PROGMEM)
arduino: Assembling with CPP bertos/cpu/avr/hw/switch_ctx_avr.S
arduino: Linking images/arduino.elf
"/opt/avr-4.3.2/bin/avr-"objcopy"" -O srec images/arduino.elf images/arduino.s19
"/opt/avr-4.3.2/bin/avr-"objcopy"" -O ihex images/arduino.elf images/arduino.hex
"/opt/avr-4.3.2/bin/avr-"objcopy"" -O binary images/arduino.elf images/arduino.bin

The BeRTOS image will be placed under the "images/" directory. The output is available in different formats: Motorola S19 record, binary, hexadecimal dump.

Flash the BeRTOS image on Arduino

Flash the image using avrdude (the avrdude package is available in the standard Ubuntu's repository):

 $ avrdude -p m328p -c arduino -P /dev/ttyUSB0 -b 57600 -F -U flash:w:images/arduino.hex

The benchmark is running!

Get the output of the BeRTOS Context Switch benchmark from the UART:

$ setserial /dev/ttyUSB0 baud_base 115200
$ dd if=/dev/ttyUSB0 bs=1
Switch: 20.544 usec
Switch: 20.544 usec
Switch: 20.544 usec
Switch: 20.544 usec
Switch: 20.544 usec
...

Now we can see that with BeRTOS the context switch between two processes requires about 20 µs on the Arduino Duemilanove board.

Attachments