General NAS-Central Forums

Welcome to the NAS community
It is currently Sat Sep 23, 2017 2:05 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Jan 12, 2013 12:07 am 
Offline

Joined: Fri Jan 11, 2013 11:45 pm
Posts: 2
Hello,

i have a NSA210 and have one issue - my hdd have long spin-up (about 12sec) and that means NSA wont detect it, only way to start is turn off and immediately turn on. I had an usb script (if, else) which use usb_func and reboot router every start or restart. This solution was functional, but now i need to use both usb ports and don´t want to use usb hub.

What i need? I need to add line "sleep 10" to start of "rcS script". I read that only way how to modify it is extract firmware file and edit initrd file and make new checksum.


So is there anybody, who could tell me, how edit initrd file, make new checksum and pack firmware together to flash via web-interface? I dont have cables for serial connection.
Will be everything working, when i change an initrd file or is there something which have to be edited?




Thanks for reply


Top
 Profile  
 
PostPosted: Sat Jan 12, 2013 10:04 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
rcC is inside initramfs, which is compressed and embedded in the kernel, which is compressed and embedded in a zImage, which is embedded in a uImage. Extracting the initramfs is not too hard, but changing it and repacking it, I don't know. The uImage has a checksum, don't know about the zImage and the kernel. I suppose the compressed initramfs shouldn't grow. That could be done by removing some comments, I suppose.

I think the easiest way is to request the GPL sources, and just build your own firmware. In that case you don't need to bother about checksums.

How doest your unb_key_func.sh work? Check if a harddisk is detected, and if not, just reboot?


Top
 Profile  
 
PostPosted: Sat Jan 12, 2013 11:09 am 
Offline

Joined: Fri Jan 11, 2013 11:45 pm
Posts: 2
I am not a programmer, so i make only "one step loop" - first i created two files on flash disk - file "0" and file "1" and then a script

Quote:
#!/bin/sh

file=/mnt/parnerkey/1

if [ -e $file ]
then
rm /mnt/parnerkey/1
reboot

else
cp /mnt/parnerkey/0 /mnt/parnerkey/1
exit 1

fi


Maybe it isn´t ideal way but for me it does work without any problem.

I have also a simple solution, how automaticaly sent firmware to printer eg. HP P1006 when is connected, and it work without ffp or any mod. I can post if someone want see it.


Top
 Profile  
 
PostPosted: Sat Jan 12, 2013 11:49 am 
Offline

Joined: Mon Jun 16, 2008 10:45 am
Posts: 6039
I just saw I might be wrong. Was looking for a good way to detect a harddisk on a 210, and I saw that at least in FW 3.20 there is no initramfs, only an initrd. Maybe this isn't changed.
Try to extract and mount mdt2, this might be your initrd:
Code:
dd if=/dev/mtdblock2 of=initrd
mkdir initrd.d
mount -o loop initrd initrd.d
If this works, and rcS is in initrd.d, it might be possible to write back initrd to mtd2. In that case I suggest you to look in /sbin and /usr/sbin if it contains scripts which are used for firmware updates. It might contain usable code to write the flash. Possible variants are
  • dd if=initrd of=/dev/mtdblock2
  • dd if=initrd of=/dev/mtd2
  • flash_eraseall /dev/mtd2
    cat initrd >/dev/mtd2
  • mixtures of above
  • something else
Don't know why sometimes one method is used and sometimes another. Maybe subtle differences between flash drivers in the kernel.
My 3.20 backup doesn't seem to contain such a script, but the firmware for the 300 series does. I hope ZyXEL has eliminated the differences between the firmwares in the 4.x firmware.

Flashing back is a one-shot. If it fails, you have a brick.

BTW, according to the script in 3.20 there is no easy fail-safe way to detect an internal harddisk. But if there is a disk, it should be sda, so the usb stick should be sdb. You could check the mountpoint of the stick:
Code:
#/bin/sh

if cat /proc/mounts | grep parnerkey | grep sdb
then
    exit 1
fi

reboot
exit 1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group