openmamba on Raspberry Pi

openmamba devel on Raspberry Pi

Project status

A usable LXDE graphical environment with working sound and network (both ethernet and wireless) connection can run on RPi.

openmamba packages built for the RPi architecture:

kernel-raspberrypi-3.6.11.20130425git-1mamba.arm: Linux kernel files for the RPi.

kernel-raspberrypi-modules-3.6.11.20130425git-1mamba.arm: Linux kernel modules for the RPi.

kernel-raspberrypi-doc-3.6.11.20130425git-1mamba.arm: Raspberry Pi kernel documentation.

libcec-rpi-20130217git-4mamba.arm: USB CEC Adaptor communication Library.

libcec-rpi-devel-20130217git-4mamba.arm: Development files for libcec-rpi.

libraspberrypi-20130302git-1mamba.arm: Libraries for interfacing to Raspberry Pi GPU.

libraspberrypi-devel-20130302git-1mamba.arm: Development files for the Raspberry Pi GPU

omxplayer-rpi-20130302git-1mamba.arm: A commandline OMX player for the Raspberry Pi.

raspberrypi-firmware-3.6.11.20130425git-1mamba:

xbmc-rpi-12.2-1mamba.arm: A media player and entertainment hub for digital media.

wiringPi-20130612git-1mamba.arm: GPIO Interface library for the Raspberry Pi

A web interface for controlling the openmamba RPi is under developement - NEW

web: https://sites.google.com/site/davidemadrisan/opensource/rpiweb

git: https://github.com/madrisan/rpiweb

Future steps

  • Switch to systemd by updating the system to the latest available openmamba-devel snapshot - DONE

  • Wayland techical preview (see the freedesktop page and the Pekka's blog)

Hardware requirements

  • Raspberry Pi board,

  • Prepared SD Card of 4Gb or more (see below),

  • USB keyboard (and optionally an USB mouse),

  • Display (with HDMI, DVI, Composite RCA (PAL & NTSC) or SCART input),

  • Power Supply (via MicroUSB, capable of providing at least 700mA at 5V),

  • Ethernet LAN cable,

  • SD card reader.

Thanks to CFP Informatique and Numeri'zik for providing me the hardware :)

Software requirements

As the RPi has no internal storage it requires an SD-Card that is set up to boot the RPi.

So you need:

Setup

Formatting the SD-Card under Linux

Warning: "DRIVE" must be the device of your SD-card.

You can find this by inserting your card and then running dmesg | tail or better journalctl --follow.

You should see the messages about the device being mounted in the log.

DRIVE=/dev/sdb # -or- DRIVE=/dev/mmcblk0

PARTITION1=${DRIVE}1 # PARTITION1=${DRIVE}p1

PARTITION2=${DRIVE}2 # PARTITION2=${DRIVE}p2

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

# create a root partition for installing openmamba

# (choose one of the following o1ptions)

# 1. use all the SD for the root partition

set -- $(LC_ALL=C fdisk -l "$DRIVE" | grep "^Disk.*bytes"); SIZE="$5"

CYLINDERS=`echo $SIZE/255/63/512 | bc`

{ echo ,9,0x0C,*; echo ,,,-; } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

# 2. create a 2Gb root partition

SIZE=$((2*(1024**3)))

CYLINDERS=`echo $SIZE/255/63/512 | bc`

{ echo ,5,0x0C,*; echo ,$(($CYLINDERS-5)),,-; } | \

sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

mkfs.vfat -F 32 -n "RPI_BOOT" $PARTITION1

mke2fs -t ext4 -j -L "rpi_openmamba" $PARTITION2

tune2fs -m0 $PARTITION2

udisksctl mount -b $PARTITION1

BOOTMP=/run/media/root/RPI_BOOT

udisksctl mount -b $PARTITION2

ROOTMP=/run/media/root/rpi_openmamba

Install openmamba devel

SWHOME=$HOME/raspberrypi

mkdir -p $SWHOME

cd $SWHOME

FTPSITE="ftp://ftp.openmamba.org/pub/openmamba/media/devel/rootfs-light/en"

# Choose the latest snapshot available in the openmamba repository

TARBALL="openmamba-rootfs-light-en-snapshot-20141114.arm.tar.xz"

wget ${FTPSITE}/${TARBALL}

cd $ROOTMP

tar xvf $SWHOME/$TARBALL

# The raspberry pi doesn't have any PCI bus

sed -i "s@^usbfs.*@#&@" $ROOTMP/etc/fstab

echo -e "/dev/mmcblk0p1\t/boot\t\tvfat\tdefaults\t\t0 0" >> $ROOTMP/etc/fstab

Setting up the boot partition

The RPi has no BIOS. It boots by looking for a program called ‘start.elf’ that carries on the rest of the bootstrapping process and it only looks for this file in the first partition of the SD card and only if that partition is FAT32. So this is the procedure I followed to make a bootable SD for RPi.

cd $SWHOME

git clone --depth=1 git://github.com/raspberrypi/firmware.git

# 1st choice. Using the kernel binaries provided by openmamba

for f in bootcode.bin fixup_x.dat start_x.elf LICENCE.broadcom; do

cp $SWHOME/firmware/boot/$f $BOOTMP/

done

cp -p $ROOTMP/boot/zImage-3.14.6-rpi $BOOTMP/kernel.img

cp -p $ROOTMP/boot/System.map-3.14.6-rpi $BOOTMP/

# 2nd choice. Using the kernel binaries provided by the raspberry git

for f in bootcode.bin fixup_x.dat kernel.img start_x.elf LICENCE.broadcom; do

cp $SWHOME/firmware/boot/$f $BOOTMP/

done

# Copy kernel modules (modify the kernel modules path if necessary)

# NOTE: not required if you use the openmamba package kernel-rpi

cp -R $SWHOME/firmware/modules/3.12.28+ $ROOTMP/lib/modules/

# Copy libraries and source code provided by RPi

# cp -R $SWHOME/firmware/opt/vc $ROOTMP/opt

# cmdline.txt: parameters passed to the kernel on boot

echo "\

dwc_otg.lpm_enable=0 \

root=/dev/mmcblk0p2 \

rootfstype=ext4 \

quiet \

rootwait" > $BOOTMP/cmdline.txt

# Create the kernel configuration file

echo "\

start_file=start_x.elf

fixup_file=fixup_x.dat

gpu_mem=128

arm_freq=800

force_turbo=1

hdmi_force_hotplug=1

disable_overscan=1

framebuffer_depth=32

framebuffer_ignore_alpha=1" > $BOOTMP/config.txt

# Enable HDMI mode rather than DVI, if required

echo "\

hdmi_drive=2" >> $BOOTMP/config.txt

# Remove the services that do not work

rm $ROOTMP/etc/systemd/system/multi-user.target.wants/ufw.service

# If you want to modify the default runlevel ('graphical.target')

# to the 'multi-user.target' (aka "level 3"):

ln -sf ../../../lib/systemd/system/multi-user.target \

$ROOTMP/etc/systemd/system/default.target

cd $SWHOME

udisksctl unmount -b $PARTITION1

udisksctl unmount -b $PARTITION2

Setting up the keyboard

If you will not use an American keyboard, you have to modify the following files:

  • /etc/X11/xorg.conf.d/10-keyboard.conf

  • /etc/vconsole.conf

  • /etc/sysconfig/keyboard

Here's an example for configuring a french keyboard layout in /etc/X11/xorg.conf.d/10-keyboard.conf

Section "InputClass"

Identifier "Keyboard Defaults"

MatchIsKeyboard "on"

Driver "evdev"

Option "XkbLayout" "fr"

Option "XkbModel" "pc105"

EndSection

Setting up the timezone

Follow these simple steps to manually change the system timezone (Europe/Paris in the example).

cd /etc

ln -sf ../usr/share/zoneinfo/Europe/Paris localtime

Installing the kernel and RPi software

Now it's better to switch to the kernel files and modules and to the RPi utils packaged by the openmamba developers. This way you'll be able to update this software when new versions will be available.

# if necessary run the following command

HOME=/root gpg -q --import /etc/pki/rpm-gpg/RPM-GPG-KEY-Mambasoft

smart update

smart install kernel-raspberrypi kernel-raspberrypi-modules

smart install raspberrypi-utils

Disabling unnecessary services

You can now turn off unwanted services.

For instance, if you plan to transform your RPi into a multimedia box you can execute the following commands:

for srv in portmap xinetd syslog-ng; do

chkconfig $srv off

service $srv stop

done

# -or- with a more recent openmamba snapshot:

# display a list of all active services:

systemctl list-units --type=service

# and disable the unwanted ones

for srv in portmap syslog-ng brcm-patchram ufw-init alsa-{restore,state,store}; do

systemctl disable ${srv}.service

done

Removing unnecessary rpm packages

We can now remove some software we'll never use to free some disk space.

rpm -e kernel-hannspad kernel-hannspad-modules \

kernel-iconia kernel-iconia-modules \

kernel-mamba-arm kernel-mamba-arm-firmware \

kernel-mamba-arm-sound kernel-mamba-arm-wireless \

kernel-cubox kernel-cubox-devel

rpm -e dracut

rm -fr /lib/modules/*{hannspad,iconia,mamba-arm}

umount /boot && rm -f /boot/* && mount /boot

Creating a swap file

It's recommented to create a swap file of at least 256Mb.

This will help avoid out-of-memory errors while building big projects (like xbmc).

su -

dd if=/dev/zero of=/swap bs=1024 count=262144

mkswap -L rpi_swap /swap

chmod 0600 /swap

swapon /swap

echo "/swap swap swap default 0 0" >> /etc/fstab

Multimedia

Testing audio with hello_audio

Analog and HDMI output both work.

This patch is required in order to build this tool on openmamba:

--- hello_audio/Makefile.orig 2012-09-02 20:04:35.543254955 +0200

+++ hello_audio/Makefile 2012-09-02 20:03:59.274782723 +0200

@@ -1,6 +1,6 @@

OBJS=audio.o sinewave.o

BIN=hello_audio.bin

-LDFLAGS+=-lilclient

+LDFLAGS+=-lilclient -lpthread

include ../Makefile.include

Build instructions:

smart update

smart install gcc glibc-devel

cd /opt/vc/src/hello_pi

make -C libs/ilclient

smart install libfreetype-devel

make -C libs/vgfont

make -C hello_audio

Update system configuration to fix the "failed to open vchiq instance" error (a reboot is required)

echo 'SUBSYSTEM=="vchiq", GROUP="video", MODE="0660"' \

> /etc/udev/rules.d/10-vchiq.rules

Test the audio:

cd /opt/vc/src/hello_pi/hello_audio

LD_LIBRARY_PATH=/opt/vc/lib ./hello_audio.bin # (analog output)

LD_LIBRARY_PATH=/opt/vc/lib ./hello_audio.bin 1 # (HDMI)

The omxplayer video player

OpenMAX is an open standard, royalty-free, cross-platform APIs that provides comprehensive streaming media codec and application portability to enable the authoring and accelerated playback of dynamic media on a wide variety of platforms and devices.

omxplayer is a commandline OMX video player specifically made for the Raspberry PI's GPU made by Edgar Hucek from the XBMC project.

Status: A working package for openmamba arm-devel is available.

Accelerated video and both analog and HDMI audio are working as expected.

The following udev rule is required to fix the "failed to open vchiq instance" error (a reboot is required)

echo 'SUBSYSTEM=="vchiq", GROUP="video", MODE="0660"' \

> /etc/udev/rules.d/99-vchiq-permissions.rules

Note: This system setting is not necessary is you install the openmamba package kernel-raspberrypi.

Installation instructions follows:

sudo smart install omxplayer-rpi

omxplayer -o hdmi /path/to/file.{mp4,avi}

The media player XBMC 12.2 "Frodo"

XBMC is an award-winning free and open source (GPL) software media player and entertainment hub for digital media. openmamba permit you to transform your RPi into a fully featured media player.

Note for developers: you can find here the documentation of the XBMC 12 python APIs.

sudo su -

smart install xbmc-rpi

echo "\

#!/bin/sh

export HOME=/home/liveuser

/usr/bin/xinit >/dev/null 2>&1" > /usr/sbin/xinit-xbmc

chmod 755 /usr/sbin/xinit-xbmc

echo "\

#!/bin/sh

/usr/bin/killall plymouthd >/dev/null 2>&1

/usr/lib/xbmc/xbmc.bin" > /home/liveuser/.xinitrc

chown liveuser. /home/liveuser/.xinitrc

# modify the file /etc/inittab

sed -i "s,x:5:respawn:login_manager,#&," /etc/inittab

echo "x:5:respawn:/usr/sbin/xinit-xbmc" >> /etc/inittab

reboot

# -or- with a more recent openmamba snapshot:

getent group xbmc > /dev/null || groupadd xbmc

getent passwd xbmc > /dev/null || useradd -m -d /var/lib/xbmc -g xbmc xbmc

usermod -G audio,video xbmc

chmod 4711 /usr/bin/Xorg # (now upstream)

systemctl stop lxdm.service

systemctl disable lxdm.service

echo "\

[Unit]

Description=XBMC Media Center

Conflicts=getty@tty1.service

After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service

[Service]

User=xbmc

Group=xbmc

ExecStart=/usr/bin/xinit /usr/lib/xbmc/xbmc.bin

Restart=always

[Install]

Alias=display-manager.service" > /lib/systemd/system/xbmc.service

systemctl enable xbmc.service

systemctl start xbmc.service

The multimedia streaming liquidsoap 1.1.1

liquidsoap 1.1.1, aka "the definite version 1" is a swiss-army knife for multimedia streaming, notably used for netradios.

sudo su -

smart install liquidsoap

# test (mp3 audio file via alsa):

liquidsoap 'output.alsa(single("/home/liveuser/audio.mp3"))'

Edimax EW-7811UN Wireless adapter

Installation

The Linux kernel module 8192cu.ko is automatically loaded by openmamba (under the hood, EW-7811Un runs Realtek's rtl8192cu chipset):

[liveuser@openmamba-rootfs-light ~]$ /sbin/lsmod

Module Size Used by

snd_bcm2835 15846 0

snd_pcm 77560 1 snd_bcm2835

snd_timer 19998 1 snd_pcm

snd 58447 3 snd_bcm2835,snd_timer,snd_pcm

snd_page_alloc 5145 1 snd_pcm

ipv6 278186 20

spidev 5224 0

evdev 9426 2

8192cu 489381 0

joydev 9316 0

leds_gpio 2235 0

led_class 3562 1 leds_gpio

spi_bcm2708 4510 0

i2c_bcm2708 3759 0

The lsmod command detects the Edimax nano USB Wireless adapter

[liveuser@openmamba-rootfs-light ~]$ lsusb

Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.

Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]

Bus 001 Device 005: ID 040b:2013 Weltrend Semiconductor

and as a final validation check, iwconfig display an available wireless interface:

wlan0 unassociated Nickname:"<WIFI@REALTEK>"

Mode:Managed Frequency=2.462 GHz Access Point: Not-Associated

Sensitivity:0/0

Retry:off RTS thr:off Fragment thr:off

Power Management:off

Link Quality:0 Signal level:0 Noise level:0

Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0

Tx excessive retries:0 Invalid misc:0 Missed beacon:0

[liveuser@openmamba-rootfs-light ~]$ /usr/sbin/iwconfig wlan0

Configuration

Update the postplug configuration:

# sed -i "s,\(NETWORK_NEWDEVICE=\).*,\1off," /etc/sysconfig/postplug

Create the file '/etc/sysconfig/network-scripts/ifcfg-wireless' as follow

ESSID="__ESSID__"

MODE=Managed

KEY_MGMT=WPA-PSK

TYPE=Wireless

BOOTPROTO=dhcp

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=no

NAME=wireless

UUID=__UUID__

ONBOOT=yes

The UUID value can be generated by running 'uuidgen'.

Then save the authentication key in '/etc/sysconfig/network-scripts/keys-wireless'.

echo "WPA_PSK='__WPA_ASCII_KEY__'" \

> /etc/sysconfig/network-scripts/keys-wireless

chmod 600 /etc/sysconfig/network-scripts/keys-wireless

Image backup and restore

If you want to preserve all of the data, you will probably have to create a disk image.

Here's a procedure working on Linux.

# fdisk -l /dev/sdb # -or- /dev/mmcblk0

Disk /dev/sdb: 3998 MB, 3998220288 bytes, 7809024 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Identificativo disco: 0x00000000

Dispositivo Boot Start End Blocks Id System

/dev/sdb1 * 63 80324 40131 c W95 FAT32 (LBA)

/dev/sdb2 80325 4192964 2056320 83 Linux

# echo "40131 + 2056320" | bc

2096451

today="$(date "+%Y%m%d")"

dd if=/dev/sdb bs=1024 count=2096451 | gzip -9 > rpi-openmamba-2dev-${today}.img.zip

You can use bzip2 or xz for better compression ratio or even zero-fill the free disk space:

# udisks --mount /dev/sdb2 # -or- /dev/mmcblk0p2

# df -k /media/rpi_openmamba

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sdb2 2023952 1632140 391812 81% /media/rpi_openmamba

# create the zero-filled file /zerofile (size = 391812 KB)

# dd if=/dev/zero of=/media/rpi_openmamba/zerofile bs=1024 count=391812

225280+0 records in

225280+0 records out

230686720 bytes (231 MB) copied, 4,2184 s, 54,7 MB/s

# rm -f /media/rpi_openmamba/zerofile

# udisks --unmount /dev/sdb2

And here's the linux command for restoring the rpi-openamamba image to a new SD card:

# gunzip --to-stdout rpi-openmamba-${today}.img.zip | dd of=/dev/sdb bs=65536

# -or-

# gunzip --to-stdout rpi-openmamba-${today}.img.zip | dd of=/dev/mmcblk0 bs=65536

Windows users should use Win32DiskImager. More informations can be found in the Raspberry Pi wiki.

Points under investigation

GStreamer on Raspberry Pi

The starting point is the following freedesktop article:

http://lists.freedesktop.org/archives/gstreamer-devel/2013-March/040163.html

gst-omx -- Gstreamer OpenMax IL wrapper plugin

The package gst-omx-rpi 1.2 for openmamba arm must be created - TODO

  • configure --with-omx-target=rpi

  • for linking the plugin to the native openmax support provided by /opt/vc/lib/libopenmaxil.so

When installed check with

gst-inspect-1.0 | grep omx

and run with the follow command

gst-launch-1.0 -v filesrc location=<filename> ! qtdemux ! h264parse ! omxh264dec ! eglglessink

Note: eglglessink (an EGL/GLES Video Output Sink Implementing the VideoOverlay interface) is part of the gst-plugins-bad package.

Modify the value of gpu_mem in /boot/config.txt if required (ex: gpu_mem=128).

Ephiphany on Raspberry Pi

The Ephiphany (aka GNOME Web) web browser has been developed and improved for the Raspberry Pi.

Epiphany brings a host of neat features to Raspberry Pi, including:

  • Much-improved HTML5 support

  • A JavaScript JIT

  • Hardware-accelerated video decoding

  • ARMv6-optimized blitting functions

  • Better interactivity during page loading

  • Faster scrolling

It needs to be packaged in rpm format for openmamba and used as a default web browser (replacing Midori).

Bug reports

Build error while compiling xbmc with -mfloat-abi=softfp: xbmc issues #2260

Fixed by git commit: bc772968ebaa98d37a0baa5d820d7b8abb57a8f3

Interesting internet links

OpenMAX -- an open standard, royalty-free, cross-platform APIs to enable the authoring and accelerated playback of dynamic media on a wide variety of platforms and devices.

  • OpenMAX™ is a royalty-free, cross-platform API that provides comprehensive streaming media codec and application portability

  • It enables accelerated multimedia components to be developed, integrated and programmed across multiple operating systems and silicon platforms

  • The OpenMAX API will be shipped with processors to enable library and codec implementers to rapidly and effectively make use of the full acceleration potential of new silicon - regardless of the underlying hardware architecture

QtonPi -- a n Embedded Linux platform plus SDK optimized for developing and running Qt 5 Apps on RPi:

First steps with the Raspberry Pi: