User Tools

Site Tools


gnx5howto:setupdevplatform

Toolchain setup and Hello World example

This page provides details on how you can:

  • Set up a development platform for Guinnux 5 on your PC.
  • Write a simple c program and execute it on the board.

Toolchain

The toolchain is essentially a clone of the operating system and kernel that the board runs. You therefore need it to cross compile code on your PC to run on your board.

Getting the toolchain

You can set up the toolchain by following the instructions in The Guinnux 5 Toolchain wiki page.

Installing Packages

Once you have the toolchain you can start installing packages using the package manager. The Guinnux toolchain uses Arch Linux's package manager, pacman (see https://wiki.archlinux.org/index.php/pacman). For starters, let's see some examples of the basic operations of pacman. You can install a package using the following command:

$ arm-gnx5-linux-gnueabi-pacman -Sy "package name"

The “y” flag makes sure our package index is up-to-date with the remote package repository.

You can search for packages using the following command:

$ arm-gnx5-linux-gnueabi-pacman -Ss "search term"

Now that the toolchain has been set up you can start developing code for the board.

Hello World example

This example shows how you can write a simple c program for your Guinnux 5 device.

Installing missing packages

The first step is to install any missing packages that you might need. In this case gcc-libs:

$ arm-gnx5-linux-gnueabi-pacman -S gcc-libs

HelloWorld.c

The contents of the HelloWorld.c file:

#include <stdio.h>
 
int main(void)
{
  printf("Hello World!\n");
  return 0;
}

Compiling the code

Now that you have written the code, it can be compiled with the following command:

$ arm-gnx5-linux-gnueabi-gcc HelloWorld.c

By default this creates the binary “a.out”.

Getting the binary on the board

To get the binary on the board, boot it up. Connect to the board using either SSH or Minicom.

SSH

Connect a USB cable to the board and SSH to it using the following command:

$ ssh root@192.168.5.1

Alternatively an Ethernet cable and the boards IP can be used.

You will be prompted for the password (the default is “bigbang”).

Minicom

Install Minicom if you don't have it already. Connect a serial cable and use the following command to connect:

$ minicom -D /dev/ttyS0

Note that the serial interface is not necessarily ttyS0. Verify the available tty interfaces with the following command:

$ dmesg | grep tty

Once you are connected to the board you can use the default login details to log in.

gnx5 login: root
password: bigbang

Copying the binary to the board

A simple method of copying the executable to the board is by using scp from the source directory:

$ scp a.out root@192.168.5.1:~

You will be prompted for the password.

Executing the binary

Once the binary is on the board it can be executed:

$ ./a.out

You should see “Hello World!” printed to the terminal.

gnx5howto/setupdevplatform.txt · Last modified: 2016/08/30 15:38 by ben