Ez a weblap erősen fejlesztés alatt áll, úgyhogy ha valami nem működik, az nagy valószínűséggel nem a te hibád.

[blog] [zene] [it] [linkek] [etc] [info]
[blog] [bejelentkezés] [regisztráció] [tudnivalók] [RSS ]
2009. szeptember 30. szerda, 02:15
Debian on the SheevaPlug -- my way

If you look around a bit on the net, you can find a couple of tutorials on installing Debian on a Marwell SheevaPlug Development Board. I did the same, but wasn't satisfied with any of them, for various reasons; thus I decided to try it myself from the ground up, so you can find another method below. Although I use a different approach to do it, I collected very useful bits of information from the other tutorials listed under References.

I decided to install the OS to a USB stick instead of the Plug's embedded flash memory since it's easier to handle. Although the one and only USB port of the Plug will become occupied this way, you can get a cheap USB hub at any store round the corner, so you can have as many ports as you want. (I planned to connect a few more USB devices to the Plug so I needed a hub anyway.) Another thing that worths mentioning is that the current stable release of Debian (codename 'Lenny') doesn't support the SheevaPlug yet (and never will), thus we'll install the testing distribution codenamed 'Squeeze'.

In short, we'll use a QEMU virtual ARM machine to bootstrap the file system, put a suitable kernel on it for the SheevaPlug (officially it's called the Kirkwood family of machines), then configure the Plug's boot loader to start that kernel. Details follow.

First, you need a working QEMU installation. On a Debian system, just apt-get install qemu and you're done. We'll use the ARM variant called 'Versatile' for installation. You also need a kernel and an initial ramdisk with the installer to setup the OS in the virtual machine. Grab them from your preferred local Debian mirror (it's in the dists/squeeze/main/installer-armel/current/images/versatile/netboot/ directory) or from here. Plug the USB stick into the host machine and find out the device name it gets. You can do it by running dmesg | tail, for example. I'll assume it's sdc as well as the names of the ramdisk and the kernel you downloaded are initrd.gz and vmlinuz-2.6.26-2-versatile, respectively. Make sure that the stick is not mounted, otherwise you'll get unpredictable results. Oh, have I already mentioned that you need to say goodbye to all your data on the stick? ;-)

Let's start the installation in the virtual machine. Triple check that you replace sdc with the device name of your USB stick.

Install the OS according to your preference. As always, I use a separate primary partition for /boot and another one for all the rest on LVM. Use ext2/3 filesystem for /boot, as at the moment the boot loader recognizes only these. On a 8GB stick I created one volume group (called 'tutorial') with five logical volumes: root (1GB), usr (2GB), tmp (1GB), var (1GB), swap (512MB), their purpose should be obvious. Be patient, the partitioner is still damn slow. You can ignore the warning about a missing boot loader as the flash in the Plug already contains U-Boot.

After completion, the installer will restart the virtual machine, but don't let it boot again since it will just start the installer over. This is because it still uses the ramdisk specified on the command line which contains a basic installer, not the tools needed to bring the system up. You can't boot the stick in the Plug now, since the kernel that the filesystem has currently is for the Versatile variant, and we need the Kirkwood. So first we need to install that kernel onto the stick, and generate an initial ramdisk for it as well. But remember, you can't run any program -- including initrd generators -- on your machine. Thus we need to boot the virtual machine once again to install a Kirkwood kernel and to generate an initrd. To do that, a guest kernel and initrd is needed on the host system so that it can be passed to QEMU for booting in the virtual machine. So let's copy it out: make the kernel re-read the partition table, mount the filesystem /boot resides on, copy the kernel and the initrd to the host system, and boot the virtual machine with them, passing the kernel the correct root filesystem:

Now login as root and install a Kirkwood kernel:

This will pull in uboot-mkimage, the tool to make boot images for U-Boot to load. These images only differ from the original kernel and initrd images that they contain extra information including the type of the image, checksums and addresses to load their contents to. You can freely choose the names of them, I'll use a .ub suffix.

Before preparing them, the initrd must be regenerated. Unfortunately you need a few more kernel modules in the initrd to access the stick at early boot time. Remember, for the virtual machine it's a SCSI disk, so no USB modules are included in the default initrd. Edit /etc/initramfs-tools/modules and add the following lines:

Then regenerate the initrd and make the images for U-Boot:

Let's adapt inittab to the Plug. As it only has a serial port, you need to put a getty on it to be able to log in. Do that by uncommenting the line starting with #T0: and changing the baud rate to 115200, so it looks like this:

Later once the OS is running on the thing, we'll disable the virtual terminals, since they are useless on the Plug. Shut the virtual machine down now, and remove the stick from the host machine.

It's time to get your hands on it. Attach the USB cable that came with the Plug to your machine and the other end to the small USB port on the side of the box, right beside the MMC slot. Now plug it in the power outlet. On the host machine a USB/serial converter should appear soon. Check the kernel log, it looks like this:

Find the name of the converter, it's in the last line of the above log. Grab your favorite serial terminal emulator and attach it to the converter, making sure it's set to 115200 baud, 8 data bits, no parity. I prefer picocom, so I do

You'd better be quick at this point. The boot loader initialization takes around 10 seconds plus a 3 second delay before the preinstalled Ubuntu starts booting. Don't worry too much about it, you won't use that anymore. Complete initialization process looks like this:

Almost there. What you see is the command line interface of U-Boot. It has a bunch of commands documented in its manual plus a few more added exclusively for the Plug by Marvell. Execute the following commands, this time I'll show you the output as well:

Now lean back and watch your full-blown Debian system booting on the SheevaPlug. However, there are still a few things to do. As I mentioned earlier, the virtual consoles should be disabled in inittab, so comment them out:

There are a few things to set in U-Boot so the Plug can be restarted without human intervention. Reboot the Plug and enter the interactive command line interface by interrupting the boot process during the countdown. U-Boot maintains an environment of variables that's loaded from the flash at initialization time. Most of the variables have a special meaning, for example:

baudratesets the baud rate of the serial port
arcNumberused to tell the kernel the type of the machine -- see References
bootcmdcontains commands executed when the boot countdown is not interrupted
mainlineLinuxWell, I think no one actually knows what this is for... :-)
bootdelaycontrols how long the boot countdown takes in seconds
bootargsboot arguments automatically passed to the kernel

So let's set these and a few new ones, save everything to the flash, then restart the boot loader so we can see what happens. The meanings of the commands themselves should be pretty obvious.

Don't interrupt the boot process this time. If everything's okay, the OS will be started automatically. Now go on and install software, configure the network, have breakfast, whatever.

References

  1. http://www.cyrius.com/debian/kirkwood/sheevaplug/unpack.html
    Martin Michlmayr's tutorial. He provides a prebuilt tarball to unpack to the boot media, with additional instructions to install to an SD/MMC card. I don't trust any single system not installed by myself, so such a tarball is not an option for me.
  2. http://groups.google.com/group/it.fan.marco-ditri/browse_thread/thread/2a1d1d60e6d2ae54/3bd92e55a73b0630?lnk=raot
    A tutorial by Marco d'Itri. He uses the kernel of the preinstalled Ubuntu system to do the second stage of bootstrapping. He adds very useful other steps achieve a read-only root filesystem extending the lifetime of the USB stick.
  3. http://www.denx.de/wiki/DULG/Manual
    The U-Boot Manual
  4. http://www.openplug.org/plugwiki/index.php/ArcNumber
    A wiki page explaining arcNumber
  5. http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Introduction-to-Das-UBoot-the-universal-open-source-bootloader/
    Introductory article to U-Boot

***

Re: Debian on the SheevaPlug -- my way
2009. 09. 30. 12:19
Ivan

Koszi a cikket, remek!

(Harom hete rendeltem meg a cuccot, de meg nem adtak fel. Ha a negyedik heten sem kapok levelet a fedextol, akkor rajuk telefonalok :)

 
 
Koncertnaptár
Használd ezt.
 
Most olvasom (ötlet: wade)
Popper Péter:
A belső utak könyve
Kosztolányi Dezső összes novellái (2. kötet)
Mohás Lívia:
Ki vagy te? -- Önismereti könyv önjáró fiataloknak
Tendzin Gjaco (Őszentsége a dalai láma):
Út a nyugalomhoz -- mindennapi tűnődések
No software patents GNU Firefox Hacker last.fm
Apache powered MySQL stored PHP parsed Debian Emacs