The current latest working version of U-Boot is 1.2.0 (as of this writing, 12/3/2007) but we'll need to apply patches for it to work on the Kurobox.

+

The current latest working version of U-Boot is 1.2.0 (as of this writing, 12/3/2007) but we'll need to apply patches for it to work on the Kurobox. Some people have run into problems extracting the files from patches.zip, use -aa to make sure they're extracted as text files.

If you don't succeed in getting git running, for example when on Debian Sarge (Sylver's image), you could try to download a dtc tarbal from the website.

==Build dtc==

==Build dtc==

Line 104:

Line 106:

==Set up a netconsole==

==Set up a netconsole==

−

You nowl need to run netcat on your PC or Apple Mac in order to communicate with U-boot over your LAN. This allows you to interact with the bootloader so you can see what is happening, and to send it commands.

+

You now need to run netcat on your PC or Apple Mac in order to communicate with U-boot over your LAN. This allows you to interact with the bootloader so you can see what is happening, and to send it commands.

You will need to have your PC or Apple Mac and your Kurobox on the same LAN, and you'll need to know the IP addresses of both. Write them down.

You will need to have your PC or Apple Mac and your Kurobox on the same LAN, and you'll need to know the IP addresses of both. Write them down.

Line 410:

Line 412:

*Turn the Kurobox on. Just when the power LED stops flashing, press the red button on the back. Wait for a while for the system to boot.

*Turn the Kurobox on. Just when the power LED stops flashing, press the red button on the back. Wait for a while for the system to boot.

*Telnet to your computer, login with root / kuroadmin:

*Telnet to your computer, login with root / kuroadmin:

+

+

(What is meant in the above is that you should go into EM mode. Pressing the red button on the back does not put my KuroBox into [[EM_Mode|EM mode]].)

+

$telnet 192.168.x.y

$telnet 192.168.x.y

*You need to ftp the tool to chroot to your OS on /dev/hda1. On your computer:

*You need to ftp the tool to chroot to your OS on /dev/hda1. On your computer:

Latest revision as of 19:09, 13 August 2010

As of 2.6.20-rc2, standard kernels support the Linkstation and Kurobox with no additional kernel patches. This page will document all the stuff you need to run these kernels by the installation of the U-Boot bootloader.

Introduction

The 2.6.20 kernel has an additional requirement: a *.dtb file, which is a database of hardware peripherals, supplied by the bootloader.

The good thing about this is, it will allow you to build a generic PowerPC kernel which works unchanged on all sorts of devices.

The bad thing is, it requires a bootloader with support for dtb files. At time of writing, this means U-Boot from git (not the old 1.1.4 release), and it also rules out the loader.o hack. But read on... we'll be using the uloader.o hack instead.

Assumptions

You should have a normal linux PC, or an Apple Mac, on the same ethernet network, and the ability to run netcat ('nc') on that machine.

You should also have a normal Linux distribution installed on the hard drive of your Kurobox, and booting properly. Your Kurobox will also need a working C compiler, as we will be compiling everything directly on it. It will also need the following tools & libraries installed: bzip2, git-core, make, patch, perl, tar, unzip, wget,bison, flex, libncurses5-dev and your text editor of choice. My command listings will use "$" to indicate commands run as a normal user, and "#" to indicate commands to be run as root. Most of this stuff will be done as a normal user, and unless specified otherwise, all commands should be run on the Kurobox directly.

If you do not already have a linux distribution installed on your hard drive, I recommend Gentoo or Debian. (I use Gentoo Linux, so I already know my compiler works.) You could set up a cross compiler on your PC/Mac and use that, but setting up such things is described elsewhere.

My U-Boot configuration modifications assume your linux box does not have a separate partition for /usr or /usr/src. In other words, this directory should be on the root partition (/). If this is not the case, you will need a different value for the U-Boot "ubpart" environment variable. If you don't get this right, U-Boot won't be able to find the right file when you tell it to write U-Boot into flash, and will output an error message.

Note that you MUST be running either the 2.4.17 or the 2.4.20 kernel in order to flash or try U-Boot on RAM. This is because the uloader.o, a module which is required for those processes, is only compatible with those kernels. If you have installed other kernels, you can still follow this procedure by going into EM mode.

Safety

Read the Rough edges section before you begin, to understand the things you should watch out for.

Do not attempt this unless you feel comfortable hacking C sources. Do not attempt this unless you are comfortable with linux, normal users and root user, permissions, and that kind of thing. Also, don't attempt this unless you have a day or two to play around with it. This is not a 15 minute exercise.

Most of the stuff you'll be doing here is pretty harmless. If you follow these instructions correctly, you won't be in any danger of bricking your box until you get to the actual flashing part, in Install u-boot into FLASH, below. But you'll be testing a RAM build first, and you'll be using netconsole, so you should be able to spot any problems before you re-flash anything. Notice, that even a successful RAM-based U-boot test does NOT guarantee that the eventual re-flashing will be successful too, so even then exists the possibility for bricking your system.

Guennadi Liakhovetski developed the kernel support, with his Kurobox HG. I am using a Kurobox HG, too. He thinks it will work with Kurobox HDs, Linkstation I, Terastations, i.e., all compatible PPC-based systems, but I have yet to hear of anyone who has tested it. I would be very interested to hear from anyone who does test it... at least you should be safe with a RAM build without risk of bricking your unit.

Finally, this will violate your warranty. If you didn't already know that, maybe this isn't for you.

Getting the things you need

You will need the following:

nc

You will need nc, also known as 'netcat', installed on your PC (Apple Macs normally have it pre-installed). If you don't have it you should be able to use apt-get (Debian) or emerge (Gentoo) or whatever your system uses to install it. If you can't find a package for your distribution its website is here.

Kurobox Set-Up

As mentioned in the Assumptions and Safety section above you will need to install the following tools & libraries on your Kurobox: bzip2, git-core, make, patch, perl, tar, unzip, wget, bison, flex, libncurses5-dev, gcc. Again, if any of these are missing use the appropriate commands (apt-get, emerge, whatever) to install them.

As we will be compiling most things as a normal user, make sure our build directory is writable by that user. My Kurobox user is "paranoid", and Gentoo uses "users" as the group name; please replace these with your user/group of choice.

$ su
# chown -R paranoid:users /usr/src
# exit

kernel

Download the linux kernel sources onto your Kurobox, in the /usr/src directory. 2.6.20 is current at time of writing, and that's what I'm using.

U-Boot

The current latest working version of U-Boot is 1.2.0 (as of this writing, 12/3/2007) but we'll need to apply patches for it to work on the Kurobox. Some people have run into problems extracting the files from patches.zip, use -aa to make sure they're extracted as text files.

Set up a netconsole

You now need to run netcat on your PC or Apple Mac in order to communicate with U-boot over your LAN. This allows you to interact with the bootloader so you can see what is happening, and to send it commands.

You will need to have your PC or Apple Mac and your Kurobox on the same LAN, and you'll need to know the IP addresses of both. Write them down.

On your PC or Apple Mac run the following command, replacing 1.2.3.4 with the IP address of your Kurobox:

$ nc -u -p 6666 -v -v 1.2.3.4 6666

Netcat should output a message like the following, and then sit there waiting to receive packets from the network:

Configure U-Boot

This part requires some text editing in order to change the values included in the Kurobox patch into something which will be useful for you. I'm just documenting my own modifications here; it's likely that not all of them are necessary. Consider this section a work in progress; feel free to edit, simplify and clarify.

Change these addresses so that CONFIG_IPADDR_LS is the IP address of your Kurobox, and CONFIG_SERVERIP_LS is the IP address of your PC or Apple Mac. These addresses determine where the netconsole packets go so it is important to get these right. Here's a silly example:

#define CONFIG_IPADDR_LS 1.2.3.4
#define CONFIG_SERVERIP_LS 5.6.7.8

Find CONFIG_BOOTARGS on line 129. It currently says:

#define CONFIG_BOOTARGS "root=/dev/hda1"

You need to change it to the following replacing 1.2.3.4 with your Kurobox IP, and 5.6.7.8 with your PC/Apple Mac IP:

Build your kernel

Start with the default linkstation config file, and enable any other options you need. Some guidelines:

The default linkstation config uses PATA, which is a separate driver from the normal IDE stuff. CONFIG_IDE should be disabled, otherwise they will conflict. The platform maintainer (Guennadi Liakhovetski) said he had problems with the IDE driver, which is why the kernel config uses the PATA driver instead.

The linkstation kernel config has enabled the right architecture options for the devices present in the kurobox. This means things like rtc, serial port, ethernet port, usb, etc. You might still want to add support for networking options, filesystems, and usb devices you may wish to use.

Figure out your uloader.o

When I first loaded U-Boot, I followed the instructions on this page. I had some confusion, because that page said my Kurobox HG was supposed to be running a 2.4.20 kernel, but in fact it had a 2.4.17 kernel. Their 2.4.17 module was built for a normal kurobox... on an HG, it requires an extra module parameter. Since this took me a while to figure it out, I'm going to be extra-specific in this section.

You need to know what hardware you have, and what version of the kernel it is currently running. You might be running a 2.4.17 kernel, or a 2.4.20 kernel. You can find out what kernel you're running with the following command:

$ uname -a

Which will produce output like the following. I've highlighted the kernel version number:

Now that you have all of these things, let's see if U-Boot runs correctly on your device. If you have a standard Kurobox, replace "u-boot-load-hg" with "u-boot-load-hd". Note: If you end up getting an error you're probably trying this using your 2.6 kernel. If so, skip down to the next section.

$ cd /usr/src
$ su
# sh u-boot-load-hg.sh

You've just logged out of the device, which should now be rebooting. After 10 to 20 seconds the green power LED should turn off, and then begin pulsing slowly. After a few more seconds you should see some text come up in the netconsole window:

After 2 to 4 minutes you should be able to ping and ssh back into your Kurobox.

If *anything* goes wrong with this step, you need to troubleshoot it before proceeding to the next step. Some possible pitfalls:

If you don't get any netconsole output: make sure the PC/Apple Mac and kurobox are on the same ethernet network. Check the IP addresses of both units. Check the IP addresses in the uboot source's linkstation.h, for the CONFIG_IPADDR_LS and CONFIG_SERVERIP_LS values, and for the CONFIG_BOOTARGS line. Check the IP in the command line when you ran nc on your PC/Apple Mac. Make sure you're using good ethernet cables, try a different port on your hub/switch, make sure the proper link lights are on for both the switch and Kurobox.

If U-Boot gives you error messages over netconsole, or if the old linux kernel fails to load, something is seriously wrong. Do not flash this version of U-Boot into your Kurobox, you will brick your unit. Start over. Note that it does take a few minutes to boot, so be patient and don't throw your kurobox at the nearest wall yet.

If you are not running 2.4.x kernels

This part of the guide applies to those who are running a kernel OTHER than 2.4.17 or 2.4.20. If you ARE under those kernels skip this whole section.

If you are not on a 2.4.x kernel, the previous step will fail because uload won't work. Assuming that you already have a working system with a 2.4-compatible insmod, installed to /dev/hda1, and that you have followed all the previous steps, here are the steps you can follow :

Turn the Kurobox on. Just when the power LED stops flashing, press the red button on the back. Wait for a while for the system to boot.

Telnet to your computer, login with root / kuroadmin:

(What is meant in the above is that you should go into EM mode. Pressing the red button on the back does not put my KuroBox into EM mode.)

$telnet 192.168.x.y

You need to ftp the tool to chroot to your OS on /dev/hda1. On your computer:

Try out the new kernel

Next you need to make sure your new kernel will boot. Follow the instructions on your distro's website to make sure you will have the right software installed to use version 2.6. Here is the link for Gentoo. Mostly you just have to have udev and module-init-tools installed.

Your new kernel will have one big problem: we've switched from IDE to PATA drivers. This means hda1 becomes sda1, hda2 becomes sda2, etc. Due to this you will have to change your /etc/fstab entries, but you should do that last because it will affect your ability to boot the old kernel. You need to make sure everything else works first.

So, reboot. Note the old kernels don't always reboot properly in my experience, or maybe I'm just impatient. I typed reboot, and 5 minutes later I got impatient and pulled the power plug out of the back, plugged it back in and pressed the power switch.

Watch the netconsole this time. Don't interrupt it, let it try to boot the new kernel. It probably won't boot fully. But you need to ensure 3 things:

That the network works (e.g. you get some text on your netconsole from the new kernel)

That it detects the hard drive properly

That it mounts the root filesystem properly

I'll include a log of what mine says, below. But first, here are the lines we care about:

Also you'll need to edit your /etc/inittab file and change any getty processes from ttyS0 to ttyS1, because the AVR device is now on /dev/ttyS0. You don't want a getty process talking to the AVR as it can confuse the AVR and cause your system to reboot after 5 minutes by the watchdog.

# ne /etc/inittab
(change getty processes on ttyS0 to ttyS1)

Ok, now reboot. Everything should work because you checked everything else before changing your fstab, right?

# reboot
# exit
$ exit

And wait. Once again, maybe try pulling the power cable out if it can't reboot on its own.

And everything works perfectly. At least it did for me. If you can't get to a prompt at this point you will probably have to use em-mode to rescue it. This is done with the "run emboot" command at the U-Boot prompt.

If it was successful it's now recommended that you install the 2.4.33 em-mode update[1], or the foonas-em update[2], to complete your Kurobox upgrade.

References

Rough edges

Kernel and U-Boot are not yet tested with any device other than the Kurobox HG.

Kernel does not yet have *.dts files for anything other than the Kurobox HG. This is a showstopper for standard Kurobox owners.

I made a lot of changes to the u-boot config header. Paths and partition ids are very specific to the partition layout of your kurobox's linux installation.

If your /boot directory is on its own partition, you will have to change the u-boot config before it will find your kernel image.

Having to use the PATA driver is kind of a pain in the ass. Having to adapt your /etc/fstab to get the new kernel booting is dangerous; if the new kernel doesn't boot for some other reason, then the old kernel won't know where to find its partitions either, and you have to use EM mode or a USB caddy plugged into your PC to rescue your kurobox.

You will not be able to enter EM mode directly by running "run emboot" from within U-boot with stock 2.4.17 or 2.4.20 kernel due to the check for NGNG. A possible solution would be to flash with one of the telnet-enabled (linkstation) firmwares which mindbender has made. You can attempt this after you have flashed U-boot correctly. (I had a Kurobox/HGWR with stock 2.4.17_mvl21 and successfully flashed 2.4.33 v3 kernel within 2.6.21.1 U-boot kernel)

Following successful testing of your U-Boot RAM build, you'll find that once you've flashed the Kurobox boot-loader you can no longer use the command 'run flboot' to boot to your old system. This is a known issue but the reason it occurs remains unexplained. It's now highly recommended that you install the new 2.4.33 Uboot firmimg.bin as stated above, or foonas-EM, to complete your Kurobox upgrade.

Footnotes

↑FYI: compilation of a 2.6.23.9 vanilla kernel took approximately 1hr 45min. on a Kurobox HG