DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2007-03-18 02:37:45

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Loader for DNS-323

I've taken ideas and code from kexec and the loader module (thanks for the pointer, sala), and created a kernel module for the DNS-323 that tries to boot a new kernel.
The kernel module loads zImage and initrd files into a contiguous block of memory, creates a table of boot parameters ("tags"), deactivates interrupts and memory management, and finally jumps to the new kernel. I developed this using qemu, and successfuly started a new kernel inside qemu (there are still problems, however).

Today, I tested this on my DNS-323. It succeeds in loading and unpacking the kernel image, but stops after:

Uncompressing Linux.................................................................................... done, booting the kernel.

My interpretation is that the kernel loader basically works on the real box, too. But something early in the boot process failes. Next
step is kernel debugging. So, If one of you is feeling brave enough, and willing to try this and debug the kernel, I'll send the code.
.

Offline

 

#2 2007-03-18 14:34:21

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: Loader for DNS-323

Which kernel you are trying to load? A vanilla from kernel.org or D-Link DNS-323 kernel?


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#3 2007-03-18 15:01:26

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

I tried to reload D-Link's linux-2.6.6 (i.e. the original sources, compiled myself). I was thinking about trying a vanilla 2.6.20.3, but I have no idea what to chose as "ARM System Type"... Any ideas?

Offline

 

#4 2007-03-18 18:15:25

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: Loader for DNS-323

I was just checking, in case you where using vanilla sources. And about vanilla, it needs more work than just selecting right things at menuconfig. If you want to get vanilla running at some day, I suggest you to make a patchset for vanilla 2.6.6 kernel, by comparing D-Link 2.6.6 to vanilla 2.6.6.

But for now, maybe you can use D-Link compiled kernel. To do so you must extract kernel from firmware image or from flash, then cut out u-boot part and finally gunzip compressed kernel image.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#5 2007-03-18 19:14:26

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

sala wrote:

But for now, maybe you can use D-Link compiled kernel. To do so you must extract kernel from firmware image or from flash, then cut out u-boot part and finally gunzip compressed kernel image.

Nice idea. One could try to reboot the original kernel from ROM, but with a different initrd.

Offline

 

#6 2007-03-18 22:47:12

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

It seems to work now - I successfully booted a new kernel (linux-2.6.6 compiled from D-Link's sources) with my own initrd.
You can find the kernel module at: http://www.inreto.de/dns323/reloaded/

Note, that this is still highly experimental and if you try it, you do this at your own risk!

PS: The initrd.gz configures the IP address 10.12.11.73, and starts a telnet server.

Last edited by fonz (2007-05-08 23:25:51)

Offline

 

#7 2007-03-19 17:26:34

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: Loader for DNS-323

Very nice smile
Now you can boot operation system (debian) from hard disk.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#8 2007-03-25 20:36:32

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

sala wrote:

Very nice smile
Now you can boot operation system (debian) from hard disk.

Yes and no. The loader module should work well enough to boot a debian. But, personally, I'd like to have some "sweet & simple" (http://en.wikipedia.org/wiki/KISS_principle) busybox/uclibc-based system. I've had a quick look at the etch.tar from dev.skcserver.de, and it's not what I'm looking for. Since I know Slackware pretty well, I also looked at ARMedslack, but like debian, it's not exactly made for embedded systems. LFS has some ARM documentation in the works, but this will be quite time consuming (though interesting). I wonder, how much interest there actually is in replacing the whole D-Link software?

Offline

 

#9 2007-03-26 22:30:41

mig
Member
From: Seattle, WA
Registered: 2006-12-21
Posts: 532

Re: Loader for DNS-323

fonz wrote:

I wonder, how much interest there actually is in replacing the whole D-Link software?

I am VERY interested in replacing the whole D-Link software, I think it is the only way we can realize the full potential of the DNS-323.  I think the DNS-323 is really good hardware, but the D-Link provide software doesn't give the features I would expect, even for it's designed use case as a Network-Attached-Storage device.

IMHO here a a few of the poorly implemented features in the D-Link firmware (v1.02b USA)
- does not keep accurate time or accurate time zone rules
- does not have a journaling file system
- does not identify/report hard disk problems
- does not have capability for UPS power protection (more critical feature given no journaling)
- does no use the latest version of samba

I think all these problem can be overcome with better software.  The chroot-debian is a possible solution; however, I think there are still problems in the D-Link kernel that would not be fixed by chroot. 
For example the #cat /proc/uptime has some very large values, and #cat /proc/stats | grep btime gives an unusually small value
I think this is an indication that something is fundamentally wrong with the the code in the time functions in the D-Link provided kernel, a chroot-debian still gives bad information for uptime because it uses the /proc/... entries from the D-Link kernel.

I am VERY excited about the reloader.ko module you have produced.  This give us a way to boot to a different kernel without having to re-flash the firmware (and risk bricking the unit) .

I have a Kurobox (www.kurobox.com) which uses this same "rebooter" technique.  Buffalo Technologies (the manufacture) shipped a 2.4 monte-vista kernel and I can "reboot" a 2.6 Fedora Core 4 kernel.  There were a lot of very talented people on the kurobox forum who did all the "heavy lifting" to develop this technique and I was able to follow their guidance and compile my own kernel modules for features I wanted.  The current Kurobox has a PPC processor so binary sharing is not possible; however, a new Kurobox-Pro is being released and it uses an ARM processor, so there may be some sharing when development starts for that Kurobox-Pro model.

From my understanding, one of the fundamental differences between how Buffalo Technologies and D-Link implement their NAS design is D-Link keeps the root file system in RAM and Buffalo-Tech has the root file system on disk.  With the root fs in ram a busybox / uclibc  (KISS) solution seems the right choice.  I you are willing to use some of the hard drive(s) for root [/dev/sda1 for root (3GB) and /dev/sda2 for swap (256MB) and /dev/sda3 for /mnt/HD_a2) then a [ Debian | Gentoo | Fedora_Core] / glibc solution could be viable.

I'm in the process of building a serial cable, and plan to try your 'reloader' module after the cable project is complete.

// Mig


DNS-323 • 2x Seagate Barracuda ES 7200.10 ST3250620NS 250GB SATAII (3.0Gb/s) 7200RPM 16MB • RAID1 • FW1.03 • ext2 
Fonz's v0.3 fun_plug http://www.inreto.de/dns323/fun-plug

Offline

 

#10 2007-03-26 23:15:02

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

mig wrote:

With the root fs in ram a busybox / uclibc  (KISS) solution seems the right choice.  I you are willing to use some of the hard drive(s) for root [/dev/sda1 for root (3GB) and /dev/sda2 for swap (256MB) and /dev/sda3 for /mnt/HD_a2) then a [ Debian | Gentoo | Fedora_Core] / glibc solution could be viable.

Yes, I am willing to use the disks. Actually, I already booted successfully from the hard drive (yesterday ;-)). I also agree that trying some full-blown Linux distro is worth a try. But still, 64MB RAM is not that much, and performance will degrade badly once the box starts swapping.

I was about to try ARMedslack and Debian myself, but gave up. My first idea was to put debian on a USB stick and boot it from there. That failed: If you have a USB stick plugged in and then start a new kernel, it won't detect the stick until you remove and reinsert (but you can't do that while "booting", at least I'm not quick enough). With ARMedslack (while I love Slackware) there seems to be problem with bash - it segfaults from time to time, so I didn't even try to install and boot it.

mig wrote:

I'm in the process of building a serial cable, and plan to try your 'reloader' module after the cable project is complete.

Good luck.

Offline

 

#11 2007-03-27 08:46:19

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: Loader for DNS-323

fonz wrote:

I also agree that trying some full-blown Linux distro is worth a try. But still, 64MB RAM is not that much, and performance will degrade badly once the box starts swapping.

It's not that bad at all. Look nlsu2 and dsm-g600 with 32mb of ram. Both working quite fine with gentoo (uclibc) and debian. Of course it is not a good idea to run many memory dependent processes like python, apache, php, perl, samba-3 eg.

Here is booted Gentoo on DSM-G600: http://dns323.kood.org/forum/p1523-2007 … html#p1523
As you can see 32mb device still has 25148kb free memory left after plain (kernel+init+network+shell) boot.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#12 2007-04-05 22:19:40

someguy
Member
Registered: 2007-01-17
Posts: 47

Re: Loader for DNS-323

I came across Embedded Debian (EmDebian) - looks interesting:
http://wiki.debian.org/Embedded_Debian
http://www.emdebian.org/

Offline

 

#13 2007-04-05 22:36:11

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

someguy wrote:

I came across Embedded Debian (EmDebian) - looks interesting:
http://wiki.debian.org/Embedded_Debian
http://www.emdebian.org/

did you try it or are you going to try it?

I'm currently testing embedded cross linux from scratch (so far i have compiled the basic stuff for armv5te architecture and 926ej-s cpu using the latest gcc).

Offline

 

#14 2007-04-06 16:06:18

sala
Member / Site Admin
From: Estonia
Registered: 2006-07-28
Posts: 731
Website

Re: Loader for DNS-323

fonz wrote:

someguy wrote:

I came across Embedded Debian (EmDebian) - looks interesting:
http://wiki.debian.org/Embedded_Debian
http://www.emdebian.org/

did you try it or are you going to try it?

It look good, but there are only limited number of packages available.


DSM-G600 - NetBSD hdd-boot - 80GB Samsung SP0802N
NSA-220 - Gentoo armv5tel 20110121 hdd-boot - 2x 2TB WD WD20EADS

Offline

 

#15 2007-05-08 23:50:17

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

I've uploaded an updated dns323-reloaded package. This version does better memory allocation, making it much more robust and reliable when memory is low (and it's always low on my box). Sources are available at: www.inreto.de/dns323/reloaded

Note that reloaded modules are included in bobclfs, so this is for those who want to experiment with their own kernels and root file systems. Have fun.

Offline

 

#16 2007-06-13 18:53:07

da_blitz
Member
Registered: 2007-06-13
Posts: 5
Website

Re: Loader for DNS-323

you might want to look at open embedded, i know i posted it elsewhere but i thought its relevent, the nslu guys use it to generate thier packages automatically as do the openwrt people Nokia and the zaurus guys (disclaimer: i have several of each device)

debian gives you the most package choices but open embedded gives you the autobuild facilities and the feed generation

the main reason i point it out is that it was designed for situations like that, if the NSLU or OpenWRT guys fix a packageing problem you reap the benifits

another soultion is scratchbox or buildroot but they are more focussed on distro building (not to say OE isnt, but it can be used to generate the one package)

if you guys have gotten to a piviot_root situation with kexec then you are in the same position as the x86 arch, i know of 2 projects trying to replicate the ease of the x86 bootloader with a kexec linux kernel but they arent mature. i guess all this needs is a bit o spit and polish to get it to the state where it can boot off of any storage device connected, download (internet or flashdisk) and put a basic OS onto said storage device

basically just use the flash as a nice large BIOS and get ont the storage device ASAP, firmware testing becomes a brezze, just boot off of a flash disk and keep a couple lying around for each dev build

enough ranting from me, willing to help and hope i gave you some ideas.


Embedded Processor Freak
http://www.pocketnix.org

Offline

 

#17 2007-06-13 21:37:40

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

OE and buildroot have useful patches, I'm using them for quite a while now. I'm not using their toolchains, though, but CLFS-E.
I also think that pivot_root is the wrong approach for booting - having your system on disk prevents spin-down. I'm booting into an initramfs with pkgsrc/optware-style extras on disk. That way background tasks can run without disk access.

Nobody was brave enough to reflash yet, which is not a problem, since the kernel loader works fine and pretty reliable.

Compiling packages is not the problem - providing the device-specific bits is more work...

Offline

 

#18 2007-08-14 09:34:07

Paul
Member
From: Landshut, Germany
Registered: 2007-01-19
Posts: 35
Website

Re: Loader for DNS-323

Hi there,

I'm currently trying to boot my own kernel - but without any luck (yet)...
I've downloaded the reloaded fsck Package (http://www.inreto.de/dns323/fsck/), and when I'm executing the reload.sh it all works. It's running the 2.6.12.6-arm1_huge Kernel...

So I've compiled the original linux kernel without any modifications, copied the zImage over and executed the reload.sh with my own kernel (same initramfs!). And there was no response from the dlink... not even the network was configured ?!

(I've recompiled the kernel using the cross-compile toolkit and on the dlink itself... both didn't work :-( )


Am I missing something??

Thanks in advance,
Paul

Offline

 

#19 2007-08-14 12:50:31

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Loader for DNS-323

Paul wrote:

I've downloaded the reloaded fsck Package (http://www.inreto.de/dns323/fsck/), and when I'm executing the reload.sh it all works. It's running the 2.6.12.6-arm1_huge Kernel...

Good.

Paul wrote:

So I've compiled the original linux kernel without any modifications, copied the zImage over and executed the reload.sh with my own kernel (same initramfs!). And there was no response from the dlink... not even the network was configured ?!

Do you have a serial connection? First thing would be to check if the kernel boots at all and prints messages on the serial link. But I guess it's doing so.

More likely is that your kernel config is not compatible with the s-initramfs. I was lazy and instead of configuring the network myself, I used the kernel's autoconfig feature.
The reload.sh script extracts the IP config from ifconfig output and creates a command line parameter for the new kernel (look for IP_CMDLINE in reload.sh). The kernel will configure the network interface using that information only if it has IP autoconfiguration enabled (and the DHCP autoconfig option disabled!).

Alternatively, you can change the ramdisk image (extract, edit etc/rc.d/rc.sysinit, repack).

Or even simpler: use the "opt" feature :-) - which is quite similar to the "fun_plug" feature of the original firmware. The ramdisk will look for /mnt/HD_a2/linux/opt and mount it as /opt (if it exists). Then, if there's a opt/etc/rc.d/rc.optinit script, it will be run. Have a look at /etc/rc.d/rc.sysinit for the details (inside the s-initramfs).

Offline

 

#20 2007-08-14 13:40:23

Paul
Member
From: Landshut, Germany
Registered: 2007-01-19
Posts: 35
Website

Re: Loader for DNS-323

fonz wrote:

Do you have a serial connection? First thing would be to check if the kernel boots at all and prints messages on the serial link. But I guess it's doing so.

Not yet since I'm not very gifted with the soldering gun :-(
(btw: anyone interested in selling his cable *fG* ??)

fonz wrote:

More likely is that your kernel config is not compatible with the s-initramfs. I was lazy and instead of configuring the network myself, I used the kernel's autoconfig feature.
The reload.sh script extracts the IP config from ifconfig output and creates a command line parameter for the new kernel (look for IP_CMDLINE in reload.sh). The kernel will configure the network interface using that information only if it has IP autoconfiguration enabled (and the DHCP autoconfig option disabled!).

I've tried using the stock 2.6.12.6 kernel from dlink's site... it has autoconfiguration enabled, afaik.

fonz wrote:

Alternatively, you can change the ramdisk image (extract, edit etc/rc.d/rc.sysinit, repack).

Or even simpler: use the "opt" feature :-) - which is quite similar to the "fun_plug" feature of the original firmware. The ramdisk will look for /mnt/HD_a2/linux/opt and mount it as /opt (if it exists). Then, if there's a opt/etc/rc.d/rc.optinit script, it will be run. Have a look at /etc/rc.d/rc.sysinit for the details (inside the s-initramfs).

Nice :-)
I'll do some tests this evening when I'm at home... maybe I'll figure something out...

Thanks a lot!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB