Lab 5, Hello World

This lab will be short but it is going to summarize all material provided in previous labs.
Our target to develop simple “barebone” program which can be loaded and executed by U-Boot.
It should only print “Hello world!” to our serial console.

First, let’s find out how we can print something. BCM2835 manual describes that the chip has different features as Mini-UART and PL011 UART.

Instead of writing own driver for UART routines let’s better check how U-Boot performs. Checking the sources codes gives us a hint that when U-Boot pass execution control to our program we have initialized PL011 which has ports ready to transmit bytes to our serial line. It has choice for PL011 because Linux kernel (which is default target/option for U-Boot) will be throwing boot messages exactly to PL011 ports until Linux kernel initializes own driver for serial.

After checking routines we realizes that code for sending something to serial is pretty simple:

#define IOBASE          0x20000000      /* base of io registers */
#define PL011REGS       (IOBASE+0x201000)
#define UART_PL01x_FR_TXFF  0x20
typedef unsigned int    u32int;

pl011_putc(int c)
    u32int *ap;
    ap = (u32int*)PL011REGS;
    /* Wait until there is space in the FIFO */
    while (ap[0x18>>2] & UART_PL01x_FR_TXFF)

    /* Send the character */
    ap[0] = c;

    /* Wait until there is space in the FIFO */
    while (ap[0x18>>2] & UART_PL01x_FR_TXFF)

pl011_puts(char *s) {
    while(*s != 0) {
        if (*s == '\n')

main() {
    char * s = "Hello world!\n";
    for (;;);

Again, we do not need to initialize anything, so our code should just work.

Compile our barenone kernel, connecting everything (serial, eth, etc), starting tftp server, juice power to rpi and:

U-Boot 2012.04.01-00489-gcd2dac2-dirty (Jul 07 2012 - 12:57:03)

DRAM:  128 MiB
WARNING: Caches not enabled
MMC:   bcm2835_sdh: 0
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0 
reading uEnv.txt

17 bytes read
Importing environment from mmc ...
reading boot.scr

274 bytes read
Running bootscript from mmc0 ...
## Executing script at 00008000
(Re)start USB...
USB:   Core Release: 2.80a
scanning bus for devices... 3 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
       scanning bus for ethernet devices... 1 Ethernet Device(s) found
Waiting for Ethernet connection... done.
BOOTP broadcast 1
*** Unhandled DHCP Option in OFFER/ACK: 95
*** Unhandled DHCP Option in OFFER/ACK: 95
DHCP client bound to address
BOOTP broadcast 2
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server; our IP address is
Filename 'irpi'.
Load address: 0x7fe0
Loading: T T T T T T T T #
#Bytes transferred = 634 (27a hex)
## Starting application at 0x00008000 ...
Hello world!

So at this point you can develop any OS you would like to have, using Plan9 Assembler and C lang, but our timeline is to have Inferno OS working native on Raspberry Pi.


This entry was posted in Blog, Inferno OS, Raspberry Pi, Research. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted December 8, 2012 at 00:59 | Permalink

    Nice lab series! I can’t wait to see Inferno working on R-pi.nWhat happens after main() ends? Will it execute a random code from uninitialized memory?

  2. Posted December 9, 2012 at 03:31 | Permalink

    oh guys, please continue!

  3. yshurik
    Posted January 26, 2013 at 10:57 | Permalink

    Those good questions to be collected as questionnaire for the lab :)

  4. yshurik
    Posted January 26, 2013 at 10:59 | Permalink

    Sure, we do, at least up to the stage when we need usb (because ref documentation is really needed to implement it, but it is currently closed)

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>