2009-10-09

Installing Slackware on the SheevaPlug

And so, finally, we come to the final part of our series regarding the setting up of our SheevaPlug with Linux. Thanks to the good guys at armedslack, we will have the best Linux distro ever, running on one of the coolest little devices around.

For this setup, we will install Slackware on an 8 GB High speed SDIO MMC card, and leave the NAND flash untouched with its updated Ubuntu version. This will also suppose that you have a working kernel that supports ext4 and all the features you want already installed on the flash (if not, refer to this post to to set it up). Now, we are going to deviate a little bit from the "official" armedslack intallation guide for the SheevaPlug, as we are not going to use TFTP for our packages but instead read them directly from an USB device.

And so, without further ado:
  1. Download the packages from armedslack.org. The only directories you really need are the "slackware", "isolinux" and "kernels" directory from ftp://ftp.armedslack.org/armedslack/armedslack-current/. If you're downloading from a Linux system, one way to do it, as advertised in the armedslack installation readme is:
    rsync --exclude '*/source/*' --delete -Pavv ftp.armedslack.org::armedslack/armedslack-current .
    (NB: If you use Filezilla to download from FTP, please note that it seems to default to ASCII mode instead of binary, so don't be surprised if your files are corrupted!)
    This amounts to about 2 GB of files, so it will take a while, but the filesystem used for the target shouldn't matter much, as long as it is accessible from the default armedslack kernel. So if you have a FAT formatted USB stick lying around, with more than 3 GB space available, you should probably use that.
    I also have to point out that we are downloading slackware-current, which contains an up-to-date version of the packages, but is different from a dot release, so you might see some versioning differences between current and what you get on the official x86 dot releases.
    For the remainder of this guide, I will assume that you have the directories (slackware/, isolinux/ and kernels/) in an "armedslack/" directory at the root of a FAT formatted USB device. Note that if you're not using a FAT formatted device, you will need to copy the kernel and initrd image on a separate device that can be read from U-boot

  2. Alright, time to reboot the system, with your USB and MMC card plugged in and enter the Marvell>> U-boot prompt through the serial console. There, you need to issue the following:
    Marvell>> usb start
    
    (Re)start USB...
    USB: scanning bus for devices... 2 USB Device(s) found
    scanning bus for storage devices... 1 Storage Device(s) found
    Marvell>> fatload usb 0 0x00800000 armedslack/kernels/kirkwood/uImage-kirkwood
    reading armedslack/kernels/kirkwood/uImage-kirkwood
    ...
    ................................................................................

    1887248 bytes read
    Marvell>> fatload usb 0 0x01100000 armedslack/isolinux/uinitrd-kirkwood.img
    reading armedslack/isolinux/uinitrd-kirkwood.img
    ...
    ................................................................................

    10985095 bytes read
    Marvell>> setenv bootargs console=ttyS0,115200 nodhcp kbd=uk root=/dev/ram rw;bootm 0x00800000 0x01100000
    If all is well, you should be seeing your usual Slackware installation screen.
    Please note that because of the "kbd=uk" line above, your keyboard will be automatically set to uk, so change it accordingly.
    Also, if you want to use a network session rather than the serial console, you should issue:
    dhcpcd eth0
    
    /etc/rc.d/rc.dropbear start
    Then you can find your IP address through ifconfig and ssh to it.

  3. If needed, you should use fdisk to partition your MMC device:
    fdisk /dev/mmcblk0
    On my system, I created a 512MB /dev/mmcblk0p1 partition for Swap (type 0x82) and left the rest as /dev/mmcblk0p2 for Linux (type 0x83)

  4. If you had a look at dmesg, you should see that your USB device has been detected by the kernel (normally as /dev/sda). Since we have our Slackware package on that device, this is what we are going to use for the source. I have found out however that:
    - If you attempt to mount the directory manually and chose the Install from a pre-mounted directory option in SOURCE MEDIA SELECTION, MAKE SURE that your path ends with the slackware/ directory where the a/, ap/, d/... packages reside and NOT the one where extra/, isolinux/, kernels/... reside. If you don't, setup will happily list the packages but fail to install them and produce a completely irrelevant error!
    - If you select "Install from a hard drive partition" but haven't previously mounted the partition, it will fail to mount the directory properly.
    For now, we will use the "Install from a hard drive partition" option, but we first need to mount that partition manually.
    And remember that the Slackware setup process uses /mnt for its own purpose, so you should not use that location as a mountpoint. So:
    mkdir /usb
    
    mount /dev/sda1 /usb
    echo "mmc0" > /sys/class/leds/plug\:green\:health/trigger
    setup
    The "echo mmc0" line in there is a trick to get the blue LED act as an MMC card access indicator, as, if you're like me, you want to see some indication of r/w access to your root device.

  5. Setup should be smart enough to detect your Swap & Linux mmc partitions, and format them (the default ext4 is a good choice for a filesystem). With regards to the SOURCE MEDIA SELECTION screen, you should now select "2 Install from a hard drive partition" then enter "/dev/sda1" as the device and "/armedslack" as the path (or whatever you called your directory on the USB). If you did mount your partition beforehand, this will work and you will then be able to select the packages straight off the USB.

  6. From there, it's your run-of-the-mill package selection and installation. On my 8 GB SD Card, I found that selecting everything but GNU Emacs, TeX, KDEI and the Kernel sources resulted in a 3.7 GB installation, thus leaving about 2.9 GB free space, which is fine. Of course, if you want more space, you can fine tune your package selection or use a bigger SD card.

  7. After you've gone through the rest of the configuration (network, etc) you can reboot the system and get back to the Marvell>> U-Boot prompt. There we will want to test that the custom kernel we've been using to boot Ubuntu can also boot our Slackware installation. Again, this supposes that you followed the steps from my earlier post regarding custom kernel installation and flashing. If not, now is probably a good time to follow this post to to flash the uImage-kirkwood kernel that you used for setup.

    To test that your current NAND kernel can boot Slackware:
    # Preliminary check to see if your bootargs_console variable is
    
    # properly defined. if not, make sure you set it up
    Marvell>> printenv bootargs_console
    bootargs_console=console=ttyS0,115200
    # This defines our root device. Make sure that use the right device, and that you mount it "ro"
    Marvell>> setenv bootargs_root root=/dev/mmcblk0p2 rootfs=ext4 ro
    Marvell>> setenv bootargs $(bootargs_console) $(bootargs_root)
    Marvell>> printenv bootcmd
    bootcmd=nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
    # Your bootcmd should only read the kernel and boot from it.
    # If not, just issue the 2 commands above instead of what follows
    Marvell>> run bootcmd
    You should then be able to boot into your newly installed Slackware Linux. If not, you might want to check your parameters and install & flash a kernel that works.
    Now, while we have confirmed that your system can indeed boot, we haven't yet saved anything on the flash to make it the default, so you need to reboot into the Marvell prompt once more, and this time:
    # First, we start by saving the current working bootargs so that if you ever want
    
    # to get back to Ubuntu, you can issue a "setenv bootargs $(bootargs_rescue)"
    Marvell>> setenv bootargs_rescue $(bootargs)
    Marvell>> setenv bootargs_root root=/dev/mmcblk0p2 rootfs=ext4 rootwait ro
    Marvell>> setenv bootargs $(bootargs_console) $(bootargs_root)
    Marvell>> saveenv
    Saving Environment to NAND...
    Erasing Nand...Writing to Nand... done
    Marvell>> reset
  8. After this last command, the plug should automatically boot into Slackware and you can finalize your installation.

    IMPORTANT: You VERY MUCH want to add a rootwait parameter to your bootargs, which ensures that the SD is ready before the kernel attempts to mount it as rootfs. Otherwise, you may end up with maddening kernel panics when mounting rootfs, especially after a power failure, that are really due to the SD card not being ready yet.
    Another alternative would be to add rootdelay=## but if you read here, you'll see that rootwait is the smarter option.

    One thing you might want to do, as we did during the install, is set the blue LED as an MMC access indicator.
    On my system, I did that by editing /etc/rc.d/rc.S and adding the line:
    # Set the blue LED as SD access indicator
    
    echo "mmc0" > /sys/class/leds/plug\:green\:health/trigger
    just before the section
    # Enable swapping:
    
    /sbin/swapon -a



2 comments:

  1. Regarding step 5: Armedslack 12.2 (the latest I thought) was not able to detect the MMC partitions. I had to modify a setup file (I forget at the moment) to fdisk probe the SD card every time I installed onto a non USB device. Then the installer just cruised along. Are you using armedslack-current? Has this issue been addressed?

    ReplyDelete
  2. Hi John,

    I've encountered that issue altely, and it is due to the SD card not being ready before the kernel attempts to mount it as rootfs. However, the kernel provide boot options such as rootdelay=## or (better) rootwait to address just this scenario. I have no updated the guide above to add rootwait to bootargs_root

    ReplyDelete

Note: only a member of this blog may post a comment.