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
13 Comments
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.
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)
I use partitions – “1”, “2”, “3”, “4” in SD Card. nIs your anwer that only 1 partition in SD Card?
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
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”.
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.
This is image file, to write it to SD, you may need to do similar of: http://elinux.org/RPi_Easy_SD_Card_Setup
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”?
btw, why do you have filename like sd.img.bz2.img, are you sure that you decompressed it (should be about 4GB file size)?
Did you test connected FTDI serial line working ok?, because all output is coming only from there. (nothing from display yet)
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
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.
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
[…] I read everything related by gonzo, followed by the wiki pages and this […]