Alberto Embedded & Open experience

Notes on my experience on Open Source Embedded Systems

Posts Tagged ‘kernel

Developing kernel on a Virtual Machine (the solution)

leave a comment »

I am working now on Ubuntu Karmic Koala.

As I said in my previous post, Qemu is a complete platform emulator that can emulate the Integrator ARM machine platform (CPU and devices!).

In Karmic Koala the latests Qemu version (0.11.0) is shipped within Ubuntu repositories so with this line we can install it:

# sudo apt-get install qemu qemu-kvm qemu-kvm-extras

ARM test images

From the Qemu home page we can download a Linux 2.6 ARM example image builded by Paul Brook and extracting it in $PRJROOT/images, we can find the README file where it is written how to launch the test platform:

# cp DownloadDirectory/arm-test-0.2.tar.gz $PRJROOT/images
# cd $PRJROOT/images
# tar -xvf arm-test-0.2.tar.gz
# cd arm-test
# cat README

So, with or without the graphical interface we can test the qemu arm installation with the followings:

# qemu-system-arm -kernel zImage.integrator -initrd arm_root.img
# qemu-system-arm -kernel zImage.integrator -initrd arm_root.img \
  -nographic -append "console=ttyAMA0"

A suitable Linux config file

Over the test purpose , executing the test image can give the kernel configuration file stored in /proc/config.gz ! so:

# qemu-system-arm -kernel zImage.integrator -initrd arm_root.img \
  -nographic -append "console=ttyAMA0"
Uncompressing Linux...............................................
........................... done, booting the kernel.
Linux version 2.6.17-rc3 (paul@wren) (gcc version 4.1.0 (CodeSourcery ARM))
 #53 Thu May 4 15:05:18 BST 2006
CPU: ARM926EJ-Sid(wb) [41069265] revision 5 (ARMv5TEJ)
Machine: ARM-IntegratorCP
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-through cache
CPU0: I cache: 4096 bytes, associativity 4, 32 byte lines, 32 sets
CPU0: D cache: 65536 bytes, associativity 4, 32 byte lines, 512 sets
Built 1 zonelists
Kernel command line: console=ttyAMA0
PID hash table entries: 1024 (order: 10, 4096 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total


Log in as root with no password.
qemu login: root
# cp /proc/config.gz .
# tar -xvf config.gz
# vi config.gz

With this file we can configure the mainline linux kernel! (copying from screen, copying within net, scrolling the options with a near mainline make menuconfig window).

ARMv5te Toolchain to build the kernel

The machine emulated by qemu-arm is based on the core ARMv5te , so I need the correct toolchain for build all the necessary code.

The Pengutronix OSELAS environment can do that in the OSELAS toolchain project. Similarly at what described in Initializing a Linux Embedded Development Host Machine moving in $PRJROOT/build-tools/OSELAS.Toolchain- we can select the suitable ptxdist configs with:

# cd $PRJROOT/build-tools/OSELAS.Toolchain-
# ls ptxconfigs/
# ptxdist select ptxconfigs/\
# ptxdist menuconfig

In the menuconfig, all can live as it is but in “misc->prefix for installation” we can choose $PRJROOT/tools where $PRJROOT must be manually extended. So with:

# ptxdist go

A part from minor dependencies that we can solve installing software with apt-get, the toolchain is built and the correct prefix will be:


If we assign the environmental variable CROSS_COMPILE=CROSS_COMPILE_OSELAS_v5 the kernel configured by the upper config file and compiled with this toolchain is a good kernel to execute within the qemu-system-arm emulator!

A suitable Root Filesystem

Ok we have a good kernel ad a small initrd filesystem, but we have to develop application to run in the emulated device!

We can use the OSELAS.BSP Phytec phyCORE project installed following the description in Initializing a Linux Embedded Development Host Machine.

Download the platform_config file platformconfig-qemu and the ptxconfig one ptxconfigThiny (that is the normal ptxconfig removing all graphic subsystem for a speedier compilation)

Every two configuration file must be placed in $PRJROOT/build-BSP/OSELAS.BSP-Phytec-phyCORE-12-1/configs so with:

# cd $PRJROOT/build-BSP/OSELAS.BSP-Phytec-phyCORE-12-1/
# ptxdist select configs/ptxconfigThiny
# ptxdist platform configs/platformconfig-qemu
# ptxdist toolchain $CROSS_COMPILE_OSELAS_v5
# ptxdist go
# ptxdist images

In  $PRJROOT/build-BSP/OSELAS.BSP-Phytec-phyCORE-12-1/platform-phyCORE-qemu/images/ we will find the root.ext2 image, ready to be the SD/MMC image of the qemu device!

Running qemu

If in the $PRJROOT directory we create the images/phyCORE directory and we put all the necessary:

# mkdir -p images/phyCORE
# cp (kernel_path)/arch/arm/boot/zImage images/phyCORE/
# cp $PRJROOT/build-BSP/OSELAS.BSP-Phytec-phyCORE-12-1/platform-phyCORE-qemu/images/root.ext2\

then we can start qemu:

# qemu-system-arm -kernel images/phyCORE/zImage -sd images/phyCORE/root.ext2 \
  -nographic -append "console=ttyAMA0 root=/dev/mmcblk0"


In results we have a complete developing environment: emulator, toolchain, kernel, software ecosystem.

Kernel modification that do not deal with the hardware abstraction layer can be well developed in the emulator and tested by ad-hoc software inserted in the phyCORE-qemu distribution!


Written by Alberto!

25/11/2009 at 5:01 pm

Android subsystem is gonna die

with 3 comments

As you can see on linux webgit log the Android subsystem resident on mainline kernel developing tree is gonna die:

Staging: android: mark subsystem as broken

It’s causing lots of build errors, so just mark it as broken.  It is
scheduled to be removed in 2.6.33 anyway.

Signed-off-by: Greg Kroah-Hartman <>

A BROKEN subsystem is a piece of kernel code that the build system do not visit in the build process.

The true problem is that Google has stopped to support mainline code leaving it at an embryonic state: no Coding Style corrections and no update on new kernel API changes.

Another important thing is that the android subsystem that live now in mainline kernel is incomplete: many parts of Google layer were not merged with mainline linux, producing an eternal incomplete subsystem.

What the mess with this? Why the mainline part of Android is important? There is always the android branch hosted by Google no?

Yes is true, but what about the next device porting? what about quality on device porting? A mainline architecture support code is controlled and accepted by a number of Community Developers that know better than a lot of people how this things must be done, and sure, also the better developer make mistakes!

Developing a new hardware platform in the Google android branch make this job harder and full of traps.

The aim of my job now is to recover this situation, taking the present mainline android subsystem on the right way in terms of quality and readability and then completing it with the missing things!

So, good Job Alberto!

Written by Alberto!

23/11/2009 at 6:11 pm

Compilare il kernel Atrmark 2.6.26 per armadillo 500

leave a comment »

Ecco le maggiori info 🙂
Cercando in rete ho scoperto che su armadillo 500-FX è già ststo portato android con kernel 2.6.26.
Dato che le due macchine sono così simili a livello hardware mi è parso così strano che il kernel più aggiornato disponibile per armadillo 500 sia il solo 2.6.18.. Quindi ho cercato tra i repository dell’armadillo 500-FX i sorgenti del kernel con l’intenzione di portarlo su armadillo-500.
Il kernel disponibile era proprio il 2.6.26 e con gioia ho scoperto che esisteva anche il file di configurazione per armadillo 500! nonché tutti i sorgenti specifici della CPU board e driver della board di sviluppo!

Bene! Allora i passi per il deploiment:
Scaricare e decomprimere i sorgenti del kernel dai repository atmark:

$ wget
$ tar -xvf linux-2.6.26-at3.tar.gz

Configurare e compilare i sorgenti per armadillo con l’aiuto di android:

$ cd linux-2.6.26-at3
$ make armadillo500_defconfig
$ export ARCH=arm
$ export CROSS_COMPILE=[basePathAndroid]/cupcake/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
$ make

Nota: ho usato la toolchain di cupcake, credo che anche con il branch master non abbia problemi..
Deploiment nella scheda:
In ./arch/arm/boot sono stati creati i file immagine del kernel: Image e compresso zImage
quindi copiando zImage nella cartella /tftp e scaricandolo nella flash attraverso hermit come nei post precedenti (indicando il nome di file zImage eh!) al reboot tutto funziona correttamente 🙂

Nota: il comando tftpdl da hermit della scheda, all’attivazione della periferica di rete è come se alcune volte non avesse il link attivato.. rimanendo in attesa della risposta dal server per il download.
Workaround: se da workstation eseguo il ping al’indirizzo impostato per la board il download dell’immagine, prima in attesa, parte contemporaneamente.

Written by Alberto!

23/03/2009 at 8:58 am

Porting del Kernel Android 2.6.27 su Armadillo 500

leave a comment »

Link di riferimento:
Specifiche della board:
Specifiche del processore:
Area di download sw armadillo:

Bene Bene! Prima fase reale del mio progetto: Porting del kernel più aggiornato possibile nella board di sviluppo Atmark Armadillo 500! Questa monta un processore Freescale i.MX31L con set di istruzioni ARMv6.
Ho ordinato il mio fantastico libro Building Embedded Linux Systems, Second Edition che spero illuminerà la mia strada ma nell’attesa che arrivi cerco di individuare le modifiche fatte al kernel “vanilla” per supportare la scheda nella versione presente sul sito atmark.

Importante: Questi Giapponesi scrivono solo in giapponese! Servirà la mail che ho inviato per la richiesta di doc inglese?

Altro: Il kernel a disposizione è un 2.6.18 debian etch1 sssoooo old! 🙂

Written by Alberto!

19/03/2009 at 9:03 am

Sul repository locale del kernel

leave a comment »

Nella cartella “master/prebuilt/android-arm/kernel/” troviamo un bellissimo file “PREBUILT” che recita:

To rebuild the emulator kernel:

% git clone git:// kernel
% cd kernel
% export ARCH=arm
% export CROSS_COMPILE=arm-eabi-
% make goldfish_defconfig
% make

If kernel/common.git is mapped into your repo client, you can
just built it from there instead of re-cloning it.

ehm.. un pò da adattare dato che non menziona il branch android-goldfish-2.6.27 (nel branch common del kernel non c’è il file goldfish_defconfig) e che la toolchain di crosscompilazione non è (per ora) nel path d’esecuzione principale (non abbiamo modificato PATH).
Ma almeno abbiam trovato delle informazioni 🙂

Written by Alberto!

07/03/2009 at 11:29 am

Posted in android, linux-arm

Tagged with , , ,

Il nostro nuovo Android sull’emulatore!!

leave a comment »

Bene bene, compilato il Kernel 2.6.27 per la macchina goldfish eseguiamo il tutto sull’emulatore!
Raccimoliamo tutti i file di output dei processi di build necessari che sono:

  • Kernel, l’immagine compressa:
  • Android, i file immagine per ramdisk userdata e system nella cartella:

Io ho copiato la zImage nella cartella di output di android:

$ cd PATH_GIUSTO/alberdroid/master/out/target/product/generic/
$ cp PATH_GIUSTO/alberdroid/kernel-goldfish/.repo/manifests/arch/arm/boot/zImage .

e via all’emulatore!

$ emulator -system . -kernel zImage -show-kernel

Così l’emulatore cercherà i file ramdisk.img userdata.img e system.img nella cartella corrente (-system .), utilizzerà zImage come immagine del kernel (..non utilizzare l’immagine Image ma quella compressa zImage) e nella shell corrente mostrerà l’output del kernel!

Written by Alberto!

07/03/2009 at 10:57 am

Kernel per Android..

leave a comment »

Link di riferimento:
Allora, la sottocartella kernel esiste in master! e perché non viene compilata????
Urc! solita ricerca in rete e vien fuori che la versione che ho non è propriamente la versione per goldfish -> attiviamo il branch giusto!
..consiglio, creiamo un’altra directory per il nostro kernel:

$ mkdir -p alberdroid/kernel-goldfish
$ cd alberdroid/kernel-goldfish
$ repo init -u git:// -b android-goldfish-2.6.27
$ repo sync

Solito tempo che passa…..

Edit: perché ha salvato i sorgenti in .repo/manifests ??
cmq, dal precedente codice shell

$ cd .repo/manifests

e si continua con:

$ export ARCH=arm
$ export CROSS_COMPILE=PATHGIUSTO/alberdroid/master/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
$ make goldfish_defconfig
$ make

Verrà così creato un buon kernel per l’emulatore 🙂

Written by Alberto!

06/03/2009 at 4:15 pm

Posted in android

Tagged with , , , ,