Friday, April 27, 2012

Using the Qube as a NAS device 2

In an earlier post I forgot to mention that installing NetBSD using the Restore CD option will wipe out your whole drive. So, before I started, I disconnected the hard drive and installed everything on the CF card. A basic installation of NetBSD does not require a lot of space. The 1 GB CF card was big enough for a basic install, but, to be able to use pkgsrc, I installed a 4 GB card.

After I verified the installation was working properly, I decided to connect the hard drive again. This is where the problems started :(

VIA Technologies VT83C572 USB Controller (USB serial bus, revision 0x02) at 
pci0 dev 9 function 2 not configured
tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1
tlp1: interrupting at level 2
tlp1: Ethernet address 00:10:e0:00:3c:5d
lxtphy1 at tlp1 phy 1: LXT970 10/100 media interface, rev. 3
lxtphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
wd0 at atabus0 drive 0: 
wd0: 977 MB, 1986 cyl, 16 head, 63 sec, 512 bytes/sect x 2001888 sectors
wd1 at atabus0 drive 1: 
wd1: 298 GB, 620181 cyl, 16 head, 63 sec, 512 bytes/sect x 625142448 sectors 
Kernelized RAIDframe activated
viaide0:0:1: lost interrupt
       type: ata tc_bcount: 512 tc_skip: 0
viaide0:0:1: bus-master DMA error: missing interrupt, status=0x61
viaide0:0:1: device timeout, c_bcount=512, c_skip0
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), retrying
viaide0 channel 0: reset failed for drive 0 drive 1
viaide0:0:1: lost interrupt
       type: ata tc_bcount: 512 tc_skip: 0
viaide0:0:1: bus-master DMA error: missing interrupt, status=0x61
viaide0:0:1: device timeout, c_bcount=512, c_skip0
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), retrying
... (several minutes, same message)
viaide0:0:1: lost interrupt
       type: ata tc_bcount: 512 tc_skip: 0
viaide0:0:1: bus-master DMA error: missing interrupt, status=0x61
viaide0:0:1: device timeout, c_bcount=512, c_skip0
wd1d: device timeout reading fsbn 1 (wd1 bn 1; cn 0 tn 0 sn 1), retrying
viaide0:0:1: lost interrupt
       type: ata tc_bcount: 512 tc_skip: 0
viaide0:0:1: bus-master DMA error: missing interrupt, status=0x61
viaide0:0:1: device timeout, c_bcount=512, c_skip0
wd1d: device timeout reading fsbn 1 (wd1 bn 1; cn 0 tn 0 sn 1), retrying
wd1: soft error (corrected)
wd1: no disk label
boot device: wd0
Hmmm, strange. This was definitely not a hardware problem, since the disk is fairly new and was working without any issues in Debian Lenny and Squeeze.

I suspected some kind of DMA problem, so I asked the friendly (yes, they are very friendly, not the RTFM kind) people for help. They suggested to recompile the kernel, and make it more suitable for running on my Qube. The following procedure describes how to do this on a recent Linux box (tried on openSUSE 12.1):

Go somewhere on the Linux machine, and do this:

mkdir src tools obj
cvs -d :pserver:anoncvs%anoncvs.netbsd.org@localhost:/cvsroot checkout -PA  -rnetbsd-5 src
This will get you the latest 5.x source tree.
Go to src/sys/arch/cobalt/conf/
Copy GENERIC to some other name, edit it and save it.
Go back to src
Now, create tools ./build.sh -m cobalt tools
Now, build the kernel ./build.sh -m cobalt -T ./tooldir.Linux-3.1.9-1.4-desktop-x86_64 -O ../obj kernel=MyKernel
After a while it will end up in the obj/sys/.../netbsd
Put the kernel (netbsd) in / on the Qube, and rename the old kernel netbsd.old You can choose which kernel is booted at the Qube's boot prompt, by simply typing its name (if you're connected to the serial console).

Disabling DMA in the kernel config (GENERIC) was fairly easy. Locate the following lines:

# IDE drives
# Flags are used only with controllers that support DMA operations
# and mode settings (e.g. some pciide controllers)
# The lowest order four bits (rightmost digit) of the flags define the PIO
# mode to use, the next set of four bits the DMA mode and the third set the
# UltraDMA mode. For each set of four bits, the 3 lower bits define the mode
# to use, and the last bit must be 1 for this setting to be used.
# For DMA and UDMA, 0xf (1111) means 'disable'.
# 0x0fac means 'use PIO mode 4, DMA mode 2, disable UltraDMA'.
# (0xc=1100, 0xa=1010, 0xf=1111)
# 0x0000 means "use whatever the drive claims to support".
wd*             at atabus? drive ? flags 0x0000
Now, do what the documentation says and put 0xf to disable DMA:
wd*             at atabus? drive ? flags 0x0ff0
After compiling the kernel using the above procedure, the Qube boots just fine. What's more important; I can now actually use the machine as a NAS device. I already produced several backups using mondo on the Qube, without any problems.

No comments: