About Docker

In child words, Docker is a tool to ease running « any » applications on « any » systems. Of course there is conditions and rules to follow, but to start using Docker there is no need to bother yet.

The docker story starts as root like that :

[root@localhost ~]# yum install docker
Yum command has been deprecated, redirecting to '/usr/bin/dnf install docker'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'

Last metadata expiration check: 0:43:54 ago on Sat Aug 13 08:51:04 2016.
Dependencies resolved.
 Package Arch Version Repository Size
 docker x86_64 2:1.10.3-26.git1ecb834.fc24 updates 6.7 M
 docker-selinux x86_64 2:1.10.3-26.git1ecb834.fc24 updates 74 k
 docker-v1.10-migrator x86_64 2:1.10.3-26.git1ecb834.fc24 updates 1.9 M

Transaction Summary

Total download size: 8.7 M
Installed size: 35 M
Is this ok [y/N]:

And once you say yes … you are already half way, docker is terribly easy to use ..

You need to start the service first:

# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
# systemctl start docker

And then you can dowload an image:

> sudo docker pull "atlassian/agent-setup-git:latest"

Trying to pull repository docker.io/atlassian/agent-setup-git ... 
latest: Pulling from docker.io/atlassian/agent-setup-git
6c123565ed5e: Pull complete 
2a3a5d549d2b: Pull complete 
Digest: sha256:e1d2f19b296912e43eed9ea814dcfddbe68a23256791663e53316a0127ddf375
Status: Downloaded newer image for docker.io/atlassian/agent-setup-git:latest

And you can run your first command in this docker:

> sudo docker run "atlassian/agent-setup-git:latest" ls 


You can also start using docker configuration file which look like that:

FROM fedora:24

RUN dnf install -y gtk2-devel cmake libXmu-devel
RUN mkdir /toto
COPY . /toto/
RUN ls /toto

And building an image like that:

> sudo docker build -f DockerFile -t docker.io/bodman/test:fedora24 ./

Docker tends to generate a lot of files to work. The best is to manage where those files are created. With Fedora, in the configuration file /etc/sysconfig/docker find the OPTIONS parameter and add -g /path/to/store/docker/files argument.

To see infos about docker :

docker info

To increase the maximum size of docker images add in the file /etc/sysconfig/docker-storage :

DOCKER_STORAGE_OPTIONS= – -storage-opt dm.basesize=30G



How to check when a division by zero happends (x86)

This piece of code was gold for me (thanks to Harry !)  :

    uint32_t mxcsr;
    uint32_t mask = 0;
    //mask |= 1 << 12; // precision mask
    mask |= 1 << 11;   // under flow mask 
    mask |= 1 << 10;   // over flow mask
    mask |= 1 << 9;    // division by zero mask
    mask |= 1 << 7;    // invalid operator mask
    mask = ~mask;
    asm volatile ("stmxcsr %0" : "=m"(mxcsr));
    mxcsr &= mask;
    asm volatile ("ldmxcsr %0" : : "m"(mxcsr));

When you add it, then any division by zero (or other type of error you had to the mask) will trigger an floating point exception. This can save you a day (or two)…

Building Android 4.4_r1 on Fedora 22

First, I create a specific user to build Android :

useradd builder
passwd builder
su - builder

Download the download tool :

mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH

Download the repo :

mkdir -p ~/android/source
cd ~/android/source
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1

Download the source (very long … ) :

repo sync

Prepare the build :

source build/envsetup.sh
lunch aosp_arm-userdebug
export PATH=/usr/java/jdk1.6.0_45/bin/:$PATH

In the file « build/core/main.mk » remove the test which want a specific version of GNU make. This is not required. However the JDK 1.6 is required !

Start the build (less than 2 hours …) :


If it worked you just need to run the emulator !

DISPLAY=:0 emulator

You may need to share your standard user’s DISPLAY with the builder user :

xhost +SI:localuser:builder

Or the Android kernel in command line :

emulator -sysdir ./out/target/product/generic/  -kernel ./prebuilts/qemu-kernel/arm/kernel-qemu-armv7 -no-window -show-kernel -shell

Source : http://source.android.com/source/initializing.html

Compiling Qemu v0.9.1

Easy :

git clone git://git.qemu-project.org/qemu.git
git checkout v0.9.1

If you get this error :

block-raw-posix.c:242: error: `SIGUSR2' undeclared here (not in a function)
block-raw-posix.c: In function `qemu_aio_init':
block-raw-posix.c:264: error: storage size of 'act' isn't known
block-raw-posix.c:268: warning: implicit declaration of function `sigfillset'
block-raw-posix.c:271: warning: implicit declaration of function `sigaction'
block-raw-posix.c:264: warning: unused variable `act'
block-raw-posix.c: In function `qemu_aio_wait_start':
block-raw-posix.c:348: warning: implicit declaration of function `sigemptyset'
block-raw-posix.c:349: warning: implicit declaration of function `sigaddset'
block-raw-posix.c:350: warning: implicit declaration of function `sigprocmask'
block-raw-posix.c:350: error: `SIG_BLOCK' undeclared (first use in this function)
block-raw-posix.c:350: error: (Each undeclared identifier is reported only once
block-raw-posix.c:350: error: for each function it appears in.)
block-raw-posix.c: In function `qemu_aio_wait':
block-raw-posix.c:364: warning: implicit declaration of function `sigwait'
block-raw-posix.c: In function `qemu_aio_wait_end':
block-raw-posix.c:370: error: `SIG_SETMASK' undeclared (first use in this function)
make: *** [qemu-img-block-raw-posix.o] Error 1

One way to solve it is to change the source :

--- a/block-raw-posix.c
+++ b/block-raw-posix.c
@@ -44,13 +44,14 @@
 #ifdef __linux__
 #include <sys/ioctl.h>
 #include <linux/cdrom.h>
 #include <linux/fd.h>
+#include <signal.h>



ARM bare metal example

Here is the simplest example of bare metal program I know. This is a mix of examples I found, because for some obscure reasons, none of these sources provided a working example with a recent GNU GCC. I’ll only give the source for each file and a makefile.


.globl _start
 .extern STACK_TOP
 ldr sp, =STACK_TOP
 bl start
 b 1b
 .size _start, . - _start


 /* QEMU loads the kernel in Flash here. I strongly suggest you look at the
 * memory map provided in the CoreTile TRM (see below).
 . = 0x80010000 ;
/* Make sure our entry stub goes first */
 .stub : { _start.o(.text) }
 .text : { *(.text) }
 .rodata : { *(.rodata) }
 .data : { *(.data) }
 .bss : { *(.bss COMMON) }
 . += 0x10000;


#define UART0_BASE 0x1c090000
 void start()
 *(volatile long int *)(UART0_BASE) = 'A';


all : kernel.elf
test : kernel.elf
 qemu-system-arm -M vexpress-a15 -cpu cortex-a15 -kernel kernel.elf -nographic
_start.o : _start.arm
 $(CROSS_COMPILE)as -march=armv7-a -mcpu=cortex-a15 $^ -o $@
 start.o : start.c
 $(CROSS_COMPILE)gcc -ffreestanding -Wall -Wextra -Werror -c $^ -o $@
 kernel.elf : linker.ld _start.o start.o
 $(CROSS_COMPILE)ld -T $^ -o $@

Then make elf will build the binary, and make test should launch Qemu 🙂

Sources : https://balau82.wordpress.com/2010/02/14/simplest-bare-metal-program-for-arm/ , http://wiki.osdev.org/ARMv7-A_Bare_Bones

Preparing a minimal x86 linux system for Qemu

The fast way only !

Downloads :

wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.0.3.tar.xz
wget https://busybox.net/downloads/busybox-1.23.2.tar.bz2
tar xf linux-4.0.3.tar.xz
tar xf busybox-1.23.2.tar.bz2

Build x86 busybox :

 mkdir -pv build/busybox-x86
 cd busybox-1.23.2
 make O=../build/busybox-x86 defconfig
 make O=../build/busybox-x86 menuconfig
 (BusyboxSettings->Build Options-> Build BB as a static binary = ON)
 cd ../build/busybox-x86
 make install # will install in the _install dir
 cd .. # in build dir
 mkdir -p initramfs-x86
 cd initramfs-x86
 mkdir -pv {bin,sbin,etc,proc,sys,usr/{bin,sbin}}
 cp -a ../busybox-x86/_install/* .
 echo '#!/bin/sh' > init
 echo "mount -t proc none /proc" >> init
 echo "mount -t sysfs none /sys" >> init
 echo "echo -e \"\nBoot took \$(cut -d' ' -f1 /proc/uptime) seconds\n\"" >> init
 echo "exec /bin/sh" >> init
 chmod +x init
 find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs-busybox-x86.cpio.gz

Build x86 Linux :

 cd linux-4.0.3/
 make O=../build/linux-x86-basic x86_64_defconfig
 make O=../build/linux-x86-basic kvmconfig
 make O=../build/linux-x86-basic -j4

Run it x86 system with Qemu :

qemu-system-x86_64 -kernel linux-x86-basic/arch/x86_64/boot/bzImage -initrd initramfs-busybox-x86.cpio.gz -nographic -append "console=ttyS0"

Debug :

If init is not found at boot, you can check it is in the initramfs file :

$ zcat initramfs-busybox-x86.cpio.gz | cpio -t| grep init
5111 blocks

Build ARMv5 Linux :

For ARM, ensure you have a the compilation toolchain in your PATH.

 cd linux-4.0.3/
 export CROSS_COMPILE=arm-unknown-linux-gnueabi-
 export ARCH=arm
 make O=../build/linux-armv5-basic versatile_defconfig
 make O=../build/linux-armv5-basic -j4

Build ARMv5 busybox :

 export CROSS_COMPILE=arm-unknown-linux-gnueabi-
 export ARCH=arm
 mkdir -pv build/busybox-armv5
 cd busybox-1.23.2
 make O=../build/busybox-armv5 defconfig
 make O=../build/busybox-armv5 menuconfig
 (BusyboxSettings->Build Options-> Build BB as a static binary = ON)
 cd ../build/busybox-armv5
 make install # will install in the _install dir
 cd .. # in build dir
 mkdir -p initramfs-armv5
 cd initramfs-armv5
 mkdir -pv {bin,sbin,etc,proc,sys,usr/{bin,sbin}}
 cp -a ../busybox-armv5/_install/* .
 echo '#!/bin/sh' > init
 echo "mount -t proc none /proc" >> init
 echo "mount -t sysfs none /sys" >> init
 echo "echo -e \"\nBoot took \$(cut -d' ' -f1 /proc/uptime) seconds\n\"" >> init
 echo "exec /bin/sh" >> init
 chmod +x init
 find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs-busybox-armv5.cpio.gz

Run it x86 system with Qemu :

qemu-system-arm  -M versatilepb  -kernel linux-armv5-basic/arch/arm/boot/zImage -initrd initramfs-busybox-armv5.cpio.gz -nographic -append "console=ttyAMA0,115200"


Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)

You probably forget the initrd or your initramfs is wrong.

Failed to execute /init (error -8)
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
Starting init: /sbin/init exists but couldn't execute it (error -8)
Starting init: /bin/sh exists but couldn't execute it (error -8)
Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

Your initramfs is wrong.

source :

I mostly reproduce the proposition from this website, it also proposes more explanation and a way to speed-up the kernel boot : http://mgalgs.github.io/2015/05/16/how-to-build-a-custom-linux-kernel-for-qemu-2015-edition.html

Building a compiler with Crosstool-ng

What is crosstool-ng : http://www.crosstool-ng.org/

Step 1 – Preparation

Download and compile it :

$  git clone git://crosstool-ng.org/crosstool-ng
$  cd crosstool-ng
$  ./configure --enable-local 
$  make

Step 2 – Configuration

Configure your target (ex: arm architecture) :

$ ./ct-ng arm-unknown-linux-gnueabi

If you are not sure about the target you need, you can check the existing ones :

$ ./ct-ng list-samples
[L..] armeb-unknown-linux-gnueabi
[L..] x86_64-unknown-linux-gnu
[L..] x86_64-unknown-linux-uclibc
[L.X] x86_64-w64-mingw32
[L..] xtensa-unknown-linux-uclibc
 L (Local) : sample was found in current directory
 G (Global) : sample was installed with crosstool-NG
 X (EXPERIMENTAL): sample may use EXPERIMENTAL features
 B (BROKEN) : sample is currently broken

Step 3 – Generation

Generate the compiler :

$ ./ct-ng build


Once the compilation is done,

$ export PATH=crosstool-ng/.build/arm-unknown-linux-gnueabi/buildtools/bin/:$PATH
$ export CCPREFIX := arm-unknown-linux-gnueabi-
$ export AS := $(CCPREFIX)as
$ export LD := $(CCPREFIX)ld
$ export CC := $(CCPREFIX)gcc
$ export AR := $(CCPREFIX)ar

You can also repeat the build operation on different target to generate all you need:

$ ./ct-ng arm-unknown-linux-gnueabi 
$ ./ct-ng build
$ export PATH=crosstool-ng/.build/arm-unknown-linux-gnueabi/buildtools/bin/:$PATH

Possible errors

[ERROR] g++-4.6.real: internal compiler error: Killed (program cc1plus)

This happended to me on a board with not enough memory. You can temporarily add more swap :

dd if=/dev/zero of=swap.img bs=1024k count=1000
mkswap swap.img
swapon swap.img



[Git] merger dans la douleur , OK … mais bien équipé :)

Sous git, merger n’est pas toujours une action de tout repos. parfois il peut arriver d’oublier un commit dans la nature.

L’histoire commence généralement par un commit sans branche :

> git commit -m "add bugtrack function in generic.mk"

le commit est dans la nature, pour le récupérer comment faire ? Commençons par faire la liste des dernières actions :

> git reflog (q to exit)
4f7befc HEAD@{3}: commit: add bugtrack function in generic.mk

Puis il suffit de déplacer l’état courant vers ce commit perdu à l’aide de son SHA1 (4f7befc)
git checkout 4f7befc

Pour retrouver ce commit par la suite (pour un merge par exemple …) créons pour finir une nouvelle branche :
git checkout -b commitperdu

Source : http://stackoverflow.com/questions/366093/git-commit-against-tag-with-no-branch

[F15] Ajouter un raccourci personnalisé sous gnome 3

Comme vous le savez, gnome3 est assez .. épuré … en terme de paramétrage rapide. Et pour cause, le mot d’ordre semble avoir été de privilégier l’usage au paramétrage (ce qui ma foi est plutôt une bonne chose).

Du coup, voilà une manière propre d’ajouter un raccourci personnalisé dans la liste des applications favorites.

Pour cela il faut ajouter un nouveau fichier .desktop dans le dossier share/applications, cependant contrairement à ce que certains conseillent, je suis totalement opposé à l’écriture dans le dossier /usr/share/aplications, et pour cause, chaque utilisateur dispose de son propre dossier : ~/.local/share/applications (à créer s’il n’existe pas encore).

Par exemple, pour ajouter un lien vers eclipse avec les arguments qui vont bien :

mkdir -p ~/.local/share/applications
cp /usr/share/applications/eclipse.desktop ~/.local/share/applications

Puis modifier le fichier eclipse.desktop comme bon vous semble :

[Desktop Entry]
Name=Eclipse superstack
Comment=Eclipse Integrated Development Environment
Exec=eclipse -vmargs -Xms1024m -Xmx4196m

Ensuite il suffit de réactualiser la liste des applications, pour cela on redémarre gnome3 :
[alt] + [F2], tapez « r » puis [enter]

Et voilà votre nouveau raccourci « eclipse superstack » est ajouté à la liste des applications disponibles.