Some userspace


#include <stdio.h>

int main(int argc, char* argv[])
    printf(">>>>>>>>>>>>>> Hi!!!! This is SUPER init system v0.-1!\n");
    return 0;

Compile it

arm-linux-gnueabihf-gcc -Wall -static -ohi hi.c
file hi
hi: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=5ddde551672c3b7e2b64f5a8349371dc4b400cea, not stripped

Copy it to rootfs

Mount SD card and copy hi over to the rootfs partition.

Note: although your user was most probably allowed to mount the partition, the default access rights on the root directory of an ext4 filesystem allow only root to write to it, so the following must be executed as root (and generally, creating the sdcard image should be the only step required to be run under root).

For this simple "image" you can also modify the access rights on the rootfs partition (when you created it...) to allow your user to write to it...

cp hi /run/media/yoyo/rootfs/
ls -l  /run/media/yoyo/rootfs/
total 24
-rwxr-xr-x 1 root root  6149 Oct 27 11:49 hi
drwx------ 2 root root 16384 Oct 27 02:06 lost+found

Unmount the card! :-)

Run/boot it

Put the card into the devie and boot u-boot.

Now we need to set up some kernel commandline arguments

Note: the devices have differen default settings / commandlines (both in u-boot and kernel), so if you don't interrupt the normal boot process, they will most probably pick up your kernel (which we named / copied to the card in a default way) and most probably also your root partition (second partition on the card using extXXX) but certailny not our single userspace program :-)

The required options:

Booting your kernel with these options should result in rootfs being mounted, but kernel will still panic, because it won't be able to find /sbin/init, the first userspace process that it runs on boot.

Our "init" should now be started and we should see it's output, however just after that the kernel still panics... why?

We can fix that, but we don't really want to change the sdcard every time we want to change something. Let's make booting a bit easier by setting up a network boot.

Vim logo FireFox logo CSS XHTML
Jozef Siska @ KAI FMFI UK YoYo @ KSP KAI (DAI) KSP