Freescale TWR-MPC5125/Openembedded

Create Linux Distributions with Openembedded for Freescale TWR-MPC5125.

About this tutorial
This tutorial describes all the steps which are needed to create the linux kernel and different root file systems for the board Freescale TWR-MPC5125 with Openembedded, a build framework for embedded Linux. The Linux Distribution Angstrom, which is part of Openembedded, is used here to create the linux kernel and to create several root file systems:


 * a minimal-image for testing purposes,
 * OPIE (Open Palmtop Integrated Environment), a graphical user interface for PDAs,
 * GPE (GPE Palmtop Environment), a graphical user interface for PDAs and
 * Xfce, a lightweight desktop environment.

The minimal-image uses about 35MB RAM at runtime on the Freescale TWR-MPC5125. OPIE uses about 51MB RAM at runtime. GPE uses about 61MB RAM at runtime. Xfce uses about 95MB RAM at runtime.

Openembedded
You can find further explanations for the following steps in the Openembedded wiki: http://wiki.openembedded.org/index.php/Main_Page.

How to install Openembedded on Gentoo Linux: http://www.openembedded.org/index.php/OEandYourDistro#Gentoo_instructions

How to get started: http://www.openembedded.org/index.php/Getting_started

Advanced configuration settings: http://www.openembedded.org/index.php/Advanced_configuration

User manual: http://docs.openembedded.org/usermanual/usermanual.html

Git Paths
The source code of the Openembedded project is saved in git-repositories: http://cgit.openembedded.org/cgit.cgi

The source code of the bitbake application: http://cgit.openembedded.org/cgit.cgi/bitbake/

You can look at each source file: http://cgit.openembedded.org/cgit.cgi/bitbake/tree/

The configuration files and the defintions of the software packages: http://cgit.openembedded.org/cgit.cgi/openembedded/

You can look at each file: http://cgit.openembedded.org/cgit.cgi/openembedded/tree

Config files for the supported hardware: http://cgit.openembedded.org/cgit.cgi/openembedded/tree/conf/machine

Patches for openembedded: http://patches.openembedded.org/project/oe/list/

Apply patches: http://wiki.openembedded.net/index.php/Patchwork

Folder Names
These folders are used for

Bitbake:

Openembedded:

Project configuration:

Build:

NFSRoot:

Source:

The application bitbake is installed into the folder.

The project definitions of openembedded are installed into the folder.

Source files are downloaded by bitbake into the folder.

The configuration files for the current project are created in the folder.

bitbake creates all files in the folder.

The created root file systems are extracted in the folder and can be mounted by the target via NFS.

The current project is just called test01.

Define environment variables:

Install Software for Openembedded
Before you can install and use openembedded, you need to install some software. At first set the use flags.

Emerge the software, which is missing.

It is possible that portage requests that some other use flags are set too. psyco is not available for gentoo amd64 i.e. x86_64.

Now you can check, if all needed applications exist

texi2pdf is part of the package texinfo.

Install Bitbake
Create folders and download the branch 1.12 of bitbake:

The size of this folder is about 3MB.

Install Openembedded
Create folders and download the branch master of openembedded:

The size of this folder is about 150MB.

Update
From time to time you need to update your local versions of openembedded and bitbake.

Update Openembedded

Update Bitbake

Install the Patch for the Board Freescale TWR-MPC5125
Because Openembedded has so far no configuration files for the board Freescale TWR-MPC5125, some patches need to be applied.

The patches have been released on the openembedded-devel mailing list:

[mpc5125-twr 1/2] New machine mpc5125-twr, Freescale TWR-MPC5125-KIT http://patches.openembedded.org/patch/2091/ or http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg17818.html

[mpc5125-twr 2/2] Linux kernel for mpc5125-twr http://patches.openembedded.org/patch/2093/ or http://lists.linuxtogo.org/pipermail/openembedded-devel/2011-April/031794.html

[PATCH] gphoto2: search libdir in sysroot http://patches.openembedded.org/patch/1809/ or http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg17416.html. This patch could be needed, if you are using a x86_64 host system. There is nothing mpc5125-twr specific in this patch.

Because the patches have been published on the Openembedded patch list http://patches.openembedded.org/project/oe/list they can be easily applied:

Create the configuration file
For each project you should create a project folder with a configuration file. Here it is. Almost all settings for your project are defined in the file. At first use the file as template for the  file.

Then adjust the configuration file

Bitbake downloads source files into and creates md5 files in the folder which is specified by the environment variable DL_DIR. Portage and bitbake download the same source files. You can define DL_DIR to point to the source file repository of portage which is by default. This avoids downloading a file two times by portage and bitbake. Make sure that you have access permissions to this folder. If you don't want to use the same download folder, then choose some other folder name for DL_DIR.

Continue adjusting the local.conf file. Delete the last line of the file, otherwise you will get an error message. The value of the variable DISTRO is the name of a distribution. The allowed values are the file names without suffix in the folder.

The value of the variable MACHINE</tt> is the name of a target board or target system. The allowed values are the file names without suffix in the folder.

Define distribution and machine. Here fits best to Freescale TWR-MPC5125. Clean work folder after succesfully building.

Environment setup
Before you can call bitbake</tt>, you need to setup the environment. Because each project can have its own environment, you should create a script in the project folder.

Call the script file only once, before you start using bitbake. The prompt will indicate, if you have called it or not.

All the settings in and  are independent of the environment variables MY_OPENEMBEDDED, MY_BITBAKE, MY_SRC, MY_NFSROOT, MY_PROJECT</tt>. You don't need them to run bitbake.

Build Image
You can be in any folder you like. You should be logged in as a common user. You don't need root privileges most of the time. Start building an image

Build Configuration: BB_VERSION       = "1.12.0" METADATA_BRANCH  = "master" METADATA_REVISION = "6b9a381" TARGET_ARCH      = "ppc" TARGET_OS        = "linux" MACHINE          = "mpc5125-twr" DISTRO           = "angstrom" DISTRO_VERSION   = "v20110406" At first all cross-tools (called native in openembedded), e.g. the cross-compiler are build and installed in the folder. Then the cross-tools are used to build all needed software packages. Root file images and the kernel images can be found in the folder

These are the files which are created: 7152 Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.rootfs.jffs2 10668 Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.rootfs.tar 6256 Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.rootfs.tar.gz 6204 modules-2.6.29-r11-mpc5125-twr.tgz 2448 uImage-2.6.29-r11-mpc5125-twr.bin 12 uImage-2.6.29-r11-mpc5125-twr.dtb These are the links which are created: minimalist-image-mpc5125-twr.jffs2 -> Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.rootfs.jffs2 minimalist-image-mpc5125-twr.tar -> Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.rootfs.tar minimalist-image-mpc5125-twr.tar.gz -> Angstrom-minimalist-image-eglibc-ipk-v20110406-mpc5125-twr.tar.gz uImage-mpc5125-twr.bin -> uImage-2.6.29-r11-mpc5125-twr.bin uImage-mpc5125-twr.dtb -> uImage-2.6.29-r11-mpc5125-twr.dtb

Linux Kernel
The board is already shipped with a Linux kernel in flash. U-boot can load the kernel from a TFTP server or from flash. Here we load the kernel from a TFTP server.

Create the Root File System
Take the rootfs image and extract it into another folder. The extraction needs to be done with root privileges.

Extract the kernel modules into the root file system.

The rootfs can be now mounted via NFS.

nfs server
Configure the nfs server to export the rootfs

Prepare the Board
You need a monitor, a USB mouse, a USB keyboard and a USB Hub. Only the TWR-MPC5125 MPU module is used.
 * Connect the monitor to the HDMI port of the TWR-MPC5125 MPU module. E.g. you can use a HDMI to DVI-D cable. The resolution has been 640x480 60Hz during the tests.
 * Connect the mouse and the keyboard to a USB hub. Connect the USB hub to the Mini-AB connector on the board which is next to the HDMI connector. Use the Mini-B to receptable A cable.
 * Connect a USB cable to your host computer and to the Mini-B connector next to the SDHC card slot. This is the Serial-to-USB bridge.
 * Connect an Ethernet cable to the board.
 * Connect a 5V power supply to the board, if it is not already provided by the USB cable to your host computer.

Serial Port
There is a Serial-to-USB bridge on the board, which connects the serial port PSC0 to a USB port. When the Mini-B connector next to the SDHC card slot on the board is connected to a USB port of the host, then this message appears in /var/log/messages: usb 1-1.2: new full speed USB device using ehci_hcd and address 5 cdc_acm 1-1.2:1.0: This device cannot do calls on its own. It is not a modem. cdc_acm 1-1.2:1.0: ttyACM0: USB ACM device usbcore: registered new interface driver cdc_acm cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters Install the terminal application cu</tt> on your host system.

Now open a terminal to the board

U-boot
Use the Serial-to-USB bridge to connect to the serial port PSC0 of the CPU. Boot the board and enter the command line of u-boot. Define the IP address of the board, the IP address of the server and the path for nfsroot. Check the current settings of the variables which are used to boot the board.

Change the variables which are used to boot the board.

Define the command to load the kernel from a TFTP server.

Define the nfsroot path and the bootcmd argument. When you want to use a different nfsroot, you need to change only rootpath and bootargs.

Save the new environment and boot again.

Target Log
Linux: Output when the board is booted and Linux kernel is started.

minimal-image: Output of the minimal-image specific part, when board is booted. .

Status
The image seems to work with one exception. Unfortunately getty reports a Segmentation fault, when started. Therefore login via the devices /dev/tty1 or /dev/ttyPSC0 is not possible. You can login to the board only with ssh via Ethernet.

No password is needed.

Problem with getty
When getty</tt> is called in, it is respawned. You can test it on the command line:

Segmentation fault Output on the display console getty:ioctl TIOCSPGRP call failed: Inappropriate ioctl for device For the device /dev/ttyPSC0 a segmentation fault occurs too.

Segmentation fault

Image opie-image
Only the differences to are described.

Build Image opie-image
You can be in any folder you like. You should be logged in as a common user.Call the script only once.

Start building the image.

Root file images and the kernel images can be found in the folder

Create the Root File System
Take the rootfs image and extract it into another folder. The extraction needs to be done with root privileges.

Extract the kernel modules into the root file system.

The rootfs can be now mounted via nfs.

NFS Server
Configure the NFS server to export the rootfs

U-boot
Change the path of the root file system and the bootargs.

Save the new environment and boot the board again.

Target Log
opie-image: Output of the opie-image specific part, when board is booted and GUI is started. .

Status
The GUI of OPIE appears on the screen and can be controlled by the mouse and the keyboard. A small black rectangle appears in the upper left corner. Several errors like missing group names are reported, when booting, but the GUI appears and can be used. This is just a starting point for using OPIE. Unfortunately getty reports a Segmentation fault, when started. Therefore login via the devices /dev/ttyPSC0 or /dev/tty1 is not possible.

Screenshots
A screenshot can be found at http://en.wikipedia.org/wiki/OPIE_user_interface.

Image x11-gpe-image
Only the differences to are described.

Build Image x11-gpe-image
You can be in any folder you like. You should be logged in as a common user.Call the script only once.

Start building the image.

Root file images and the kernel images can be found in the folder

Create the Root File System
Take the rootfs image and extract it into another folder. The extraction needs to be done with root privileges.

Extract the kernel modules into the root file system.

The rootfs can be now mounted via nfs.

NFS Server
Configure the NFS server to export the rootfs

U-boot
Change the path of the root file system and the bootargs.

Save the new environment and boot the board again.

Target Log
x11-gpe-image: Output of the x11-gpe-image specific part, when board is booted and GUI is started. .

Status
The GUI of GPE appears on the screen and can be controlled by the mouse and keyboard. A small black rectangle appears in the upper left corner of the display. Several errors like missing group names are reported, when booting, but the GUI appears and can be used. This is just a starting point for using GPE. Unfortunately getty reports a Segmentation fault, when started. Therefore login via the devices /dev/ttyPSC0 or /dev/tty1 is not possible. You can login to the board with ssh via Ethernet.

Screenshots
Screenshots can be found here http://gpe.linuxtogo.org/gallery/gallery/view_album.php?set_albumName=Applications.

Image xfce46-image
Only the differences to are described.

Build Image xfce46-image
You can be in any folder you like. You should be logged in as a common user.Call the script only once.

Start building the image.

Root file images and the kernel images can be found in the folder

Create the Root File System
Take the rootfs image and extract it into another folder. The extraction needs to be done with root privileges.

Extract the kernel modules into the root file system.

The rootfs can be now mounted via nfs.

NFS Server
Configure the NFS server to export the rootfs

U-boot
Change the path of the root file system and the bootargs.

Save the new environment and boot the board again.

Start Xfce
Login as root, check the current settings of the nameserver and adjust them, if needed.

Start the GUI.

Target Log
xfce46-image: Output of the xfce46-image specific part, when board is booted and GUI is started. .

Status
The GUI of Xfce appears on the screen and can be controlled by the mouse and keyboard. A small black rectangle appears in the upper left corner of the display. Several errors like missing group names are reported, when booting, but the GUI appears and can be used. X server reports serveral warnings but works. This is just a starting point for using xfce. Unfortunately getty reports a Segmentation fault, when started. Therefore login via the devices /dev/ttyPSC0 or /dev/tty1 is not possible. You can login to the board with ssh via Ethernet.

Workaround when fetch fails
When you use the portage distfiles folder for downloads and bitbake fails while fetching even when the file is there, this has helped usually:

Start bitbake again.

Workaround for cannot stat error
When you start bitbake the current date is saved in some folder names. When bitbake fails and you restart it on another day, the the folder names are different. You need to copy the files from the old folder to the new folder like in this example and then start bitbake again: install: cannot stat `/MyOE/tmp/test01/work/mpc5125-twr-angstrom-linux/angstrom-version-1_v20110406-r6/lsb_release': No such file or directory NOTE: package angstrom-version-1_v20110406-r6: task do_install: Failed

Bitbake Reports an Error
You are using the master branch of openembedded, which is constantly changing. This is the latest version of openembedded. If the latest version cannot be build, you can try to use the latest tested version. Currently this is the version with the tag 021312cbea3bd07f2ec8591d667998c9c7b28b3a</tt>.

Save all your changes, which you don't want to lose, before you continue. Change to the tag 021312cbea3bd07f2ec8591d667998c9c7b28b3a</tt>.

Save and remove tracked files.

Delete untracked files and directories dry-run

Delete untracked files and directories

Check the current status.

Now install the patches for mpc5125-twr and try to build the images in an empty directory again.