Building SnapGear

From NAS-Central MRT Wiki
Jump to: navigation, search

The OpenFSG firmware for the [Freecom Network Drive Pro] is a lovely firmware which would be ideal for the MRT Giganas. It's mature, well written, nearly bugfree and comes with lots of really cool features (and it's NOT based on Sausalito!). Unlike Sausalito, Snapgear actually care about creating a properly working NAS box (as you can tell from the many tiny bug fixes in the ChangeLogs). The Freecom NDP uses nearly identical hardware to the Giganas ie; the Storlink Gemini, so porting it should be easy enough.

The following is the attempts to build a working version of this firmware for the MRT Giganas. Please use & add to it any further information you find.

Random notes on building SnapGear firmware for GigaNAS

Before building anything, you will need to slightly patch the sources. Patch the file linux-sl3516/drivers/mtd/maps/sl2312-flash-cfi.c:

--- sl2312-flash-cfi.c.old	2007-02-10 19:21:21.000000000 +0000
+++ sl2312-flash-cfi.c	2008-06-30 04:21:35.006431131 +0100
@@ -33,7 +33,7 @@
 #include <asm/system.h>
 #include <asm/arch/sl2312.h>
 #include <linux/mtd/kvctl.h>
-#include "sl2312_flashmap.h"
+#include "sl2312_flashmap.h.16MB"
 //extern int parse_afs_partitions(struct mtd_info *, struct mtd_partition **);
@@ -153,14 +153,14 @@
 	sl2312flash_map.virt = FLASH_VBASE;//(unsigned int *)ioremap(SL2312_FLASH_BASE, FLASH_SIZE);
-	sl2312flash_map.virt = (unsigned int *)ioremap(SL2312_FLASH_BASE, FLASH_SIZE);
+	sl2312flash_map.virt = (unsigned int *)ioremap(SL2312_FLASH_BASE, FLASH_SIZE);
 	//printk("sl2312flash_map.virt  = %08x\n",(unsigned int)sl2312flash_map.virt);
 //	simple_map_init(&sl2312flash_map);
-	mtd = do_map_probe("amd_flash", &sl2312flash_map);
-//	mtd = do_map_probe("cfi_probe", &sl2312flash_map);
+//	mtd = do_map_probe("amd_flash", &sl2312flash_map);
+	mtd = do_map_probe("cfi_probe", &sl2312flash_map);
 	if (!mtd)
@@ -184,7 +184,7 @@
     sl2312flash_disable_parallel_flash();      /* disable Parallel FLASH */
-    //printk("SL2312 MTD Driver Init Success ......\n");
+    printk("SL2312 MTD Driver Init Success ......\n");
 	return ret;

This restores the flash ROM partitioning scheme to the one which MRT uses (that's the sl2312_flashmap.h.16MB) and it also alters the flash ROM type detection as the cfi_probe is the correct driver for the MRT).

The general build process (you can get the latest firmware sources from [OpenFSG Firmware] at the bottom of the page):

  • Download Freecom Kernel
  • Download Freecom SnapGear
  • Download Toolchain
  • Unpack them to /usr/src (they have to be there)
  • Switch user to root (eg; 'sudo -s') as building needs root to chown the files
  • Modify the files inside fcsnap/vendors/Freecom/Versatile4/ with any customisations you might like. In here live kernel config, package config, fstab config etc.
  • Run 'make menuconfig' or 'make xconfig'. Choose the 'Versatile4' target. If you modified the vendor config, remember to reset & vendor settings to default.
  • Run 'make'

The firmware output (into /usr/src) is pretty useless as-is as it's in a format MRT's RedBoot doesn't understand (it's a tar.bz2 with a CRC appended to the front and the entire image XORed with a running CRC). Hence you'll want to intercept the firmware build as follows:

  • Open to fcsnap/tools/create_update
  • At the bottom, simply modify to like this to have the tar.bz2 copied out:
grep -q sl3516 etc/version
if [ $? = "0" ]; then
  echo -n "Creating VT4 image..."
  tar cfj update.tar $FILES
  cp update.tar ../../vt4-$VERSION.tar.bz2
  mv update.tar ../../vt4-$VERSION.bin
  ../tools/encode_crc ../../vt4-$VERSION.bin VT

Having this tar.bz2 is rather handy because OpenFSG expects a certain disk layout and this tar file needs to be extracted into the first partition of your hard drive. You will need to connect your hard drive to your Linux box, wipe its partition table and create the following using fdisk (or equivalent):

  • partition 1, 256Mb ext3
  • partition 2, either leave empty or don't create it.
  • partition 3, 512Mb of swap
  • partition 4, as big as you like but in jfs

Extract the tar image into partition 1. Return the hard drive to the Giganas, but MAKE SURE you plug it into the SATA connector nearest the fan (ie; the top one). This is because OpenFSG expects the primary hard drive to be at /dev/hdd and only the top connector is hdd (the bottom one is hdc).

Ok, you'll now need to flash the new kernel image. You can find this inside fcsnap/romfs/boot. It's probably best to do this via the serial console and Redboot.

With these instructions you'll get a fully booting kernel which manages to mount /dev/hdd1 as the root partition but then it inexplicably kernel panics with an "Attempted to kill init" which indicates that the init process tried to kill itself. I am afraid I have not been able to config the kernel to output a stack backtrace - if someone knows how to do this, you can find out the source and fix it.

One thing which would be well useful is to inspect a real Freecom NDP to see how it works. In particular, I have guessed the above partition scheme from the NDP firmware sources - who knows what it really is!

Good luck! ned14