Buffalo NAS-Central Forums

Welcome to the Linkstation Wiki community
It is currently Fri Apr 27, 2018 9:29 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 158 posts ]  Go to page Previous 13 4 5 6 711 Next
Author Message
PostPosted: Mon Dec 11, 2006 7:30 pm 
Offline
Developer

Joined: Wed Oct 25, 2006 6:05 pm
Posts: 613
Location: Germany
Analysed my ethereal logfile last night when I read lb_worms request...
Code:
After pressing update button: 
packet#    from->to:  packet
5.   PC->LS:   ACP_DISCOVER
6.   LS->PC:   Answer, includes current version etc.
7.   PC->LS:   ACP_EN_ONECMD (contains some kind of encrypted password)
8.   LS->PC:   Answer
9.   PC->LS:   ACP_AUTH
10.   LS->PC:   Answer
11.   PC->LS:   ACP_CMD "cat /proc/buffalo/firmware"
12.   LS->PC:   Answer (content)
13.   PC->LS:   ACP_CMD "cat /etc/initrd_ver"
14.   LS->PC:   Answer (content)
15.   PC->LS:   ACP_FIRMUP2
16.   LS->PC:   Answer
17.   PC->LS:   108b, ACP_ /boot/hddrootfs.img
18.   LS->PC:   Answer
Lengthy TCP-transfer to 22936
18036.   PC->LS:   ACP_FILESEND_END
18037.   LS->PC:   Answer, 20cb
18038.   other unrelated traffic
18039.   LS->PC:   Answer, 21cb
18040.   PC->LS:   a080, length 28h, code 01? Would be ACP_Reboot (time in session: 92.4 sec)
18041.   LS->Brdcst:   Answer
The packet numbering is that of the ethereal session (kept it for my own navigation).
I'm missing ACP_FIRMUP_END (maybe I was too tired yesterday?). If you think your new distro is that far I'd try to update my box with it and record the session.

If I didn't miss anything the box decides on its own when to replace the files. It probably happens after the reboot cmd either before going down or during bootup. After packet 18041 there is a three second pause then the box broadcasts some announce packets (not ACP, normal network traffic). Then the box dissapears for reboot while the PC continues to send ACP_DISCOVER packets until the box reappears again. Didn't see anything that would call a special script or so.

So with LSUpdater.exe you had to run an update file by file if you want a certain order that differs from that jonli described. Would probably mean a reboot after each update part. With a custom updater we could send ACP_CMD's. Using these you can do just everything you can do on command line. Or we could start a shell script (directly by ACP_CMD or by telnet enabled by ACP_CMD). The basic packet structure for the ACP stuff is quite obvious, now. But I have to get details for special commands and the encryption of the passwords in ACP_AUTH and ACP_EN_ONECMD. Then there is the TCP transfer of the files... Maybe EricC has some details?

Regarding overwriting/replacing during the update process. Just discovered that I've only an uImage.buffalo in \boot, while I updated for uImage.buffalo-usb-printer. Or didn't I?

Summary: Box probably replaces files after receiving the reboot cmd. If you want a fast solution for the update process that works on the original system, I recommend to use ACP_AUTH, ACP_CMD to enable telnet and ftp, upload the files to the box via ftp and run a script there. Basically what lb_worm suggested initially. If we ask the user to set the admin password to "password" simply replaying the catched encrypted password should be fine.

Ok thirsty after that speech. Need another sip of the red wine. ;)

_________________
acp_commander users note: from ver. 0.4 on the correct ACP authentication method is used, avoiding possible side effects.
Download: http://sourceforge.net/project/showfile ... _id=167037


Top
   
PostPosted: Mon Dec 11, 2006 7:38 pm 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
From what I can see of the boot process, it checks for files like hddrootfs.buffalo.updated which result in echo "0x100" >/proc/sys/kernel/real-root-dev. I took this as a flag to force EM mode but I am having seconds thoughts about this. No I am right, it does force EM (initrd) boot mode. So, if kernel then initrd are updated before hddrootfs are uploaded then the box must reboot when hddrootfs arrives. Also must reboot when initrd is updated too or maybe they are left as packets in /boot and it reboots as each is installed? There is a process which is run called fwupdate.sh, this re-formats the disk (this could be changed :) ) and decompresses the tar ball (tar zxf ${MPT_BOOT}/hddrootfs.buffalo.updated -C ${MPT_ROOTFS}). Nice bit of code this I have found, this is the build process. It does trigger reboots along the way too. It also keeps a copy of the previous images by renaming them to .org. We could customize some of this? It does a lot of file moves which ultimatley result in a single reboot. Needs to be done in stages I fear.

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Mon Dec 11, 2006 7:39 pm 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
Nice one Georg. You beat me to it. I have been looking at the code at the other end :)

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Mon Dec 11, 2006 7:42 pm 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
Georg wrote:
Summary: Box probably replaces files after receiving the reboot cmd. If you want a fast solution for the update process that works on the original system, I recommend to use ACP_AUTH, ACP_CMD to enable telnet and ftp, upload the files to the box via ftp and run a script there. Basically what lb_worm suggested initially. If we ask the user to set the admin password to "password" simply replaying the catched encrypted password should be fine.


I like this idea. I hoped we could do something like this to free us from the updater. Is your Java code in a 'good' state to do something like this?

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Mon Dec 11, 2006 7:50 pm 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
Can not even cheat the tar process because of:

tar zxf ${MPT_BOOT}/hddrootfs.buffalo.updated -C ${MPT_ROOTFS}

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Mon Dec 11, 2006 7:56 pm 
Offline
Developer

Joined: Wed Oct 25, 2006 6:05 pm
Posts: 613
Location: Germany
No not at all, it just gives you an idea how the packets have to look like.
The definiton of the packets :
Code:
 
byte[] _ACP_auth = new byte[]{
        0x20,  0x00,  0x00,  0x00,         0x08,  0x00,  0x01,  0x00,  // byte 0 (+1 ?) length of header 01.0 0.08.00 is the packet version
        0x10,  (byte)0x8a,  0x28,  0x00,   0x00,  0x00,  0x00,  0x00,  // 0x8a10 ACP_special_cmd, 0x28 = opti on size
        0x00,  0x50,  0x56,  (byte) 0xc0,  0x00,  0x09,  (byte)0xff, (byte)0xff,  // 00:50:56:c0{  : }00:08 = connection-id byte22: start of target MAC
        (byte)0xff, (byte)0xff,  (byte)0xff,  (byte)0xff,    0x00,  0x00,  0x00,  0x00,  // end of header
        0x0c,  0x00,  0x00,  0x00,         0x00,  0x00,  0x00,  0x00, // byte32: 0x0c authenticate
        0x05, (byte) 0x80, 0x24, (byte)0x8d,   (byte)0xab, (byte)0x9c, (byte)0x97, (byte)0xe0,    // password  - check !!!
//            0x05, 0x05, 0x05, 0x05,   0x05, 0x05, 0x05, 0x05,  // hm does not work as password ;(
        0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00,
};
byte[] _cmdbuff = new byte []{                                         // first byte: byt e 0
        0x20,  0x00,  0x00,  0x00,         0x08,  0x00,  0x01,  0x00,  // byte 0 (+1 ?) length
        0x10,  (byte)0x8a,  0x26,  0x00,   0x00,  0x00,  0x00,  0x00,  // 0x8a10 ACP_cmd, 0x26 = option size
        0x00,  0x50,  0x56,  (byte) 0xc0,  0x00,  0x08,  (byte)0xff, (byte)0xff,  // 00:50:56:c0{  : }00:08 = connection-id byte22: start of target MAC
        (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff,    0x00,  0x00,  0x00,  0x00,
        0x1a,  0x00,  0x00,  0x00,         0x03,  0x00,  0x00,  0x00}; // byte32: length of cmd strin g
                                                                       // byte36: type
 
     int _startbyte = 40;

Send them after completing the ACP_CMD packet
Code:
 
         _ssocket = new UdpSocket();
         _ssocket.setSoTimeout(500);             // set socket timeout to 500 ms
...
        UdpPacket _authpack = new UdpPacket (_ACP_auth, _ACP_auth.length, _target, _tport);
        _ssocket.send(_authpack);
...
        // prepare ACP_CMD packet
        String Scmd = new String (jTextField5.getText());
        Integer _totalLen = new Integer (Scmd.length()+44);  // length of cmd-string + 12 (cmd header) +  0x20 ACP_header
        Integer _cmdLen = new Integer (Scmd.length());
 
        byte[] _sbuffer = new byte [_totalLen.intValue()];
 
        System.arraycopy(_cmdbuff, 0, _sbuffer, 0, _cmdbuff.length);
        _sbuffer[10]=(byte)(_cmdLen.byteValue() + 12);
        _sbuffer[32]=(byte)(_cmdLen.byteValue());
        System.arraycopy(Scmd.getBytes(), 0, _sbuffer, 40, _cmdLen.intValue());   // src, src_pos, dest,  dest_pos, length
        UdpPacket _spacket = new UdpPacket(_sbuffer, _totalLen.intValue(), _target, _tport);
 
        // send
        appendTextPane1(Scmd.toString()+"\n", Color.BLUE);
        _ssocket.send(_spacket);
        _ssocket.receive(_rpacket);                   // !!! threadblocking !!!
 
        // receive answer
        if (_rpacket.getLength() > _startbyte){
            byte[] LSanswer = new byte[_rpacket.getData().length -_startbyte];
            System.arraycopy(_rpacket.getData(), _startbyte, LSanswer, 0, _rpacket.getData().length-_startbyt e);
            String LSansw = new String (LSanswer);
            appendTextPane1(LSansw+"\n" , Color.BLACK );
        }

code is :down: I know, I know.

_________________
acp_commander users note: from ver. 0.4 on the correct ACP authentication method is used, avoiding possible side effects.
Download: http://sourceforge.net/project/showfile ... _id=167037


Top
   
PostPosted: Mon Dec 11, 2006 10:35 pm 
Offline
Site Admin

Joined: Fri Aug 04, 2006 2:37 am
Posts: 1652
Location: United States of America
Hmm...I was thinking about the dilema and thought of something. Since initrd gets flashed first, the initrd might just work to get rid of the hddrootfs.buffalo.org, hddrootfs.buffalo.done files in /boot.

The box updates the kernel and initrd first and reboots.

On the second reboot, initrd would have to load (correct) and thus eliminate the old files from /boot. Now obviously timing is an issue. But since we now know the process responsible for extracting the rootfs, couldn't we also add a "if 1, kill <process>" to stop the process, eliminate the files, then restart the update process as normal.

In other words, write a script for like:
Code:
#Stage 1 
 
# Is an update in process?
If = yes, then kill process, goto stage 2
If = no, proceed normal boot, exit
 
#Stage 2
 
#remove junk files
mount /dev/sda1 /boot
rm -rf hddrootfs.buffalo.org hddrootfs.buffalo.done
goto stage 3
 
#Stage 3
run rootfs update script, exit.


Obviously you'd have to fill in the blanks, but something along that general logic should work? ...Then again, maybe I'm confused and am just restating something obvious. I've been up for many hours now.:)

_________________
http://www.opifer.net


Top
   
PostPosted: Tue Dec 12, 2006 7:30 am 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
jonli447 wrote:
The box updates the kernel and initrd first and reboots.


It updates:

1) uImage, by doing some file moving
2) initrd, by doing some file moving
3) u-boot, by coping to mtd0
4) hddrootfs, by re-formatting, tar'ing and mount check
5) Requests a reboot.

If the updater is requesting reboots in between each of these processes then great. Otherwise, it does not :(

@Georg: Can you code this?

Georg wrote:
Summary: Box probably replaces files after receiving the reboot cmd. If you want a fast solution for the update process that works on the original system, I recommend to use ACP_AUTH, ACP_CMD to enable telnet and ftp, upload the files to the box via ftp and run a script there. Basically what lb_worm suggested initially. If we ask the user to set the admin password to "password" simply replaying the catched encrypted password should be fine.


We could then use this process rather than the Buffalo updater. If it works well then anyone (not just Windows users) can do updates :)

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Tue Dec 12, 2006 4:11 pm 
Offline
Site Admin
User avatar

Joined: Mon Jul 11, 2005 7:19 am
Posts: 7703
Location: Austria, Vienna
lb_worm wrote:
Could help Georg in coding the Java updater? That will be a GREAT help.


agreed.

it seems to be the best thing i can help.

georg...
never think your code looks ugly...
if it helps i can send you some of my java code, haha...

we can use the cvs-repository from
http://sourceforge.net/projects/linkstationwiki/
if you want.

_________________
LS1 (2.6 kernel, foonas svn1062, 750 GB, UBoot 1.2) & LS Pro (FreeLink/jtymod/GenLink, changes all the time)
Thx to all donators!


Top
   
PostPosted: Tue Dec 12, 2006 7:05 pm 
Offline
Developer

Joined: Wed Oct 25, 2006 6:05 pm
Posts: 613
Location: Germany
As I'm more firm with delphi/pascal (that updater was my first trial with java). I wanted to do create a quick comand-line tool with delphi (see debian-thread). BUT the monitor of my desktop didn't go on this evening. :down: (monitor/graphics card??) And I don't have delphi on my business-laptop.

Time is a problem. I'll leave for holiday on sunday (until Jan. 5th) and still lots of work to do.

Mindbender, if I convert my java stuff into something more flexible. Could you finish it and create a jar (I'd use the cmd-line parameters suggested in the debian thread)? Still don't know how to create it with JBuilder 2005 Foundation. I think I had to use the cmd-line as it's not directly supported in the crippled free version.... as I said, first time!

_________________
acp_commander users note: from ver. 0.4 on the correct ACP authentication method is used, avoiding possible side effects.
Download: http://sourceforge.net/project/showfile ... _id=167037


Top
   
PostPosted: Tue Dec 12, 2006 9:30 pm 
Offline
Site Admin
User avatar

Joined: Mon Jul 11, 2005 7:19 am
Posts: 7703
Location: Austria, Vienna
Georg wrote:
Still don't know how to create it with JBuilder 2005 Foundation.


me 2. i only coded java inside ultraedit till now.

i just use the standard-commandline-tools for this.
you should be able to create a jar-file by executing this:
Code:
jar -cvf <outputfile>.jar <path2source>\*.class

for example you are one folder above the source (and the folder is named "src")
Code:
jar -cvf custom_LSPro_updater.jar src\*.class

and you should have a jar-file with all classes inside.

_________________
LS1 (2.6 kernel, foonas svn1062, 750 GB, UBoot 1.2) & LS Pro (FreeLink/jtymod/GenLink, changes all the time)
Thx to all donators!


Top
   
PostPosted: Wed Dec 13, 2006 8:02 am 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
If you guys are having problems then I can code this up in C. Do you think you can get a handle on it?

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Wed Dec 13, 2006 4:31 pm 
Offline
Site Admin

Joined: Fri Aug 04, 2006 2:37 am
Posts: 1652
Location: United States of America
I'll be interested to see how this turns out.

_________________
http://www.opifer.net


Top
   
PostPosted: Wed Dec 13, 2006 5:47 pm 
Offline
Site Admin
User avatar

Joined: Tue Jul 12, 2005 11:26 am
Posts: 3701
Location: JAPAN
How is it going Georg/Mindbender?

_________________
LS used as PVR and streaming source


Top
   
PostPosted: Wed Dec 13, 2006 10:21 pm 
Offline
Developer

Joined: Wed Oct 25, 2006 6:05 pm
Posts: 613
Location: Germany
Coded half of the evening (first half spent for my daughters x-mas present - shh! don't tell her).
Called it acp_commander (no, not the present). Options as described yesterday.
After some debuging it seems promising. But I'm too tired now.

More for tomorrow evening.

_________________
acp_commander users note: from ver. 0.4 on the correct ACP authentication method is used, avoiding possible side effects.
Download: http://sourceforge.net/project/showfile ... _id=167037


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 158 posts ]  Go to page Previous 13 4 5 6 711 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


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:
Powered by phpBB® Forum Software © phpBB Limited