Centaurus Linux Development
From PHYTEC Wiki
Contents |
1 Host Setup
1.1 PTXdist
1.1.1 Shell
The default shell on Ubuntu is dash. Unfortunately, some of the packages can not be built using this shell. Rather, bash should be selected:
cd /bin sudo rm sh sudo ln -s bash sh cd -
1.1.2 General Information
PTXdist is a set of tools created by Pengutronix to help manage all of the BSP sources, from x-loader to the filesystem and its applications. It makes it easier for a user to manage everything for specific platforms and toolchains without manually repeating relatively complex commands every time it is necessary to build a new image.
1.1.3 Extracting Sources
The Phytec Centaurus Linux BSP uses PTXdist version 2011.11.0 which can be downloaded from [ptxdist-2011.11.0.tar.bz2]
The PTXdist packet has to be extracted in order to be built before the installation. In this example, we assume that the "ptxdist-2011.11.0.tar.bz2" file has been placed in the ~ (/home/<user>) directory.
~$ tar -jxvf ptxdist-2011.11.0.tar.bz2 ~$ cd ptxdist-2011.11.0
Now that the source has been extracted, the next step is to configure it for building.
1.1.4 Pre-Requisites
PTXdist requires that certain packages are installed on your development machine. To ensure that they are in place, run:
sudo apt-get install g++ libncurses-dev gawk flex bison texinfo gettext patch git
If you are running an older release of Ubuntu, it may indicate that there is no available package for git. To resolve this, run:
sudo apt-get install python-software-properties sudo add-apt-repository ppa:git-core/ppa sudo apt-get update
followed by the above apt-get install.
PTXdist checks for additional specific packages that must be installed before it can be successfully built. The following command begins a script that uses GNU autotools to help set up the environment for building the distribution.
~/ptxdist-2011.11.0$ ./configure
This command will automatically stop if it is missing a package, and tell you why and what package to install to continue with the initial setup. After successfully running the configure script, PTXdist is ready to be built and installed.
~/ptxdist-2011.11.0$ make ~/ptxdist-2011.11.0$ sudo make install
The install location is "/usr/local" by default, which is why the "make install" command must be run with root privileges. If another directory is preferred for the install, use the --prefix option when installing, but be sure to add the "bin/" directory of the installed tools in this new folder to your $PATH by modifying and sourcing ~/.bashrc.
source ~/.bashrc
Now that the install is complete, the PTXdist folder in the ~ (/home/<user>) directory can be removed, as well as the original archive, but this is not necessary.
Optional:
~/ptxdist-2011.11.0$ cd .. ~$ rm -rf ptxdist-2011.11.0*
1.1.5 Setup
The first time PTXdist is used, there are some setup properties that have to be configured. To run PTXdist's setup, use the following command:
~$ ptxdist setup
Once in the ptxdist setup, the only settings that should be modified are the User->Name and User->eMail. This is mainly for general logging purposes. If you wish to modify any other settings, please refer to the Getting Help section for a link to PTXdist documentation.
Since PTXdist works with sources only, it needs to grab source archives from the web using wget as it advances through its setup if they do not exist already.
1.2 Toolchains
In order to build images or applications for an embedded device, it is necessary to have a cross toolchain that will perform the necessary operations to compile code for a specified processor and system setup.
Each toolchain will have a modified GNU Compiler Collection (gcc) designed for the desired setup.
For example, the following are all toolchains contained in the OSELAS Toolchain-1.99.3.7 distribution:
arm-cortexa8-linux-gnueabi-gcc arm-1136jfs-linux-gnueabi-gcc arm-v5te-linux-gnueabi-gcc powerpc-603e-linux-gnu-gcc
1.2.1 Existing Toolchains
If a working toolchain is already installed for a given architecture, it is possible to use this instead of building an OSELAS Toolchain. Do note that since external toolchains have not been tested it is possible that they may not work properly across all environments.
An extra step needs to be taken if the plan is to use an external toolchain. By default, the software package will be set to check for the vendor toolchain that it was compiled with. In order to change this, use the following command inside the root directory of the BSP:
ptxdist platformconfig
Navigate to "architecture->toolchain" and clear the "check for specific toolchain vendor" field.
1.2.2 Building OSELAS Toolchains
Building the OSELAS toolchain requires the g++ package. To ensure that it is in place, run:
sudo apt-get install g++
Download [OSELAS.Toolchain-1.99.3.7] and place it in the ~ (/home/<user>) directory then perform the following commands:
~$ tar -jxvf OSELAS.Toolchain-1.99.3.7.tar.bz2 ~$ cd OSELAS.Toolchain-1.99.3.7 ~/OSELAS.Toolchain-1.99.3.7$ ptxdist select ptxconfigs/arm-cortexa8-linux-gnueabi_gcc-4.3.2_glibc-2.8_binutils-2.18_kernel-2.6.27-sanitized.ptxconfig ~/OSELAS.Toolchain-1.99.3.7$ ptxdist go
Optional:
~/OSELAS.Toolchain-1.99.3.7$ cd .. ~$ rm -rf OSELAS.Toolchain-1.99.3.7*
The toolchain is now built and installed in "/opt/OSELAS.Toolchain-1.99.3/arm-cortexa8-linux-gnueabi" and ready to be used for building the BSP.
Be sure to add /opt/OSELAS.Toolchain-1.99.3/arm-cortexa8-linux-gnueabi/gcc-4.3.2-glibc-2.8-binutils-2.18-kernel.2.6.27-sanitized/bin to your PATH variable.
1.2.2.1 Protecting Toolchains
It is recommended, although completely optional, to set the "/opt/OSELAS.Toolchain-1.99.3/arm-cortexa8-linux-gnueabi" directory and its contents as read-only to prevent accidental modifications to the toolchain.
2 Obtaining The phyFLEX-AM387x Source
The Phytec Centaurus Linux BSP source is maintained in a git repository. To checkout the code:
mkdir Centaurus cd Centaurus git init git pull git@github.com:phytec/Centaurus.git
Contact Russell Robinson to gain access to the git repository.
Note that the end user will not obtain source from the git repository. Rather it will be delivered in a tarball as with other Phytec BSPs. The tarball is made using the script MakeTarball found at the top level of the repository. The script excludes components which should not be included in the tarball (such as the script itself).
3 x-loader
The phyFLEX-AM387x board does not use x-loader. Rather, the initial boot file (MLO) is provided by either u-boot (today) or barebox (coming). Both of these bootloaders offer an early/minimum configuration to generate a binary which takes the place of x-loader.
The ROM loads MLO which loads either u-boot.bin or barebox.bin.
4 u-boot
u-boot is generated outside of the ptxdist structure. It is built in the directory u-boot.
To compile the initial bootloader:
make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm distclean make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm pcm050_min_sd make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm u-boot.ti cp u-boot.min.sd MLO
To compile u-boot:
make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm distclean make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm pcm050_config_nand make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm u-boot.ti
The configuration pcm050_config_nand used above has the environment saved in NAND. Currently NAND is not supported on the phyFLEX-AM387x board. As a result, the environment must be placed on the SD card used for boot. This is in held in a file called boot.scr
First, create a file boot.cmd with the following contents:
setenv bootfile linuximage
setenv filesys root.ext3
setenv console ttyO0,115200n8
setenv bootcmd run boot_mmc
setenv bootargs_mmc 'setenv bootargs rootdelay=2 console=${console} noinitrd rw mem=256M earlyprintk notifyk.vpssm3_sva=0xBF900000 ip=dhcp vram=50M ti814xfb.vram=0:48M,1:1M,2:1M root=/dev/mmcblk0p2 rootfstype=ext3 rootwait'
setenv boot_mmc 'run bootargs_mmc; mmc init; fatload mmc 1 ${loadaddr} ${bootfile}; bootm ${loadaddr}'
setenv gatewayip 192.168.0.1
setenv netmask 255.255.255.0
setenv ipaddr 192.168.0.205
setenv serverip 192.168.0.101
boot
To generate boot.scr from boot.cmd:
~/Centaurus/u-boot/tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n Ubuntu -d ./boot.cmd ./boot.scr
5 barebox
Barebox is under development and is not currently functional. u-boot should be used at this time. When barebox is completed, u-boot will no longer be required.
barebox is currently generated outside of the ptxdist structure. It is built in the directory barebox.
To compile the initial bootloader:
make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm clean make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm pcm050_xload_defconfig make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm barebox.bin.ift
The binary is barebox.bin.ift (needs to be renamed MLO).
To compile barebox:
make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm clean make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm pcm050_defconfig make CROSS_COMPILE=arm-cortexa8-linux-gnueabi- ARCH=arm barebox.bin
6 Building a BSP
6.1 Managing Configurations
PTXdist uses the KConfig files present throughout the BSP to allow users to easily configure individual settings and drivers.
NOTE: All target source code is located in the platform-phyFLEX-AM387x/build-target/ directory. For driver development and general settings or carrier board design it is necessary to know about the following three files to help integrate and modify features on the system:
linux kernel source is build-target/linux-2.6.37
linux-2.6.32/arch/arm/mach-omap2/board-phytec_pfla01.c is the board config file
6.1.1 Platform
The platform config contains the default settings for each platform including what bootloaders, kernels, and filesystem images are to be built. The settings for the platform are modified using the following command:
ptxdist platformconfig
As a user, it is rare to ever modify these settings, but it may be useful to view them.
6.1.2 Kernel
Use the kernel config to modify what drivers and support are included in a linux kernel build.
ptxdist kernelconfig
6.1.3 Root Filesystem
In the overall menuconfig it is easy to modify the applications and content that is built into the filesystem by toggling options in the base configuration. This allows both minimal and more complete filesystem builds to be created easily.
ptxdist menuconfig
6.2 Building Images with PTXdist
Building images with PTXdist is very simple. The command ptxdist go does all of the required steps to compile all of the sources and make changes only where necessary. ptxdist images builds the filesystem images.
ptxdist go ptxdist images
All images are then stored in platform-phyFLEX-AM387x/images.
7 SD Card Preparation
Currently, the phyFLEX-AM387x can only be booted from SD. To prepare an SD card to hold the necessary files, create a script with the following contents:
#!/bin/bash
if [ ! "$1" = "/dev/sda" ] ; then
unset LANG
DRIVE=$1
if [ -b "$DRIVE" ] ; then
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
mkfs.vfat -F 32 -n "boot" ${DRIVE}1
mke2fs -j -L "rootfs" ${DRIVE}2
fi
fi
With the SD card inserted in your development machine, run the script:
sudo myscript /dev/sdf
replacing sdf with the device corresponding to your SD card.
In order to mount the partitions that you just created, remove and reinsert your SD card.
8 Populating the SD Card
The following commands place the necessary components on the SD card.
cp u-boot/MLO /media/boot cp u-boot/u-boot.bin /media/boot cp boot.scr /media/boot cp platform-phyFLEX-AM387x/images/linuximage /media/boot sudo rm -r /media/rootfs/* sudo tar zxf platform-phyFLEX-AM387x/image/root.tgz -C /media/rootfs
9 Usage Notes
9.1 Console
The serial console is the top connector at X3 and should be connected at 115200, 8N1.
9.2 SD Card
- The SD card is inserted in SD0.
- If the board fails to initiate boot, you can check the hardware and minicom setup by powering the device with no SD card in place. This should result in C characters being displayed on the console.
9.3 Graphics
- The /usr/bin directory on the target includes several 2D/3D graphics demo applications, such as OGLESEvilSkull.
- By default, the device is setup to display graphics on the 5" LCD panel. If you which to change this to DVI/HDMI, see the notes in the script /etc/init.d/graphics. The notes also indicate settings for different resolution monitors and the 7" LCD panel.
- If the LCD module is set for PWM control of brightness (switch 3 on, others off), it can be adjusted:
echo N > /sys/devices/platform/omap_pwm_leds/leds/lcd/brightness
where N is from 0 to 255.
9.4 USB
- Limitation: The processor senses the USB ID pin on the OTG port in order to decide whether it should act as a device or as a host. However, the processor doesn't seem to notice changes in this pin on-the-fly. For host operation on the OTG port, the OTG cable must be in place (or a jumper on JP18) before the device is powered up.