Lab 3, R-Pi Booting process

Now time to study the boot process on Raspberry Pi.
Good source to study: R-Pi Boot process

1. Stage 1 boot is in the on-chip ROM. Loads stage2 in the L2 cache!
2. Stage 2 is bootcode.bin. Enables SDRAM and loads stage3
3. Stage 3 is loader.bin. Knows about elf format and load start.elf
4. start.elf loads kernel.img (also start.elf is the main gpu code).

  • It reads config.txt, cmdline.txt and bcm2835.dtb
  • If the dtb file exists, it is loaded at 0x100 & kernel @ 0x8000
  • Else if disable_commandline_tags is set load kernel @ 0x0
  • Else if load kernel @ 0x8000 and put ATAGS at 0x100

5. kernel.img, is the first! thing that runs on the ARM processor.

We will use u-boot as kernel.img so our config.txt will look as:

kernel=u-boot.bin

cmdline.txt:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

We will use http://people.freebsd.org/~gonzo/arm/rpi/freebsd-pi-uboot-20120806-netboot.tar.gz u-boot package prepared by Gonzo to make R-Pi to start USB, initialize Serial, initialize Ethernet (remember it is behind USB), get IP via DHCP and can download and start our kernel via TFTP.

To specify IP where kernel should be downloaded from, we need to prepare boot.scr for U-Boot:
boot-tftp.cmd:

set autoload no
set serverip 10.0.55.112
set bootfile irpi
set loadaddr 7FE0
if usb start; then
    if dhcp; then
        if tftpboot ${loadaddr} irpi; then
            go 8000;
        fi;
    fi;
fi;

Now compile it into boot.scr:

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'U-Boot script' -d boot-tftp.cmd boot.scr

That’s all, now we can write files into FAT boot partition onto SD card, put there generated boot.scr and start R-Pi.

Let’s connect wires to FTDI, to USB, start screen on Mac, put SD into R-Pi, start TFTP server, turn power ON and wait:

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
BOOTP broadcast 2
*** Unhandled DHCP Option in OFFER/ACK: 95
*** Unhandled DHCP Option in OFFER/ACK: 95
DHCP client bound to address 10.0.55.120
BOOTP broadcast 3
Waiting for Ethernet connection... done.
Using sms0 device
TFTP from server 10.0.55.112; our IP address is 10.0.55.120
Filename 'irpi'.

Great!

FILES:
freebsd-pi-uboot-20120806-netboot.tar.gz
boot-tftp.cmd
boot-tftp.scr
sd.img.bz2

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

13 Comments

  1. wsh
    Posted April 17, 2013 at 10:17 | Permalink

    HI~nnI read your article.nnI have question.nnIf i apply freebsd-pi-uboot-20120806-netboot.tar.gz file in partition “boot/1”, Can u-boot operatennRaspberry Pi test board? nnNow I apply “freebsd-pi-uboot-20120806-netboot.tar.gz”, but Raspberry Pi test board does not act.

  2. yshurik
    Posted April 17, 2013 at 10:24 | Permalink

    I guess I used whole SD card as single partition and copied files from archive there. (May need to grab SD from rpi to check this)

  3. wsh
    Posted April 17, 2013 at 10:56 | Permalink

    I use partitions – “1”, “2”, “3”, “4” in SD Card. nIs your anwer that only 1 partition in SD Card?

  4. yshurik
    Posted April 17, 2013 at 10:59 | Permalink

    Yes, try to repartition your SD into just single partition and put files there. I may upload zip with my image late today when I get access to that RPi

  5. wsh
    Posted April 18, 2013 at 02:22 | Permalink

    Thank you for your answer. nnI try to adjust my SD Card Partition with just single partition. nnSingle partition’s format is FAT16. nn( Is right that SD Card single partition format is used with FAT16? nn If FAT16 format is wrong, what I will use foramt? ) nnAnd I put files in my SD card.n(The names of each file are ‘boot.scr’, ‘bootcode.bin’, ‘boot-tftp.cmd’, nn ‘cmdline.txt’, ‘config.txt’, ‘loader.bin’, ‘start.elf’, ‘u-boot.bin’, ‘uEnv.txt’)nnBut, The result of RPi booting is fail continually.nnPlease,Inform us what part of I am wrong and ask for a detailed description about how to use “u-boot.bin booting”.

  6. wsh
    Posted April 18, 2013 at 06:30 | Permalink

    Hi~ ThanknnI receive your file – sd.img.bz2. And uncompress this file with bunzip2.nnAS result, I have “sd.img.bz2.img” file.nnOne thing the question again, I want to know How use “sd.img.bz2.img” in detail.nnJust put this file card is the SD Card? Do not be the other files(‘boot.scr’, ‘bootcode.bin’, ‘boot-tftp.cmd’, ‘cmdline.txt’, ‘config.txt’, ‘loader.bin’, ‘start.elf’, ‘u-boot.bin’, ‘uEnv.txt’) ?nnplease,Inform us answers.

  7. yshurik
    Posted April 18, 2013 at 07:57 | Permalink

    This is image file, to write it to SD, you may need to do similar of: http://elinux.org/RPi_Easy_SD_Card_Setup

  8. wsh
    Posted April 18, 2013 at 10:02 | Permalink

    I try to test “site – use image file and write it to SD Card” which you know.nnAnd I succeed RPi booting with “2013-02-09-wheezy-raspbian.img”.nnbut I fail RPi booting with “sd.img.bz2.img” contiunally.nnnnCan you give me other “u-boot img file”?

  9. yshurik
    Posted April 18, 2013 at 10:59 | Permalink

    btw, why do you have filename like sd.img.bz2.img, are you sure that you decompressed it (should be about 4GB file size)?

  10. Oleg
    Posted April 18, 2013 at 21:25 | Permalink

    Did you test connected FTDI serial line working ok?, because all output is coming only from there. (nothing from display yet)

  11. fred
    Posted December 2, 2013 at 18:49 | Permalink

    Which Mac OS X software did the SD image ???nnnWhy not using Plan9 bootable image?nnnsh-3.2# uname -anDarwin […]nsh-3.2# mkimagensh: mkimage: command not found

  12. yshurik
    Posted December 2, 2013 at 19:30 | Permalink

    When I started 9pi was in early stages I guess. I used “mkimage” on linux box – /usr/bin/mkimage is coming from “dev-embedded/u-boot-tools” on gentoo.

  13. yshurik
    Posted December 2, 2013 at 19:33 | Permalink

    Also I didn’t make sd image, just took image from freebsd-pi: mentioned in the lab as freebsd-pi-uboot-20120806-netboot.tar.gz (and attached). mkimage was used to create scr file

One Trackback

  1. By How do you make u-boot run | CL-UAT on December 30, 2014 at 08:03

    […] I read everything related by gonzo, followed by the wiki pages and this […]

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>