Fixing pluggy

Photo of rather dusty, but working, pluggy the plug computer and its attached drive working as file server etc.
rather dusty, but working, pluggy the plug computer and its attached drive working as file server etc.

Pluggy the plug computer isn’t broken, but it’s not all working too well. And I’m not sure how some of the bits that are working are working. And there is a whole load of cruft on there that I tried out and forgot about and who knows whether that is working. And there are some things that could work better, like time to reboot, and being able to run NFS. Anyway, time for an update.

Step 1. decide what I want to keep.  Pluggy is always on and is connected to a 1GB USB HDD, it acts as a file and print server by running samba, and as a uPnP media streamer running Twonky. It also runs get_iPlayer which gives it a sort of PVR role. I added a bit to get_iPlayer to remux with ffmpeg so that our PS3 would recognise the files it saves.

Step 2. make sure I’ve got copies of the software and config files that does what I want to keep. So, from a backup directory on the USB HDD

tar -cvpzf ./backup.tar.gz /usr /home /[just about everything except the USB HDD!]

 

[being careful not to include the mount point for the disk where the backup was being stored!]

Step 3. pre-reqs for installing the new file system on pluggy.  I’ll be upgrading the bootloader installing UBIFS for faster reboots, following these instructions, and installing Debian following these.

a) I need a tftp server so on my main computer

sudo apt-get install xinetd tftpd tftp

create /etc/xinetd.d/tftp as

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /home/phil/tftpboot
disable = no
}

make the /home/phil/tftpboot directory chmod it to 777 and chown it to nobody. Create a test file in that directory. Restart xinetd:

sudo service xinetd restart

On another machine (my laptop):

sudo apt-get install tftp
[...]
tftp 192.168.0.222
tftp> get test
tftp> [cntl-D]
cat test

and test was what it should be.

b) Plug computers run headless. Normally I access pluggy while it is running using ssh, but for this I need acces while it is booting so I’ll need to access via a serial console. I use cu

cu -s 115200 -l /dev/ttyUSB0

but I needed to chmod 666 /dev/ttyUSB0 before this would work, even as sudo.

This gives me terminal access, so that when I reboot I see the Marvell U-Boot message:

 
     __   __                     _ _
    |  \/  | __ _ _ ____   _____| | |
    | |\/| |/ _` | '__\ \ / / _ \ | |
    | |  | | (_| | |   \ V /  __/ | |
    |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_ 
| | | |___|  _ \ / _ \ / _ \| __| 
| |_| |___| |_) | (_) | (_) | |_ 
 \___/    |____/ \___/ \___/ \__| 
 ** MARVELL BOARD: SHEEVA PLUG LE 

U-Boot 1.1.4 (Mar 19 2009 - 16:06:59) Marvell version: 3.4.16

U-Boot code: 00600000 -> 0067FFF0 BSS: -> 006CEE80

Soc: 88F6281 A0 (DDR2)
CPU running @ 1200Mhz L2 running @ 400Mhz
SysClock = 400Mhz , TClock = 200Mhz 

DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000 size 256MB 
DRAM CS[1] base 0x10000000 size 256MB 
DRAM Total size 512MB 16bit width
Flash: 0 kB
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:512 MB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled 
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
Net: egiga0 [PRIME], egiga1
Hit any key to stop autoboot: 0 
Marvell>>

[that’s after I hit the ‘any’ key]

Typing printenv at that prompt gives me a backup of the environment setting. and print ethaddr  00:50:43:01:64:26.

4. Installing new U-Boot. That’s a 2009 U-Boot I had from when I first bought pluggy. The latest I could find was this one from 2013 via Matthias Blaicher whose info on upgrading to Debian I mentioned above. I copy that to the tftp server directory on my main computer, gice everybody read access to it (chmod a+r…) and via the serial console, on pluggy (who is still waiting, paused mid-boot), following these instructions and those on Matthias’s page:

Marvell>> setenv serverip 192.168.0.2 
Marvell>> setenv ipaddr 192.168.0.100
Marvell>> tftpboot 0x0800000 u-boot.kwb
Using egiga0 device
TFTP from server 192.168.0.2; our IP address is 192.168.0.100
Filename 'u-boot.kwb'.
Load address: 0x800000
Loading: #################################################################
 ########
done
Bytes transferred = 371912 (5acc8 hex)
Marvell>> nand erase 0x0 0x60000
NAND erase: device 0 offset 0x0, size 0x60000
Erasing at 0x40000 -- 100% complete.
OK
Marvell>> nand write 0x0800000 0x0 0x60000
NAND write: device 0 offset 0x0, size 0x60000
 393216 bytes written: OK
Marvell>>reset

Get diverted because the reset closes the serial console and cu refuses to connect again saying that ttyUSB0 is in use, fix that by rebooting the main machine (there must be a better way), re-power pluggy and see

*** Warning - readenv() failed, using default environment
In: serial
Out: serial
Err: serial
Net: egiga0
Warning: failed to set MAC address

as expected. Interrupt the boot by hitting the any key to enter

Marvell>> setenv ethaddr 00:50:43:01:64:26
Marvell>> saveenv
Marvell>> resetMarvell>> reset
resetting ...


U-Boot 2013.10-rc1-00034-g2b26201 (Aug 26 2013 - 07:58:32)
Marvell-Sheevaplug

SoC: Kirkwood 88F6281_A0
DRAM: 512 MiB
WARNING: Caches not enabled
NAND: 512 MiB
In: serial
Out: serial
Err: serial
Net: egiga0
88E1116 Initialized on egiga0
Hit any key to stop autoboot: 0 
Marvell>>

[hitting that any key…]

5. Install debian, following the instructions on cyrius.com, download debian’s uImage and uInitrd into the tftp directory, chmod them a+r. On pluggy:

setenv serverip 192.168.0.2
setenv ipaddr 192.168.0.100
tftpboot 0x00800000 uImage
tftpboot 0x01100000 uInitrd 
setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most
bootm 0x00800000 0x01100000

and away it goes.

Problem:

Network autoconfiguration failed
Your network is probably not using the DHCP protocol. Alternatively, the DHCP server may be slow or some network hardware is not working properly.
2014-10-11 19.14.31
Shiny rejuvenated pluggy during the update

so I had to enter pluggy’s IP addr etc by hand. I kept the domain blank (had some problem connecting to debian mirrors when I entered something).

I installed Debian on a 4GB MMC/SD card, all files in one partition, with the default options. Chose to install the print server and file server, but not the desktop environment (not enough space on SD card).

Step 6. Set up bootloader to boot from SD card and copy Debian image from there to the onboard UBIFS flash. Found out that this bootloader won’t boot from an SD card, so I put the SD card into a USB SD drive and set the following environment & boot:

setenv bootargs_console console=ttyS0,115200
setenv bootcmd_usb 'usb start; ext2load usb 0:1 0x00800000 /uImage; ext2load usb 0:1 0x01100000 /uInitrd'
setenv bootcmd 'setenv bootargs $(bootargs_console); run bootcmd_usb; bootm 0x00800000 0x01100000'
saveenv

which booted Debian and allowed me to log inplug Login

So that’s debian running from an SD mounted as a USB drive, now need to format plugs main flash drive as UBIFS and mount it:

phil@plug:~$ su root
Password: 
root@plug:/home/phil# apt-get install mtd-utils
[...]
root@plug:/home/phil# ubiformat /dev/mtd2 -s 512

Decided to continue after warnings that some erase blocks had non UBIFS data and an invalid erase counter.

root@plug:/home/phil# ubiattach /dev/ubi_ctrl -m 2
root@plug:/home/phil# ubimkvol /dev/ubi0 -N rootfs -m
root@plug:/home/phil# mkfs.ubifs --compr=zlib /dev/ubi0_0
root@plug:/home/phil# mount -t ubifs ubi0:rootfs /mnt
[ 1087.074669] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
...

and copy the debian boot to the flash drive

root@plug:/home/phil# mkdir /tmp/rootfs
root@plug:/home/phil# mount -o bind / /tmp/rootfs/
root@plug:/home/phil# cp -a /tmp/rootfs/* /mnt/
root@plug:/home/phil# cp -a /boot /mnt/

(that first cp takes a while)

Edit /mnt/etc/fstab (that is the fstab on the flash drive) to be:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
ubi0:rootfs / ubifs defaults,noatime,rw 0 0
tmpfs /var/run tmpfs size=1M,rw,nosuid,mode=0755 0 0
tmpfs /var/lock tmpfs size=1M,rw,noexec,nosuid,nodev,mode=1777 0 0
tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0

Step 7. Set up to boot from the ubi partition. Reboot plug and hit the any key to enter u-boot.

Hit any key to stop autoboot: 0 
Marvell>> setenv mtdids nand0=orion_nand
Marvell>> setenv mtdparts mtdparts=orion_nand:0xa0000@0x0(u-boot),0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs)
Marvell>> setenv bootargs_ubi 'console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs'
Marvell>> setenv bootcmd_ubi 'ubi part nand0,2; ubifsmount ubi0; ubifsload 0×1100000 /boot/uInitrd; ubifsload 0×800000 /boot/uImage'
Marvell>> setenv bootcmd 'setenv bootargs $(bootargs_ubi); run bootcmd_ubi; bootm 0x00800000 0x01100000'
Marvell>> saveenv
Saving Environment to NAND...
Erasing NAND...
Erasing at 0x60000 -- 100% complete.
Writing to NAND... OK
Marvell>>

(comment Matthias Blaicher blog says bootargs_ubi depends on version of u-boot.) On booting get

Loading file '/boot/uInitrd' to addr 0x00000000 with size 7452840 (0x0071b8a8)...
Done
Loading file '/boot/uImage' to addr 0x00000000 with size 1612096 (0x00189940)...
Done
Wrong Image Format for bootm command
ERROR: can't get kernel image!
Marvell>>

Comment on Matthais Blaicher blog suggests using ‘U-Boot 2012.04.01 (Jun 01 2012 – 02:27:06)’. So I get a copy  of U-Boot from cyrius, run through step 4 again. Re-enter the u-boot envs above, but this time with

setenv bootargs_ubi 'console=ttyS0,115200 ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs'

(output of printenv)

AND IT WORKS

pluggy is up and running debian (now I just need to set up the file sharing, print serving and media streaming stuff)

One thought on “Fixing pluggy

  1. Had problems upgrading the kernel to 3.2.0-4-kirkwood, which always ended with the following:
    root@plug:~# Warning: root device ubi0:rootfs does not exist
    root@plug:~# Press Ctrl-C to abort build, or Enter to continue

    and which left apt-get install complaining about unfinished installations.

    Tried all sorts things to get ubi0:rootfs recognised, but in the end this bug report gave the solution: remove flash-kernel.

Comments are closed.