Tuesday, March 6, 2012

Arch Linux on a Netgear Stora

I got one of these recently.

It is basically a Plug Computer, with the following specs:

My goal is to put Arch Linux on it. It seems that no one has done this yet.

What I am going to do, is set-up the system with Debian, which boots from the hard disk. There a number of recipes around to do this, particularly on the openstora.com site. I am following this one http://www.openstora.com/phpBB3/viewtopic.php?t=217

It did not contain all the information, so I thought about writing this walk through and fill in some blanks.

What you need to start is a USB serial cable. I got a Nokia phone data cable from eBay for a few Euros. Cut the end off the cable and solder some header thing on it. I used and old PC motherboard cable that I chopped up.

You also need some method to access the disk as a USB device. I used an old dismantled external drive controller board, which was handy.

To remove the back panel, you need to remove the two screws behind the Disk Release Latches. There are two of those nasty plastic clips about 5cm in from each side. There are two more of these nasty fellas about 9cm down from the top on the left and right side. Gently prise the panel with a small screw driver and it should pop off. Pop it off from the top as there are two clips on the bottom of the panel. These can be seen when looking at the bottom of the case.


You can see the serial port pins at the top of the board.

The pin-outs are from right to left:

Pin     Function     Notes
1     3.3Vdc     Pin is the farthest from the battery.
2     RXD     Recieve Data line from Stora.
3     TXD     Transmit Data line from Stora.
4     GND     Ground.

I will be using 2, 3 and 4, as I have cable made from an old Nokia USB data cable.


I installed  tftp-hpa on the laptop, as the tftp server.

Connect stora to real network

Set-up environment for flashing.

setenv mainlineLinux yes
setenv arcNumber 2743
setenv ipaddr XXX.XXX.XXX.XXX   #This is the IP of your Stora
setenv serverip XXX.XXX.XXX.XXX #This is the IP of your TFTP server
saveenv
reset

The install the files from your tftp server


tftpboot 0x200000 uImage.di
tftpboot 0x800000 uInitrd.di
setenv bootargs console=ttyS0,115200n8 base-installer/initramfs-tools/driver-policy=most
bootm 0x200000 0x800000


This will install Debian to the hard disk.

The disk partitioning takes a long time, 40 minutes or so, so go and have a cup of tea or a beer. I wouldn't recommend reboot at this time, cuz I don't know what state the Stora would be in. Perhaps and expensive brick.

Then, it begins installing the system..............

I then followed the remaining instructions on http://www.openstora.com/phpBB3/viewtopic.php?t=217

I got quite a few errors but kept going.

Presto chango! Debian!

aka FAIL

It wouldn't boot. Feck again.

I scrolled down further on that page and began to experiment a bit with the settings.


setenv bootcmd_ide 'ide reset; ext2load ide 0 0x200000 /boot/uImage; ext2load ide 0 0x800000 /boot/uInitrd'

setenv bootcmd 'setenv bootargs $(console) root=/dev/sda1; run bootcmd_ide; bootm 0x200000 0x800000'

saveenv

reset

Again FAIL. Again Feck.

I took out the drive and connected it via USB to my laptop.

I ended up with a single partition that had some GPT data in the partition table

# fdisk -l /dev/sdb

WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk
doesn't support GPT. Use GNU Parted.

Feck again.

I used this link to remove it http://www.rodsbooks.com/gdisk/wipegpt.html

All cool.

Install Arch Linux

My next plan, was to prepare the disk and put an arm version of Arch Linux on it.

What you need is, the board ot whatever to connect your SATA drive to a USB cable. Connect it up.

Mine was /dev/sdb

Partition New Disk

I wanted to have the following disk layout:

/dev/sdb1 = 2Gb plenty of space. I don't want to have to worry that it will fill up and require maintenance at a later date.

/dev/sdb2 = swap of 1Gb

/dev/sdb3 = The rest of the disk


I have taken out some of the disk detail because it just clutters up the page.

> fdisk /dev/sdb

Delete whatever partitions are on the disk.


Command (m for help): p

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3907029167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167): +20G

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2):
Using default value 2
First sector (41945088-3907029167, default 41945088):
Using default value 41945088
Last sector, +sectors or +size{K,M,G} (41945088-3907029167, default 3907029167): +1G

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (1-4, default 3):
Using default value 3
First sector (44042240-3907029167, default 44042240):
Using default value 44042240
Last sector, +sectors or +size{K,M,G} (44042240-3907029167, default 3907029167):
Using default value 3907029167

Command (m for help): p

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41945087    20971520   83  Linux
/dev/sdb2        41945088    44042239     1048576   83  Linux
/dev/sdb3        44042240  3907029167  1931493464   83  Linux

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41945087    20971520   83  Linux
/dev/sdb2        41945088    44042239     1048576   82  Linux swap / Solaris
/dev/sdb3        44042240  3907029167  1931493464   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Done

Set-up the file systems and install Arch and Kernel files


I wanted to have journeling so I setup /dev/sdb1 to ext3. It should be reognised as ext2 on boot.

mkfs.ext3 /dev/sdb1

mkfs.ext4 /dev/sdb3

Mount /dev/sdb1 and cd to the mount point

wget http://archlinuxarm.org/os/ArchLinuxARM-armv5te-latest.tar.gz

extract the Arch linux tarball to the root of /dev/sdb1

e.g.

tar zxvf /location/ArchLinuxARM-armv5te-latest.tar.gz


kernel image: http://dl.dropbox.com/u/1397036/stora_di/uImage
initrd image: http://dl.dropbox.com/u/1397036/stora_di/uInitrd

wget the images and copy them into the boot directory of /dev/sdb1

Almost complete.

Finally put the disk back in the stora in the left slot.

Boot into the uBoot prompt.

Here are the settings I found that worked.

setenv mainlineLinux yes
setenv arcNumber 2743
setenv bootcmd_ide 'ide reset; ext2load ide 0 0x200000 /boot/uImage; ext2load ide 0 0x800000 /boot/uInitrd'
setenv bootcmd 'setenv bootargs $(console) root=/dev/sda1; run bootcmd_ide; bootm 0x200000 0x800000'
saveenv
reset

Let it run and it should boot into Arch Linux.

Woo Hoo !!!


Restore Original Firmware

It seems that the original firmware is stilled in Nand. To restore this use the following:

setenv mainlineLinux=no
setenv arcNumber
setenv bootcmd_ide
setenv bootcmd 'nand read.e 0x800000 0x100000 0x300000; setenv bootargs $(console) $(bootargs_root); bootm 0x800000'
saveenv
reset

Back to Arch Linux

setenv mainlineLinux yes
setenv arcNumber 2743
setenv bootcmd_ide 'ide reset; ext2load ide 0 0x200000 /boot/uImage; ext2load ide 0 0x800000 /boot/uInitrd'
setenv bootcmd 'setenv bootargs $(console) root=/dev/sda1; run bootcmd_ide; bootm 0x200000 0x800000'
saveenv
reset 


The End

Now to put it back together, set it up with the services I want and put it into production as a house file server and some other sneaky things.