Introduction: Building a Debian Linux Distribution for the Intel Galileo

Picture of Building a Debian Linux Distribution for the Intel Galileo

Hello Internet,

Today we'll be learning how to build and install a Debian Linux Distribution for the Intel Galileo Gen 1/2.

Why Debian?

The Debian distribution allows a more native linux familiar command line interface. Commands such as apt-get and aptitude are available straight out the box rather than in a Yokto distribution where using opkg and finding repositories could lead you to an infinite loop.

Lets Get Shopping:

1) Intel Galileo Gen 1 or 2

2) SD Memory Card (8GB Recommended)

You will also need a computer with Linux Installed.

Step 1: Preparation

Format SD Card to FAT file system

On Mac: Run Disk Utility. Go to Applications on your Mac. Open Utilities. Run Disk Utility.app.

Insert the micro SD card into your computer. In the left hand sidebar of Disk Utility, select the card. In this case, the card has never been formatted before and is called NO NAME. Click the Erase tab. From the Format drop-down list, select MS DOS (FAT). In the Name field, type Debian to make it easier to identify in the steps below. Click Erase to confirm your settings. Click Erase in the confirmation message to erase the contents of your card.

On Linux: Run Disks, as follows: Run Unity Dash (desktop search utility). Enter the command: disks. Select the Disks app. Insert the micro SD card into your computer. In the left sidebar, select the micro SD card. If you see multiple partitions, select a partition and click the - icon to delete the partition. Click the + icon to create a new partition. From the Type drop-down list, select Compatible with all systems and devices (FAT). In the Namefield, type Debian to make it easier to identify in the steps below.

Adapted by: http://intel.ly/1JWSTC9

Preparing your linux machine

On your linux machine, enter the following commands which will install debootstrap and setup the environment for mounting a Debian image.

# apt-get install debootstrap

# mkdir galileo-debian

# cd galileo-debian

# mkdir mnt-loop

# mkdir image

Step 2: Creating the Debian Image

Creating the filesystem for the new Debian Image

Entering the following command will create a new Debian image.

# dd if=/dev/zero of=loopback.img bs=1G count=1

# mkfs.ext3 loopback.img

Step 3: Mounting the Image

Download:

We will start by downloading the original image for the Galileo from Intel.

http://downloadmirror.intel.com/24000/eng/LINUX_IMAGE_FOR_SD_Intel_Galileo_v1.0.2.zip

Extract the zipped folder, go into the SD CARD directory, and copy "image-full-galileo-clanton.ext3" to your galileo-debian folder.

Enter the following commands:

# mount -o loop loopback.img ./mnt-loop

# debootstrap --arch i386 wheezy ./mnt-loop

# mount image-full-galileo-clanton.ext3 image

Step 4: Copying Files

These copy commands will put together our Debian system with the necessary original linux files needed for the Galileo.

# cp -ru image/lib/ mnt-loop/

# cp -ru image/usr/lib/libstdc++.so* mnt-loop/usr/lib

# cp -ru image/lib/libc.so.0 mnt-loop/usr/lib

# cp -ru image/lib/libm.so.0 mnt-loop/usr/lib

# cp image/usr/bin/killall mnt-loop/usr/bin/

# cp image/etc/inittab mnt-loop/etc/inittab

# cp image/etc/modules-load.quark/galileo.conf mnt-loop/etc/modules

# cp -r image/opt/ mnt-loop/

# cp image/etc/init.d/galileod.sh mnt-loop/etc/init.d/

# cp image/etc/init.d/quark-init.sh mnt-loop/etc/init.d/

Step 5: Configuring Our Debian Build

From this point on, we will be working inside our Debian build configuring important settings such connecting to the internet, ssh, and our hostname.

Run the following commands:

root@debian:/ mount -t proc proc mnt-loop/proc

root@debian:/ mount -t sysfs sysfs mnt-loop/sys

root@debian:/ chroot mnt-loop /bin/bash

root@debian:/ echo "Galileo" > /etc/hostname

root@debian:/ nano /etc/network/interfaces

Edit the file with the following:

auto eth0

iface eth0 inet dhcp

root@debian:/ apt-get install ssh
root@debian:/ passwd

Set your new password

root@debian:/ mkdir /media/realroot

root@debian:/ mkdir /sketch

root@debian:/ update-rc.d galileod.sh start

//(If this gives you errors, don't worry about it). I had errors, fixed them with the help of google and forums

//for them just to come back again. If you have a permanent fix please share and I will update :)

Step 6: Packing Up

Picture of Packing Up

Wrap it up, we are almost done packing and sending out new Debian Linux Distribution.

Enter the following commands:

root@debian:/ exit

# umount mnt-loop/proc

# umount mnt-loop/sys

# umount image

# umount mnt-loop

cp loopback.img /pathToSDRoot/image-full-galileo-clanton.ext3

Copy all files that were in the folder "SD CARD" except for "image-full-galileo-clanton.ext3"

to the root of the SD card.

Step 7: Running Debian on the Intel Galileo

Pop the SD Card in and wait 1-2 minutes for Linux to boot.

At this point it is safe to check if the board will save Arduino Sketches uploaded.

Upload the blink sketch provided in the Arduino Examples.

Once you have your LED blinking, Restart the Galileo.

Within 1-2 minutes, if the LED Starts blinking again, Congratulations, you have successfully installed

Debian on your intel Galileo.

Next what you'd want to do is to check if your ethernet port is running and SSH into it.

ethernetTest Arduino Sketch


Download the sketch provided to test your network and its IP Address.

Using the serial monitor, if the IP address of the Galileo is listed, then you are now ready to SSH into it.

Copy down your IP Address.

Step 8: SSH Into Debian

Open a terminal, or putty, or you favorite program for SSH-ing


In terminal, you would type

sudo ssh root@

Enter your sudo password and the password you chose when configuring your Debian Build.

If you receive a message of success, then pat yourself on the back for successfully SSH-ing into your Debian Build on the Intel Galileo.

Step 9: Wrap It Up

From here on I recommend entering a couple of commands:

# apt-get update

# apt-get install ntp //Configures the Network Time Protocol for automatically setting time and date

# apt-get install build-essential //Configures Build Essentials (Make)

If you'd like to set-up a local server on your Intel Galileo (Which I Strongly Recommend for DIY-ers)

# apt-get install apache2 php5 libapache2-mod-php5

You can then access your server by entering /index.html in your browser

You can manage your server in the /var/www directory on your Galileo.

Thank you for taking your time to learn from this Instructable,

I would appreciate all comments and feedback!

Goodluck!

Comments

MerlinS6 (author)2016-02-14

I successfully went through the entire process (with jessie instead of wheezy, just had to reenable ssh root login). Thank you very much!

Is it possible to run the OpenVPN-client on this distribution? The startup of this client fails with the error message "Cannot open TUN/TAP dev /dev/net/tun: No such file or directory". After a lot of fiddling and research I discovered that CONFIG_TUN is not enabled in the kernel, so "modprobe tun" fails with a "module not found". I tried using a different, fully featured kernel (https://github.com/todorez/galileo-linux-stable) but sadly this won't boot together with your Debian distro.

OmarQ13 (author)MerlinS62017-10-04

Hello Merlin,

Onae question: How do you get this command: root@debian:/ apt-get install ssh

I've been trying all the day, my output error is this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "",
LC_ALL = "en_US.UTF-8",
LC_TIME = "en_US.UTF-8",
LC_MONETARY = "en_US.UTF-8",
LC_CTYPE = "en_US.UTF-8",
LC_ = "en_US.UTF-8",
LC_COLLATE = "en_US.UTF-8",
LC_ADDRESS = "en_US.UTF-8",
LC_TELEPHONE = "en_US.UTF-8",
LC_MESSAGES = "en_US.UTF-8",
LC_NAME = "en_US.UTF-8",
LC_MEASUREMENT = "en_US.UTF-8",
LC_IDENTIFICATION = "en_US.UTF-8",
LC_NUMERIC = "en_US.UTF-8",
LC_PAPER = "en_US.UTF-8",
LANG = "es_MX.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Coulde you help me, please?

OMAR.

MerlinS6 (author)OmarQ132017-10-11

Hello Omar,

It seems to me that your problem is not related to the platform (Galileo), but to the operating system (Debian). Googling the error message "perl: warning: Setting locale failed." yields several results, for example this one: https://ubuntuforums.org/showthread.php?t=1346581
Ubuntu is build on Debian, so the described solution might work. Otherwise, keep on going through other search results or ask your question in a Debian-related forum.

MerlinS6 (author)MerlinS62016-02-14

I would appreciate any help, I'm an intermediate Linux user but out of ideas and unfortunately OpenVPN is a key requirement for my desired application.

MiguelA44 (author)2015-10-18

Hello,

The link that you provided is no longer valid. The current version of the linux image ("http://downloadmirror.intel.com/24355/eng/SDCard.1.0.4.tar.bz2") does not work using these instructions. Everything seems to be fine until step 7. The Arduino IDE detects the board, but fails to download. The following is displayed in the output window of the Arduino IDE:

#!/bin/sh

starting download script

# clupload script to invoke lsz

# Copyright (C) 2014 Intel Corporation

#

Args to shell: /Users/miguelalonsojr/Library/Arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0/x86/bin /var/folders/cz/4_f6kxjn7y1b3vtqswlrbkb40000gn/T/build3733215399650621505.tmp/Blink.cpp.elf /dev/cu.usbmodem14131

# This library is free software; you can redistribute it and/or

Serial Port PORT (note: should be /dev/cu.xxxxxx for OSX)

# modify it under the terms of the GNU Lesser General Public

Using tty Port /dev/cu.usbmodem14131

# License as published by the Free Software Foundation; either

Sending Command String to move to download if not already in download mode

# version 2.1 of the License, or (at your option) any later version.

#

# This library is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

# Lesser General Public License for more details.

#

# You should have received a copy of the GNU Lesser General Public

# License along with this library; if not, write to the Free Software

# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#

echo "starting download script"

echo "Args to shell:" $*

#

# ARG 1: Path to lsz executable.

# ARG 2: Elf File to download

# ARG 3: TTY port to use.

#

#path may contain \ need to change all to /

path_to_exe=$1

fixed_path=${path_to_exe//\\/\/}

#

tty_port_id=$3

echo "Serial Port PORT" $com_port_id "(note: should be /dev/cu.xxxxxx for OSX)"

echo "Using tty Port" $tty_port_id

#

echo "Sending Command String to move to download if not already in download mode"

echo "~sketch downloadGalileo" > $tty_port_id

#Give the host time to stop the process and wait for download

sleep 1

#

#Move the existing sketch on target.

Deleting existing sketch on target

echo "Deleting existing sketch on target"

"$fixed_path/lsz" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" < $tty_port_id > $tty_port_id

Retry 0: Got TIMEOUT

Retry 0: Got TIMEOUT

Transfer incomplete

#"$fixed_path/lsz.exe" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" < $tty_port_id > $tty_port 1>&0

#

# Execute the target download command

#

#Download the file.

host_file_name=$2

"$fixed_path/lsz" --escape --binary --overwrite $host_file_name < $tty_port_id > $tty_port_id

Retry 0: Timeout on pathname

Transfer incomplete

#

#mv the downloaded file to /sketch/sketch.elf

target_download_name="${host_file_name##*/}"

echo "Moving downloaded file to /sketch/sketch.elf on target"

"$fixed_path/lsz" --escape -c "mv $target_download_name /sketch/sketch.elf; chmod +x /sketch/sketch.elf" < $tty_port_id > $tty_port_id

Moving downloaded file to /sketch/sketch.elf on target

Retry 0: Got TIMEOUT

Retry 0: Got TIMEOUT

Transfer incomplete

#

#

This is using Arduino version 1.6.5, with an Intel Galileo Board with the firmware upgraded to 1.0.4 and using the 1.0.4 SDCard tar file mentioned above. Any thoughts on how to resolve this?

LiamD23 (author)MiguelA442016-11-14

Any update on this? I have the same error!

MiguelA44 (author)MiguelA442015-10-18

The link seems to be up again, but still no success...

SomePolishGuy (author)2015-12-16

Looks great! Can't wait until I can reach this level of comprehension

MiguelA44 (author)2015-10-23

Well, after a few days of scouring the internets... and following many, many, tutorials, I've put together a build script that should handle building a Debian image with debootstrap. Check it out: https://github.com/drmaj/alokin

seamster (author)2015-08-25

Thanks for sharing this!

Nava-Juarez (author)seamster2015-08-25

My Pleasure! :]

About This Instructable

7,358views

11favorites

License:

Bio: Hello! I am a student studying Computer Science with a background in Engineering as a hobbyist. C/C++ is my strength and time is my ...
More by Nava-Juarez:Joystick Controlled Surveillance CameraStreaming USB Webcam with the Intel Galileo Gen 2Building a Debian Linux Distribution for the Intel Galileo
Add instructable to: