Introduction

I recently got hold of an Intel Galileo Generation 2 board (Thanks Intel! :) . These boards are an improvement on the generation 1 boards in that they have faster GPIO ports and a more sensible arrangement for the serial terminal. While the Galileo can emulate an Arduino, my interest lies in the underlying Linux operating system. I prefer to see the Galileo as being an alternative to the Raspberry Pi rather than an Arduino with the added advantage of having Arduino headers built in. I am particularly interested in exploring Python programming on the device.

Getting started

The Intel IOT-devkit is a Linux image for the Galileo boards that includes many of the libraries you might need for using the board. You need to write this to an SD Card. I had an 8GB card available and used Ubuntu Linux on my PC to set the card up as described below. The IOT dev-kit image includes two partitions: a boot partition and a Linux partition (for the root file system). The image does not make use of all of the space available on the SD Card so I used the procedure below to create a new partition in the remaining space and mount this as /home. If you are not concerned about the unused space stop after step 4 (don't worry about the fdisk and fstab stuff
1) Download the iot-devkit boot image from:
https://software.intel.com/en-us/iot/downloads

2) Insert the card in your SD Card slot bunzip and dd to a memory card

WARNING: Make sure you select the correct output device or you may overwrite valuable data on your PC


sudo dd if=iot-devkit-latest-mmcblkp0.direct of=/dev/mmcblk0

3) Boot image.

4) login (as root, no password)

5) Run fdisk (in the galileo shell )as follows
fdisk /dev/mmcblk0

6) Create a new partition (mmcblk0p3, remaining space on SDCard)

7) reboot galileo

8) create filesystem on new partition:
mke2fs -j /dev/mmcblk0p3

9) edit /etc/fstab: (add the '/home' line)
# stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       defaults              1  1
/dev/mmcblk0p3	     /home		  auto	     defaults	           0  2
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
usbdevfs             /proc/bus/usb        usbdevfs   noauto                0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
/dev/mmcblk0p1       /media/card          auto       defaults,sync,auto  0  0

10) Reboot

Getting Python going

Python can interact with the Galileo I/O using a library called mraa. The version of mraa that came with the IOT dev-kit image was a little dated so I went here
https://github.com/IntelOpenDesign/MakerNode/wiki/mraa:-updating-to-the-latest-version
and followed the instructions. I recommend you update this library regularly as it is subject to ongoing development.

SPI with Python

My initial goal is to get the Galileo working with an NRF24L01 radio module. These modules have an SPI interface so the first task is to get python talking to SPI.
#!/usr/bin/python
# test script for python on galileo
import mraa as m
spi=m.Spi(0)
spi.mode(m.SPI_MODE0)
spi.frequency(100000)
ss=m.Gpio(10)
ss.dir(m.DIR_OUT)
x=1
while (x < 1000):
        ss.write(0) # drive SS low
        spi.write("abcd",4)
        ss.write(1) # drive SS high

Using my BitScope Micro I captured the following image off the SPI interface (pin 10=SS, pin 11=MOSI, pin 13=SCK)



The bottom trace (white) is MOSI, the orange trace is SS and the red trace is SCK. The data rate is set pretty low to allow the BitScope keep up and the Slave Select line is controlled by software but that's fine for now. Having verified that Python does indeed work, next step is to write some code for the NRF24L01

Back to Frank's home page