Intel Galileo – First Impressions
August 21st, 2014 • Electronics, Netduino, Software Development • 2 Comments »Yesterday I received my Intel Galileo rev 1 board. I know the rev 2 board is available but recently the Windows on Devices program have release the necessary firmware etc to upgrade a Galileo rev 1 board to enable it to run Windows.
See the end of this article for an update added on 6th Sept 2014.
Upgrading the Firmware
The first step was to check athe firmware and upgrade it if necessary. In my case it was necessary. Intel provide a comprehensive set of instructions on how to do this. The upgrade process took about 10 minutes.
Creating a Windows SD Card
The next step is to write Windows to a micro SD card. This step of the process took the longest to complete, about 25-30 minutes.
Booting to Windows
The next step is to verify that Windows has loaded correctly. Insert the card, power on and then waiting for 2 minutes for Windows to boot. If successful you should be able to telnet to the device. I used PTTYPortable to do this and was presented with the login request.
Testing the Board
One of the first tests I normally perform is to deploy a Blinky application to the board. Once I am happy that I can deploy applications to the board I speed up Blinky by removing any code which would cause a pause. The result should be an indicator of the performance of the board and the software. So let’s give it a go.
The Galileo board offers two methods for deploying Blinky to the board:
- Arduino UI
- Visual Studio Windows application
The first method uses the board without the Windows SD card image, the second deploys a Windows application to the SD card and runs as a Windows application.
Our starting point for the tests will be the standard Blink application:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup()
{
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop()
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Arduino UI
Using this application in the Arduino UI for the Galileo is simple. In fact the application is one of the samples (File -> Examples -> 01.Basics -> Blink). Loading this sketch and deploying to the Galileo starts the on board LED blinking at a steadily at 1 Hz.
Visual Studio Windows Application
Microsoft have provided a Wiring API for use in Visual Studio. This allows access to the “Arduino” hardware from a Windows application. An equivalent Windows version of the same application is:
#include "stdafx.h"
#include "arduino.h"
int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}
int led = 13; // This is the pin the LED is attached to.
void setup()
{
pinMode(led, OUTPUT); // Configure the pin for OUTPUT so you can turn on the LED.
}
// the loop routine runs over and over again forever:
void loop()
{
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
Log(L"LED OFF\n");
delay(1000); // wait for a second
digitalWrite(led, HIGH); // turn the LED on by making the voltage HIGH
Log(L"LED ON\n");
delay(1000); // wait for a second
}
Much of the application looks the same as the Arduino application. The main differences are the addition of the _tmain method and the Log statement. The _tmain method acts as the entry point for the application and provides a method for running an Arduino sketch (as above) or some other program logic.
The Log statements generate debug information which is displayed in Visual Studio’s Output window.
Deploying this application to the board results in… NOTHING!
Digging a little deeper into the examples section of the web site reveals the On Board LED example:
// Main.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "arduino.h"
int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}
//This application flashes the on board LED of the Galileo board by calling GPIO functions directly in the embprpusr.dll instead of using the Arduino layer.
ULONG state = LOW; // keeps track of the state of the on-board LED
void setup()
{
GpioSetDir(LED_BUILTIN, OUTPUT); // Sets the pin to output
}
void loop()
{
if (HIGH == state)
{
state = LOW;
}
else
{
state = HIGH;
}
GpioWrite(LED_BUILTIN, state); // Writes to the pin, setting its value either HIGH (on) or LOW (off)
Log(L"LED %s\n", (HIGH == state ? L"ON" : L"OFF"));
Sleep(1000);
}
Compiling and deploying this application to the board results in the steady flashing of the on board LED.
Reverting to the previous sample and hooking up an oscilloscope reveals that pin 13 is indeed being toggled at 1 Hz it is just not connected directly to the on board LED.
How Fast Can We Go?
Now to find out how fast the board will actually run. Starting with the Arduino example, remove the delay statements, recompile and deploy to the board. Doing this resulted in a square wave with a 50% duty cycle and a frequency of 221Hz. That’s right Hz, not KHz!
Removing the delay and logging statements and deploying the Windows application results in a square wave. This time a 60Hz square wave with a 30% duty cycle is displayed on the oscilloscope.
There must be something wrong. Surely this board with a 400MHz processor should run faster than this.
What About the Netduino?
The Netduino has always had one issue when compared with Arduino and other similar board. Namely it is running interpreted code which is not real time due to the nature of the .NET Microframework and the way the framework runs. I have performed similar tests and I was convinced that it was faster. Only one way to find out, deploy some code to the Netduino Plus 2. This board runs the .NET Microframework on the STM32 family of microcontrollers at 168 MHz. The equivalent code to the two examples above is:
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace NetduinoPlus2
{
public class Program
{
public static void Main()
{
OutputPort dp = new OutputPort(Pins.GPIO_PIN_D13, false);
while (true)
{
dp.Write(!dp.Read());
}
}
}
}
Deploying this to the Netduino PLus 2 and hooking up the oscilloscope results in a square wave with a 50% duty cycle at 17.8 KHz.
Much faster than the Galileo board.
Update 6th Sept 2014
I have been looking through the schematic for the Galileo Rev 1 board and found that not all of the GPIO pins are connected through the CY8C9540A chip but are in fact connected directly top the Quark processor. These GPIOs should be capable of higher speeds. A quick test shows that these pins (Digital 2, 3 & 10) can all generate a 1.16 KHz square wave for an application compiled in debug mode. Compiling the same applications in release more and running the application on the Galileo increases the frequency from 1.16 KHz to 1.27 KHz.
Conclusion
I’ve only had this board for a few hours but I have deployed a few of the examples. The raw GPIO speed appears lower than the interpreted .NET Microframework equivalent. The Galileo has access to a network port with easy access to the Arduino Wiring API but then so does the .NET Microframework.
Some further investigation is required I believe.