Shared publicly  - 
 
The latest Raspberry Pi patches have been applied to U-Boot. This adds:

• An "LCD" driver for the HDMI (and possibly composite) output, so you don't have to use serial console to see what U-Boot is doing. I must admit I haven't tested this recently, especially not since it was merged. I should do that!
• An MMC driver for the SD card, so files can actually be loaded, and hence Linux booted.

Still missing is USB support, e.g. for a keyboard or network booting.

To build it:

git clone -o u-boot-arm git://git.denx.de/u-boot-arm.git u-boot-rpi
cd u-boot-rpi
git checkout -b dev u-boot-arm/master
export CROSS_COMPILE=arm-linux-gnueabi-
./MAKEALL rpi_b

You'll probably want to apply http://lists.denx.de/pipermail/u-boot/2013-March/149625.html too.

Copy u-boot.bin to the SD card partition 1, renamed to kernel.img. I assume you're starting with a recent official "Raspbian" image on the SD card.

U-Boot expects to find boot.scr.uimg on the SD card in partition 1. This script will do the actual load/boot of the kernel. I use the following content:

fatload ${devtype} ${devnum}:1 ${kernel_addr_r} /zImage
fatload ${devtype} ${devnum}:1 ${fdt_addr_r} /${soc}-${board}.dtb
setenv bootargs "earlyprintk loglevel=8 console=ttyAMA0 verbose rootwait root=/dev/mmcblk0p2 rw"
bootz ${kernel_addr_r} - ${fdt_addr_r}

Put that into boot.scr, and generate boot.scr.uimg with:

mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg

Copy boot.scr.uimg to partition 1 of the SD card.

The main benefit of using U-Boot is the ability to boot an upstream kernel, since U-Boot fills in the device tree properties required for that. To build that kernel:

git clone -o korg_swarren_linux-rpi git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-rpi.git
cd linux-rpi
git checkout -b dev korg_swarren_linux-rpi/for-next
export CROSS_COMPILE=arm-linux-gnueabi-
make ARCH=arm bcm2835_defconfig
make -s ARCH=arm zImage -j8 -s && make -s ARCH=arm dtbs

Copy arch/arm/boot/zImage to the SD card. Copy arch/arm/boot/dts/bcm2835-rpi-b.dtb to the SD card; you'll need to rename that to bcm2835-rpi_b.dtb.

The kernel requires a serial console; there's no graphics or USB support upstream yet.

I don't recall if I had to manually adjust the Raspbian image to enable getty (login) on the serial port; perhaps it comes that way. Verify that something like the following is in file /etc/inttab in partition 2 of the SD card:

#Spawn a getty on Raspberry Pi serial line
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

The Raspbian image ships with a config.txt in partition 1. I don't appear to have that; I must have deleted it. I guess none of the options in it are needed for U-Boot.

Now, plug the SD card into the Pi, hook up your serial console, and boot it. With any luck, you'll see the kernel start up and be able to log in.

I also have some hacky work-in-progress patches to enable the recently added DWC2 driver in the kernel, for USB support. They don't work yet. If you're interested, they're available in git://github.com/swarren/linux-rpi.git branch rpi_dev. If you actually try to use them, you'll need to turn on the power to the USB controller before booting the kernel, e.g. by adding the following commands to the top of boot.scr.uimg:

# msg with 2 parameters, up to 2 responses
setenv prop-2-2 'mw.l 0x00001000 0x00000020 ; mw.l 0x00001004 0x00000000 ; mw.l 0x00001008 $tag ; mw.l 0x0000100c 0x00000008 ; mw.l 0x00001010 0x00000008 ; mw.l 0x00001014 $p1 ; mw.l 0x00001018 $p2 ; mw.l 0x0000101c 0x00000000 ; md.l 0x1000 8'

# send msg, read/dump response
setenv send-rec 'mw 0x2000b8a0 0x00001008 ; md 0x2000b880 1 ; md.l 0x00001000 8'

# set power, devid==p1 (3==USB), state,wait==p2 (3==ON/WAIT)
setenv tag 0x28001 ; setenv p1 3 ; setenv p2 3; run prop-2-2 ; run send-rec
9
2
Matthijs Kooijman's profile photoStephen Warren's profile photoIvan Afonichev's profile photoFlorian Meier's profile photo
9 comments
 
With this blog post I finally managed to boot the upstream kernel on my Raspberry! Thank you!

There was only one issue, that U-Boot hangs in create_fdt. Therefore, I commented out the line fdt_fixup_ethernet(...), because there does not seem to be support for that. I don't know if this has any side effects, but now it works :-D
 
Which exact U-Boot and kernel branch/commit were you using? I haven't seen that issue before, but if I can reproduce it I can try taking a look.
 
I have used exactly the above commands about 3 hours before.
 
+Florian Meier , I can't reproduce your problem. A few questions to help track this down. Which model Pi do you have, and how much RAM does it have? Which firmware version are you using? What RAM split between ARM and VC have you configured (or is it default) - what does U-Boot say the RAM size is? Are you using the exact following git commits?

U-Boot:
0ad6c34 ARM: Add Seagate GoFlex Home support
Kernel:
93746594 spi: convert drivers to use bits_per_word_mask

Thanks.

Feel free to email me; it might be easier than debugging this via a G+ post!
 
Oh never mind, I see what's probably the problem by code inspection. In fdt_fixup_ethernet(), if you change:

char mac[16] = "ethaddr";

to:

static char mac[16] = "ethaddr";

Does that solve the problem for you? It's probably yet another unaligned access, and I'm just getting lucky with the way my compiler lays out the stack.
 
This really fixes it! Thank you very much!
 
For anyone trying the u-boot for rpi fromhttps://github.com/gonzoua/u-boot-pi/tree/rpi , note that these instructions do not work (the  boot script has different name, various environment variables are not available, etc.) It also seems that that branch by gonzoua is not so new anymore, even though it still supports things (USB, netboot) that the official u-boot branch doesn't...
 
Yes, that's true. I think the only advantage of gonzoua's branch is the USB support. If someone wanted to upstream that, it'd be very welcome.
Add a comment...