Building Yocto Linux for Intel Edison

The Intel Edison board is shipped with the Yocto Linux distribution installed. Yocto allows an experienced developer to compile a small-size Linux image with only the selected packages. Then the image is flashed into the board. It’s not as convenient as Ubuntu as there are no pre-compiled packages that are easy to install.

I wanted to add the program mc (Midnight Commander); so, I had to recompile the Yocto image. My computer OS is Linux Ubuntu 14.04. I experienced a few problems while compiling; so, I’ll describe them here.

The main document is Board Support Package (BSP) User Guide. I followed it.

Installed the prerequisite packages with the following command:

sudo apt-get install build-essential git diffstat gawk chrpath texinfo libtool \
gcc-multilib dfu-util u-boot-tools

Set up my git name and email:

git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"

Downloaded the package Linux source files from the Intel Edison Software Downloads page. At the time of writing, it was in the section Intel Edison® Board Firmware Software Release 2.1.

I install everything related to the Intel Edison into the directory /home/farit/edison. The Linux sources consume 11G in that directory.

Decompressed the source package:

tar xzf edison-src-ww25.5-15.tgz  -C /home/farit/edison/
cd /home/farit/edison/edison-src/

Moved my download and build cache (also called sstate) directories from the default location under the build directory, using the –dl_dir and –sstate_dir options. To create download and sstate directory, used the mkdir command:

mkdir /home/farit/edison/bitbake_download_dir
mkdir /home/farit/edison/bitbake_sstate_dir

Used the setup.sh script to initialize the build environment for Intel Edison.

/home/farit/edison/edison-src/meta-intel-edison/setup.sh \
--dl_dir=/home/farit/edison/bitbake_download_dir \
--sstate_dir=/home/farit/edison/bitbake_sstate_dir \
--build_dir=/home/farit/edison/edison-src

After the setup, I ran these commands recommended by the setup script:

cd /home/farit/edison/edison-src
source poky/oe-init-build-env
bitbake edison-image

The compilation took 5 or so hours. I should’ve used the SSD disk. But most files have been downloaded and cached now; so, it doesn’t take much time the second time.

Then I decided to compile in Midnight Commander. I checked the name of the package on the Yocto recipes directory. It was “mc”.
I opened the file /home/farit/edison/edison-src/meta-intel-edison/meta-intel-edison-distro/recipes-core/images/edison-image.bb and added the lines at the bottom:

#Midnight Commander
IMAGE_INSTALL += "mc"

Then ran again:

cd /home/farit/edison/edison-src
source poky/oe-init-build-env
bitbake edison-image

Then I created a new Linux image:

/home/farit/edison/edison-src/meta-intel-edison/utils/flash/postBuild.sh
/home/farit/edison/edison-src/build/toFlash/flashall.sh

At first, the command complained about the non-existing mkimage program, which is in the package u-boot-tools:

Error : ota_update.scr creation failed, mkimage tool not found

I added a symlink to mkimage and ran the postBuild.sh script again:

cd /home/farit/edison/edison-src
mkdir -p u-boot/tools
cd u-boot/tools
ln -s /usr/bin/mkimage mkimage

When there were no errors, I looked in the directory /home/farit/edison/edison-src/build/toFlash. It contained the same files as in the Intel’s firmware image.
I ran the command flashall.sh in it as root. I added myself into the group “dialout”; so, I should be able to connect to a USB port as a regular user. I’ll check it again the next time.

Midnight Commander on Intel Edison
Midnight Commander on Intel Edison

By default, the subshell (Ctrl-O) doesn’t work in Midnight Commander as it requires bash. Change your user shell from the default “/bin/sh” to “/bin/bash” in /etc/passwd.

When I want to quickly recompile just the kernel after changes, I run these commands:

cd /home/farit/edison/edison-src
source poky/oe-init-build-env
bitbake -f linux-yocto

Using Atmega1284 with Arduino

I downloaded an archive for my selected branch of Arduino (version 1.6.3 at the time of writing).

Mighty 1284P: An Arduino core for the ATmega1284P

I connected my programmer AVRISP mkII to the ISP header of the board to upload the Arduino bootloader. I also connected the FTDI device to provide the 5V power to the board; otherwise, programming doesn’t work.

avrisp_atmega1284p_programming

I use the variant of the microcontroller pin definitions “avr_developers”, also known as “sanguino” for my project.

You can find the definitions in the file ~/arduino/hardware/arduino/avr/variants/avr_developers/pins_arduino.h

// ATMEL ATmega1284P (should also work for SANGUINO/ATmega644P)
//
//                       +---\/---+
//           (D 0) PB0  1|        |40  PA0 (AI 0 / D31)
//           (D 1) PB1  2|        |39  PA1 (AI 1 / D30)
//      INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D29)
//       PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D28)
//    PWM/SS (D 4) PB4  5|        |36  PA4 (AI 4 / D27)
//      MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D26)
//  PWM/MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
//   PWM/SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
//                 RST  9|        |32  AREF
//                 VCC 10|        |31  GND
//                 GND 11|        |30  AVCC
//               XTAL2 12|        |29  PC7 (D 23)
//               XTAL1 13|        |28  PC6 (D 22)
//      RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
//      TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
// INT0 RX1 (D 10) PD2 16|        |25  PC3 (D 19) TMS
// INT1 TX1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
//      PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
//      PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
//      PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
//                       +--------+
//

I use my AVRISP mkII programmer to load the bootloader into the microcontroller. I use Atmel AVR Studio (version is 4.19).

I go to Tools -> Program AVR -> Connect. Then I select my programmer.

Selecting a programmer, AVRISP mkII in my case
Selecting a programmer, AVRISP mkII in my case
Reading the signature from Atmega1284p
Reading the signature from Atmega1284p
Selecting the bootloader hex file, optiboot_atmega1284p.hex in my case.
Selecting the bootloader hex file, optiboot_atmega1284p.hex in my case. Click on Program to upload the bootloader into the chip.
Program the fuses into the chip.
Program the fuses into the chip.

Then I copy the files from the downloaded archive into the hardware/arduino/avr/ subdirectory of the installed Arduino directory and add the settings for the avr_developers board into boards.txt.

##############################################################

avr_developers.name=avr-developers.com pinouts 16MHz using Optiboot
avr_developers.upload.tool=arduino:avrdude
avr_developers.upload.protocol=arduino
avr_developers.upload.maximum_data_size=16384
avr_developers.upload.maximum_size=130048
avr_developers.upload.speed=115200
avr_developers.bootloader.tool=arduino:avrdude
avr_developers.bootloader.low_fuses=0xf7
avr_developers.bootloader.high_fuses=0xde
avr_developers.bootloader.extended_fuses=0xfd
avr_developers.bootloader.file=optiboot/optiboot_atmega1284p.hex
avr_developers.bootloader.unlock_bits=0x3F
avr_developers.bootloader.lock_bits=0x0F
avr_developers.build.mcu=atmega1284p
avr_developers.build.f_cpu=16000000L
avr_developers.build.core=arduino:arduino
avr_developers.build.variant=avr_developers
avr_developers.build.board=1284P_AVR_DEVELOPERS

After that I select this board in the Arduino IDE: Tools -> Board

Arduino Clock Atmega1284p with MIDI player and Internet

The Arduino Clock
  • uses the C++ object-oriented code written for the Arduino framework
  • is powered by the 8-bit Atmel’s microcontroller ATmega1284P
  • is installed on the PCB from Wise Clock 4
  • displays information on the Sure Electronic’s 32X16 RG Dual Color LED Dot Matrix Unit Board (display colors: red, green, orange)
  • adjusts time from the Internet using the NTP protocol via the Wi-Fi RN-XV WiFly Module
  • shows the weather forecast from the Internet
  • has alarms that can be configured to activate every day or once on a specific date or tomorrow or on different week days
  • plays music in the RTTTL format that was popular in mobile phones
  • plays music in the MIDI format via the Fluxamasynth Shield that uses the Atmel’s and Dream’s ATSAM2195 MIDI chip
  • changes the brightness of the display depending on the light level in a room detected by the light-dependent resistor
A video with the description of the clock menus
Here are the internal devices of the clock
arduino_clock_inside
Download the code for the clock

From Github: https://github.com/faritka/arduino-clock-atmega1284-midi