Running Debian on Freecom FSG-3

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Freecom FSG-3 is a small device with these specs:

If the original firmware is too little for you, you can run a full Linux distribution on FSG-3, like Debian (little-endian ARM port).


Contents

[edit] Overview

The process of installing Debian on a FSG-3 needs these steps:

You don't need to open the device.

Certainly, you also need some Linux knowledge.

Although it's not likely to brick the device if you understand and follow this HOWTO carefully - it can always happen. It's your risk, and you're the only person responsible. Don't blame me for that.
You can always repair the bricked device using a serial cable and/or JTAG.


We use "original FSG-3" when we refer to a new FSG-3 with original firmware.

We use "custom FSG-3" when we refer to a FSG-3 on which we already flashed a new kernel and a new bootloader configuration.


The kernel we flash contains a minimal initramfs. When kernel boots from flash, it tries to detect if there is any USB mass-storage device connected, tries to mount /dev/sdb2, checks if it has a /etc/emergency file there. If all conditions are met, the kernel tries to boot the operating system from that device.

This means that you can always boot the system from the USB-stick and repair it if you need.

[edit] USB-stick preparation

You need to have a USB stick of at least 256 MB. You need to set up two primary partitions on it (sda - USB stick):

/dev/sda1 - swap
/dev/sda2 - ext3 partition

Why this layout? It will match the layout on HDD.

Uncompress and copy the contents of fsg-3-deploy-stick.tar.bz2 to the ext3 partition (/dev/sda2) of the USB-stick. fsg-3-deploy-stick.tar.bz2 is available in downloads.


[edit] Configuration on the original FSG-3

http://192.168.1.1/admin/



$ ssh admin@192.168.1.1
admin@192.168.1.1's password:admin
~ $ su
root password:loginasrootisrisky
Login successful. Beware, you are root now!
/ #

Note that you can use the passwd command here to change the root password to something easier to remember.

Make sure your MTD partition layout is like below:

/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 00180000 00020000 "kern1"
mtd2: 00180000 00020000 "kern2"
mtd3: 00020000 00020000 "RedBoot config"
mtd4: 00020000 00020000 "FIS directory"

This layout has been verified correct for firmware versions 3.3.9, 3.3.14 and 4.1.6 - please check carefully if you are running other firmware versions.

Each MTD partition needs an explanaton:

"RedBoot" is /dev/mtd0, it's RedBoot bootloader, don't touch it.
"kern1", or /dev/mtd1, is the original FSG-3 kernel, also, don't touch it.
"kern2", or /dev/mtd2, is empty; this is where we'll flash our kernel.
"RedBoot config", or /dev/mtd3, is where the configuration of RedBoot is kept. Here we'll flash our own bootloader config.
"FIS directory", or /dev/mtd4, stands for Flash Image System, and also, don't touch it.

Note that after we flash a new kernel, the partition layout will change - the new kernel sees unallocated space on flash as separate place (you can put custom things there).


Also, because flashing is a dangerous process if we do it wrongly, and newer FSG-3 models can theoretically have MTD partition layout changed - we want to inspect the contents of the bootloader configuration ("RedBoot config"):

/ # strings /dev/mtd3
boot_script
boot_script_data
boot_script
fis load kern1
exec -c "console=ttyS0,115200 root=/dev/hda1 mem=64M@0x00000000
boot_script_timeout
boot_script
bootp
bootp_my_gateway_ip
bootp
bootp_my_ip
bootp
bootp_my_ip_mask
bootp
bootp_server_ip
bootp
console_baud_rate
dns_ip
gdb_port
info_console_force
info_console_number
info_console_force
net_debug
net_device
npe_eth0
npe_eth0_esa
npe_eth1_esa
H3'U

The first line marked in bold tell that by default, the bootloader loads the kernel from "kern1", in our case, /dev/mtd1. This means, we can safely flash a new kernel on "kern2" (/dev/mtd2).
The second line are the options passed to the kernel. The root= line will refer to either /dev/hda1 or /dev/hda2 depending on how many times you have updated the firmware (it alternates each time). Note that the /dev/hda1 will be /dev/sda1 in version 4.x firmware.


/ # mount
/dev/hda1 on / type reiserfs (rw,noatime,nodiratime)
/proc on /proc type proc (rw)
none on /proc/bus/usb type usbdevfs (rw)
/dev/hda4 on /home type reiserfs (rw,noatime,nodiratime)
/dev/sda2 on /home/Cruzer_Mini_132 type ext3 (rw,noatime,nodiratime)

(For version 4.x firmware, replace /dev/hda[1-4] with /dev/sda[1-4] and /dev/sda2 with /dev/sdb2)

Our USB-stick was mounted in /home/Cruzer_Mini_132. We go to a directory containing a kernel and a new bootloader configuration:

/ # cd /home/Cruzer_Mini_132
/home/Cruzer_Mini_132 # cd root/deploy/
/home/Cruzer_Mini_132/root/deploy # 


You need to erase kernel partition's contents first:

/home/Cruzer_Mini_132/root/deploy # erase /dev/mtd2 0 12 1
Erase Total 12 Units
Performing Flash unlock at offset 0x160000 done offset 0x160000


...and flash a kernel:

/home/Cruzer_Mini_132/root/deploy # dd if=kernels/2.6.20/vmlinuz-fsg3-2.6.20-arm of=/dev/mtd2
2143+1 records in
2143+1 records out


Next, flash a new RedBoot config, which will start FSG-3 using a new kernel.

WARNING: This will permanently change the MAC addresses of your WAN and LAN ethernet interfaces (as those values are stored in the Redboot config partition).

/dev/mtd3 is smaller, and that's why we use different erase options:

/home/Cruzer_Mini_132/root/deploy # erase /dev/mtd3 0 1 1
Erase Total 1 Units
Performing Flash unlock at offset 0x0 done offset 0x0
/home/Cruzer_Mini_132/root/deploy # dd if=redboot-config/redboot-config of=/dev/mtd3
256+0 records in
256+0 records out


/home/Cruzer_Mini_132/root/deploy # reboot

The system is going down NOW !! Sending SIGTERM to all processes. Connection to 192.168.1.1 closed by remote host. Connection to 192.168.1.1 closed.

Shortly, you should see USB-stick flashing and blinking as it loads the system.

[edit] Configuration on the custom FSG-3

Log in to FSG-3 running Debian on USB-stick (password is toor) - IP is 192.168.111.188/255.255.255.192 (make sure you have proper netmask on the machine you are connecting from):

$ ssh -l root 192.168.111.188

Another possiblility is to use a USB-serial cable - connect the serial part to your PC, and USB part to the FSG-3.

Port settings are:

Bps/Par/Bits  : 115200 8N1
Hardware Flow Control : No
Software Flow Control : No


Debian GNU/Linux 4.0 fsg-3-usb ttyUSB0

fsg-3-usb login: root
Password:
Linux fsg-3-usb 2.6.20 #60 PREEMPT Wed Feb 21 12:18:31 CET 2007 armv5tel

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
fsg-3-usb:~# 


Now, do these things:

[edit] Downloads

fsg-3-deploy-stick.tar.bz2 - a customized minimal Debian (ARM, LE)
Size: 66530995 bytes
md5sum: a8d31c29614b6a21505febdef9ec74a7
Please see http://lists.wpkg.org/pipermail/debian-non-standard/2008q2/000114.html for a security note.

initramfs - initramfs embedded in the kernel
Size: 57429 bytes
md5sum: 02622575d83bf69e1d8c5a0c9c32b6b8

[edit] Troubleshooting

[edit] flash partition layout

The new kernel will see a different flash partition layout - it sees unallocated space on flash as separate partitions (you can put custom things there).

New kernel:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 00040000 00020000 "unallocated"
mtd2: 00180000 00020000 "kern1"
mtd3: 00180000 00020000 "kern2"
mtd4: 00040000 00020000 "unallocated"
mtd5: 00020000 00020000 "RedBoot config"
mtd6: 00020000 00020000 "FIS directory"


Old kernel:

/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 00180000 00020000 "kern1"
mtd2: 00180000 00020000 "kern2"
mtd3: 00020000 00020000 "RedBoot config"
mtd4: 00020000 00020000 "FIS directory"


Here's a small table that summarizes the change:

what     orig FSG-3     custom FSG-3
kern2    /dev/mtd2      /dev/mtd3
redboot  /dev/mtd3      /dev/mtd5

Don't forget about it if you want to change the kernel in the future!


[edit] controlling fan

This one disables fan:

echo 0 > /sys/devices/platform/IXP4XX-I2C.0/i2c-0/0-0028/pwm1


This one sets fan at full speed:

echo 255 > /sys/devices/platform/IXP4XX-I2C.0/i2c-0/0-0028/pwm1

You can also choose any other value between 0 and 255.

You can use it in your shutdown scripts (don't forget to disable the HDD, too).

Note that disabling fan during normal work can be dangerous!


[edit] LEDs, buttons

Currently, they don't work.

See NSLU2 mailing lists for an update on that.


[edit] kexec

The kernel has kexec support. This means, you don't have to flash a kernel if you want to boot it: it's enough to load and execute a new kernel:

fsg-3-usb:~/deploy/kernels/2.6.20# kexec -l zImage
fsg-3-usb:~/deploy/kernels/2.6.20# kexec -e
(wait a minute or so... you will be able to login again once the device boots again)

[edit] kernel

The kernel was built from NSLU2 svn kernel trunk (revision 695 from 14-Feb-2007).

If you want to build a new kernel, you can use the config in /proc/config.gz.

Important!
The device starts in big-endian mode, but this kernel runs in little-endian mode. This means, that any LE kernel you write on flash needs to have bytes swapped. If you use NSLU2 build, it will be done by default - vmlinuz-fsg3-2.6.20-arm will be the file you want to flash.
If you're unsure, don't flash the kernel anymore, use kexec to load a new kernel (and adjust your startup scripts appropriately to start kexec just once) - it's way safer.


[edit] initramfs

The kernel used here contains an embedded initramfs: it starts after the kernel is executed, and tries to detect if there is a USB-storage device connected, and if yes, if it contains /etc/emergency file (can be empty).
If both conditions are met, the kernel will try to boot from USB-storage device (USB-stick etc.) - this can be handy if you screw your filesystem, and you want to boot from another device.

If you want to use it with your custom kernel, download initramfs.tar.bz2 from the downloads section, uncompress it, and make sure your .config points where initramfs files are:

CONFIG_INITRAMFS_SOURCE="/home/build/checkout/initramfs"


[edit] compiling custom kernel modules

To compile custom kernel modules:

All that on your FSG running Debian of course.


[edit] wireless

If your model didn't have a wireless card when you bought it, it has been reported that Atheros mini-PCI cards work fine with FSG-3.

If you want to use madwifi, you will have to compile it yourself. If it's too difficult for you, see Atheros on FSG-3.

[edit] other

For other troubleshooting ideas, see troubleshooting Debian on ASUS WL-500g Deluxe / Premium.

Device currently shipped seem to have marvel based wifi cards

[edit] Contact and support

If you have any questions, please subscribe to the mailing list on http://lists.wpkg.org/mailman/listinfo/debian-non-standard

For general debian-arm info, please ask at debian-arm mailing list.
For more specific questions, try NSLU2 mailing lists: http://www.nslu2-linux.org/wiki/Main/MailingLists



To make sure Debian is well supported on arm architecture, please participate in Debian Popularity Contest. To do it, install popularity-contest package:

# apt-get install popularity-contest
Personal tools
Namespaces
Variants
Actions
Navigation
ideas?
Toolbox