« Previous | Next»

Thecus N2100: Testing a kernel prior flashing

Posted by coldtobi | 17 Apr, 2008, 23:56

Update July 2009: Please see here for addtional informations.

Occasionally there is a new kernel out for the Thecus N2100, debian flavoured.

And because of personal experience, it is good to test it before flashing it to the embedded flash.
In my case, I needed that one time, as the new kernel would not boot for whatever reason.
The trick is, that you can load the kernel into RAM and execute it from there.

Of course, you can also use it to "test" the Debian installer, before actually overwriting the original firmware.
(BTW, if you only want to test a newly created RAM disk, this is also like testing a kernel -- the RAM disk would
be also flashed, so you can test your modification without any risk, if you run the it "out of RAM"

As another benefit -- if you decided not to use debian but the stock firmware -- this might become handy if you need a
rescue system. Yes, you could use the debian installer also for a rescue enviroment, and as thecus is "only" using Linux,
there are not problems to be expected.

Last but not least, in the unlikely event that you didn't like the Debian experience you can upload the original firmware back into
the Thecus.

Enough talking, Lets get started!

(Please note, that I assume some Unix knowledge in this article. I do not advise Linux novices to install debian on their NAS. For completeness, if this screws it up, this is your problem not mine, as this is soley your responsibility.)


PC Preparations

First, you need to install a tftp server on your PC, as we will have to transfer the new kernel to the RedBoot bootloader. And RedBoot "only" speaks tftp.

For Linux, you can install atftpd, which need almost no configuration. For Windows, there ist also some software, but I guess you'll gonna have to ask your favorite
search engine. ;-)

Back to atfptd. Install the server and then create the directory /var/lib/tftpboot . This directory is the "server directory", and the only thing we need to do is to place the
files we need into that directory. But first we need these files.

Getting the files

As I came up with some scenarios before, and the scenarios determines the files you need.

1. Testing a kernel

Of course, this assumes that you have already a working installation on your NAS. And usually you want to test it after an upgrade. But halt, first you have to tell debian that it won't automatically install the new kernel into the flash chips. So log in and check

 thecus:/etc# cat kernel-img.conf
# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = yes
#postinst_hook = flash-kernel

If the "postinst_hook" is not commented out, please change that, or the kernel will be automatically flashed.
After you are sure that it won't be flashed, install the kernel as you also would do. (Please be careful when installing
the same version of the kernel could (with bad luck) mess around with /lib/modules/2.6.xx.)

Okay, now you installed the kernel. Fine. The installation created two files in /boot. The kernel (vmlinuz-"version") and the corresponding ram-disk
(initrd.img-"version"). You'll need both, so copy them to your PC.

2. Rescue System and "Dry-Run" installation of Debian

For the rescue scenario, download the debian installer image as you if you want to install Debian. (See the Installtion HowTo, Part 2 on this blog)
The file you get is n2100.bin

Then do this to the file:

openssl enc -d -des -in n2100.bin -out upgrade.tar.gz -K 7A9816A4C275D557 -iv 0 -nosalt -nopad
tar xzf upgrade.tar.gz

(In my case, tar failed. However it turned out, that everything is perfectly fine, so you can ignore this error.)

Now you get the files you want in the upgrade directory: initrd and vmlinuz.

3. Return to the original firmware.
(Note: I did not test this scenario, but it should work..)

This is basically the same as 2. But this time, you need to get the original firmware from thecus.com. Get the file and do the same as you would do in 2.
This also gives you two files: the ramdisk and the kernel. (ramdisk.arm and zImage.)

Ready. Set. Go.

Now that you got your files, copy them to /var/lib/tftpboot. Make sure, that the rights are set up properly, maybe you want it to make it world-readable.
(As atftpd is launched via inetd, this is all you need to do configuring it.)

Now, enter RedBoot as described here. After you're "in", you'll need to setup IP for Redboot: (Make sure to fill the placeholders)

ip_address -l <ip_address_thecus>    
ip_address -h <ip_address_PC>

hints: (if you followed Is RedBoot via Ethernet available on my Thecus N2100)
<ip_address_PC> is

Then load the kernel into the RAM:

load -r <initrd-filename> -b 0x00800000
load -r <vmlinux-filename> -b 0x00200000

<initrd-filename> is the initrd or ramdisk.arm. (The one in your /var/lib/tftpboot)
<vmlinux-filename> is the vmlinuz-* or zImage. (The one in your /var/lib/tftpboot)
If you get any error, check your writing and maybe there could be some atftp issue. Check
the logs or start it in the foreground to be sure.

Then, execute the kernel.

exec -c "console=ttyS0,115200 root=/dev/ram0 initrd=0xa0800000,42M mem=128M@0xa0000000"

As an additional hint, you could also replace the mem=128M@0xa0000000 with something larger,
if you have more RAM installed.  For example, try "mem=256M@0xa0000000" (But don't overdo it.
I have on mine 512M, but if I used 512, the kernel did not boot (or I was to inpatient). I Did not investigate deeper,
as even 128Megabytes are fine for the debian installer / test drive / recovery.


Installing to flash

If you found out, that the result is positive (that it works), then you can flash the kernel.
For debian, install the package flash-kernel (if not already). A simple


should do it, but see the man page for details.

If you want to uninstall debian, you have to perform a regular "firmware update" to get it actually flashed.

Linux / Debian, Thecus N2100 | Comments (0) | Trackbacks (0)

Related Articles:

0 Comments | "Thecus N2100: Testing a kernel prior flashing" »