Configure Raspberry Pi

This topic provides some helpful tips to install Legato on a Raspbian distribution.

Download and Install

Download Raspbian Lite image from the official website.

Then, install the Raspbian system on your Raspberry Pi.

See the Raspbian Linux docs for details.

Note
Legato requires specific kernel options, so you need to rebuild your kernel. This will be changed in a future release.

Rebuild Kernel

Before building the kernel, you need to setup the configuration.

First, create a file in the directory of the downloaded kernel with these configuration settings:

Sample legatocfg

CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_DEVICE=y
CONFIG_MEMCG=y
# CONFIG_MEMCG_SWAP is not set
# CONFIG_MEMCG_KMEM is not set
CONFIG_CGROUP_SCHED=y
CONFIG_FAIR_GROUP_SCHED=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_BLK_CGROUP=y
CONFIG_SECURITY=y
CONFIG_SECURITY_SMACK=y
CONFIG_DEFAULT_SECURITY_SMACK=y
# CONFIG_DEFAULT_SECURITY_DAC is not set
CONFIG_DEFAULT_SECURITY="smack"
CONFIG_HOTPLUG_CPU=y
CONFIG_ARM_CPU_SUSPEND=y
CONFIG_SUSPEND=y
CONFIG_PM_SLEEP=y
CONFIG_PM_WAKELOCKS=y
CONFIG_PM_WAKELOCKS_LIMIT=100
CONFIG_PM_WAKELOCKS_GC=y
CONFIG_PM_DEBUG=y
CONFIG_PM_ADVANCED_DEBUG=y
# CONFIG_PM_TEST_SUSPEND is not set
CONFIG_PM_SLEEP_DEBUG=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_DECOMP_SINGLE=y
CONFIG_SQUASHFS_EMBEDDED=y
CONFIG_SQUASHFS_FILE_DIRECT=y
# CONFIG_SQUASHFS_FILE_CACHE is not set

Then, run the following command to set up the default kernel configuration for the Raspberry Pi 3 merging options needed by Legato.

ARCH=arm make bcm2709_defconfig && ARCH=arm scripts/kconfig/merge_config.sh -O . .config legatocfg

If you have a Raspberry Pi 2, use bcm2835 instead of bcm2709.

After you've set the options, you can build the kernel:

$ make -j 4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

Follow the Raspbian installing Linux images docs for details on how to update the kernel on the SD card.

See the Raspbian building docs if you want detailed info about building the kernel (CROSS-COMPILING).

Download and Install Legato Framework

On the Target, run these commands:

$ mkdir /mnt/flash
$ mkdir /mnt/legato
$ mkdir /legato
$ cp /lib/systemd/system/systemd-journald.service /etc/systemd/system/

You also need to edit:

  • /etc/systemd/system/systemd-journald.service
  • add "SmackProcessLabel=syslog" in [Service]

To allow you to login as root:

  • edit /etc/ssh/sshd_config
  • set PermitRootLogin to Yes.

On the Host PC, download Legato from the GitHub repo

If you have a Rapberry Pi 3, Legato's toolchain doesn't currently support the ARMv8 processor. You have to do a few extra steps to add the ARMv8 support:

Clone the Raspberry Pi tools repository.

Set the following envvars, changing ~/rpi/ to your cloned directory name:

export RASPI_TOOLCHAIN_DIR=~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
export RASPI_TOOLCHAIN_PREFIX=arm-linux-gnueabihf-

Make Legato for Raspbian

You can now make Legato for Raspbian.

cd to your Legato directory

Run $ make raspi

The makefile creates a /build/raspi/legato.squashfs file system. Copy this file into the /boot of the SD card:

$ scp build/raspi/legato.squashfs root@IP_RASPBERRY:/boot

To finish, mount the squash file on the Raspberry Pi and start Legato:

$ sudo mount -t squashfs /boot/legato.squashfs /mnt/legato/
$ /./mnt/legato/start
Note
To use data connection, you must install PPP Daemon (use 'apt-get install ppp')

Configure WiFi

To use your Raspberry Pi as a WiFi access point, you need to configure wlan0 in the /etc/network/interfaces file like this:

allow-hotplug wlan0
iface wlan0 inet manual
wireless-mode master

The WiFi access point sample app demonstrates how one Internet connection can be shared with multiple WiFi devices. To have Wireless WAN connectivity on a Raspberry Pi, a module like Linkwave's The PiloT is required. The PiloT is known to work with Legato and Raspberry Pi, and can be used to create a wireless WiFi hotspot with the WiFi access point sample app.