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 2009-01-14 19:17:06

onkl
New member
Registered: 2009-01-13
Posts: 2

Creating a generic firmware, to transfer the boot sequence to USB.

Hi all,

Recently I’ve acquired a CH3SNAS. I won’t need it for regular purposes for the next few months, so a great chance to play around with it.

I have very limited Linux skills and no experience with embedded systems whatsoever. I do have some programming experience, but not in C type languages. On the other hand, I do like to read in and have quite a lot of patience. 

Now, I have been reading quite a lot, on this site and elsewhere.
I see the improvements made in accessing the firmware of the DNS 323/CH3SNAS. However, that requires either fairly advanced knowledge or a very steep/long learning curve. So, if I’m trying to practice somewhat on my embedded systems and linux skills, I can just well make myself useful. I'm for now assessing the possibility to create a way to let novice users exploit the full advantages of these boxes in a relatively easy way.

However, before I start fiddling, I would be very happy by some feedback on the approach I’m considering.

My initial analysis would be that the "ideal HOW-TO" to open this device would be the following:

1: Get your hands on a CH3SNAS/DNS323 and a simple, generic USB stick of a certain minimal size.
2: Download "this OS-iso" and put the image contents to the USB-stick.
3: Download "this firmware" and upload it following regular procedures.
4: Restart the NAS and you have a full fledged *nix environment.
5: Getting sick& tired of it? Turn the NAS off. Remove USB stick and restart. The NAS will look for the USB device, won't find it and come up with the original firmware. Then, reflash the unit with a vendor supplied package.

As far as I understand it, this would require the following:

1: In U-boot:
The following “pseudocode” should load an image file from the root of a USB stick to a position in RAM:

USBstart
ext2load usb [usbdev0#] 0x1000000 Imagename (Also available for FAT and some other FS.)
or
usbstart
usbboot

This is under the precondition that uboot has been compiled to included appropriate usb drivers. I haven’t checked thoroughly, but since in the source as downloaded from conceptronic, the u-boot/include path contains some references to usb, I tend towards optimism.

By methods as described here, it is possible to load a fairly minimal image, with the pivot root method, the live file system on the USB stick can be set as root. It’s still rather misty to me whether u-boot is able to mount a usb partition. In that case, the method described here seems possible and easier.


According to this thread, the USB_storage command gives a return useful for scripting. By scripts like the one found here, it could be possible to chain the image on the USB stick before the original RAMdisk-image, so that on failure, the default RAMdisk is loaded.

Alternatively, it should be quite possible to create an “usbboot_by_partition_name” function within u-boot, to mitigate identification problems. The usb image should then follow this convention.
The function usb_stor_info in usb_storage.c passes a struct with info on all usb storage devices. A wrapper function, analysing the struct returned from usb_stor_info and feeding the necessary parameters into usb_boot, combined  with some device/partition information as boot arguments for the image should do the trick. The on fail, fallback to flash-RAMdisk method, can be scripted, if the return values of this function is carefully managed.

Once this is tested and accomplished, theoretical, there should be no risk in bricking the unit, since it will always be possible to follow the rather trivial “point 5 in the HOWTO” instructions (remove all USB storage, restart, reflash original trough web-interface).

2: An image to pivot the boot sequence towards the main filesystem should be created. (depending on the chosen method above)
3: After that, I can start fiddling with debian, partly using the chroot how-to’s as in this forum's wiki. Once it is working within reasonable extend, an iso to drop upon USB sticks can be generated.

Now, (I hope someone actually reaches this) Would anyone give his or her opinion:

-Is this approach at least theoretically possible?
-Is this approach manageable by someone like me: No experience, but patient enough to read in, or am I really overstepping myself?
-Would such a “HOW-TO”, if actually feasible be useful for someone?

Offline

 

#2 2009-01-19 10:55:47

maligor
Member
Registered: 2008-11-16
Posts: 8

Re: Creating a generic firmware, to transfer the boot sequence to USB.

Note: If you plan on doing u-boot work, you really need a jtag.

-Is this approach at least theoretically possible?

Yes, I imagine so. I've been trying to build a u-boot with IDE and ext2 support myself to boot from the disk, unfortunately I can't seem to make the 1.1.1/5181 version boot for some reason, and I'm not entirely sure about 1.7.3 (which does boot, but reports it as 5182).

The idea seems somewhat similiar to foonas-em, except the foonas-em is meant to reside on the device flash. It's an EMergency image that OS installers and partitioning tools ect. Booting foonas-em from a usb device shouldn't actually be a problem. It might even be made quite handy with FAT support for the poor people with windows. Just make a u-boot image with the initrd embedded and copy it to the usb mass storage.

-Is this approach manageable by someone like me: No experience, but patient enough to read in, or am I really overstepping myself?

If the CH3NAS uses the same u-boot as dns-323, there's a slight problem with it. The default image is extremely cut down to fit the flash partition. You can ofcourse just make it bigger, but writing the images over to the flash becomes trickier. (mtdblock's depend on the partition)

As for configuring and building u-boot.. It's not really feasible without a jtag unless you want to take a all out risk on the thing. A preconfigured and prebuilt u-boot is a different matter ofcourse. Also configuring u-boot requires familiarity with C language.

-Would such a “HOW-TO”, if actually feasible be useful for someone?

If you have a jtag cable dangling around, I could write something of a how-to, otherwise you'll just have to wait for someone to build images with usb support (and get tested with other people whith jtag).

Edit: This got me poking around the 1.7.3 Marvell u-boot again. And now I have a version of u-boot that supports loading the kernel from ext2/IDE and network. I'll see if I can get usb also. Only side effect is that it's big. It won't fit in the "partition" that u-boot resides on.
Edit: The usb stuff in marvell uboot seem a bit weird, and there seems to be missing symbols.

Last edited by maligor (2009-01-20 15:50:06)

Offline

 

#3 2009-04-17 00:24:49

talkingRock
Member
Registered: 2009-03-26
Posts: 100

Re: Creating a generic firmware, to transfer the boot sequence to USB.

If something like this existed, I'd be interested too.    I don't think that I have the expertise to make it work, but I'm guessing that someone who understood uboot and the dns-323/dns-321 boot sequence could.   

One option would be:
if the usb is bootable,
   boot from usb
if the /dev/sda2 is bootable,
   boot from /dev/sda2
else
boot from flash

If a static order is not ok, I suppose some parameter in the flash could determine the device, or even a magic file on the first disk?

Is that reasonable, or am I overestimating what the boot loader can do in the space given?

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB