Buffalo NAS-Central Forums

Welcome to the Linkstation Wiki community
It is currently Wed Sep 17, 2014 4:47 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sat Sep 06, 2008 9:59 pm 
Offline
Total Newbie

Joined: Sat Sep 06, 2008 8:49 pm
Posts: 3
I would like to be able to boot the Kurobox Pro from an external usb drive (flash or hard drive). After searching the wiki and forums the closest solution I have found so far is here http://buffalo.nas-central.org/forums/viewtopic.php?f=18&t=9731&st=0&sk=t&sd=a. Unfortunately, the best they came up with was a half solution, they boot with the kernel on an internal hard drive and root on a usb drive. I would like to be able to boot without any internal drive at all.

While the ideal solution would be to put everything on the external drive, it looks like this will not be possible because the version of uboot we are using can not load the kernel from usb. So as an acceptable compromise we could leave the kernel on the internal flash and put the root on the external drive. The uboot settings to do this are already provided in the wiki http://buffalo.nas-central.org/index.php/Kurobox_Pro_u-boot_environment_variable_settings. Here they are for reference:
Code:
setenv default_kernel_addr 0x00100000
setenv bootargs_base console=ttyS0,115200
setenv bootargs_root root=/dev/sda2 rw
setenv bootargs $(bootargs_base) $(bootargs_root) $(buffalo_ver)
setenv uImage_block 0
setenv uImage_offset 0x00020000
setenv bootcmd 'nboot $(default_kernel_addr) $(uImage_block) $(uImage_offset); bootm $(default_kernel_addr)'

However, the external drive will fail to mount with these setting. From the forum discussion I liked to earlier, we see that the problem is the usb needs some time “for the usb subsystem to settle.” So change the third setenv to wait 10 seconds before mounting root:
Code:
setenv bootargs_root 'root=/dev/sda2 rw; rootdelay=10'

After this when booting I get the error:
Code:
Waiting 10sec before mounting root device...
  Vendor: STECH     Model: Simple Drive      Rev: 8.59
  Type:   Direct-Access                      ANSI SCSI revision: 00
SCSI device sda: 976773167 512-byte hdwr sectors (500108 MB)
sda: assuming drive cache: write through
SCSI device sda: 976773167 512-byte hdwr sectors (500108 MB)
sda: assuming drive cache: write through
 sda: sda1 sda2 sda4 < sda5 sda6 >
Attached scsi disk sda at scsi2, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi2, channel 0, id 0, lun 0,  type 0
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
XFS mounting filesystem sda2
Starting XFS recovery on filesystem: sda2 (dev: sda2)
Ending XFS recovery on filesystem: sda2 (dev: sda2)
VFS: Mounted root (xfs filesystem).
Freeing init memory: 112K
FATAL: kernel toKernel panic - not syncing: Attempted to kill init!
o old

Now I am just guessing that this may be due to the stock kernel on the Kurobox Pro not being compatible. So I tried putting the kernel provided in the armel-lenny-for-lspro-dgv0.3.1b.tgz download into the /dev/mtd3 partition (thats the one that by default gets mounted to /mnt/mtd and served by samba) and then changing uboot to:
Code:
setenv default_kernel_addr 0x00100000
setenv bootargs_base console=ttyS0,115200
setenv bootargs_root 'root=/dev/sda2 rw; rootdelay=10'
setenv bootargs $(bootargs_base) $(bootargs_root) $(buffalo_ver)
setenv uImage_block 0
setenv uImage_offset 0x04400000
setenv bootcmd 'nboot $(default_kernel_addr) $(uImage_block) $(uImage_offset); bootm $(default_kernel_addr)'

Supposedly, 0x04400000 is where the mtd3 partition should start (you can confirm this by reading the boot messages when the MTD partitions are created). But with this setup the kernel is not found and uboot goes into tftp mode.

OK, thats all I have come up with so far. Suggestions are appreciated. I will keep trying to come up with new ideas.


Top
 Profile  
 
PostPosted: Sat Sep 06, 2008 10:43 pm 
Offline
Site Admin
User avatar

Joined: Mon Aug 28, 2006 1:15 am
Posts: 2606
just thinking out loud... the noncompatibility you mention may be the OABI vs EABI thing... not sure...

My guess is that you could try putting in the lenny-armel image in flash... I do have a KuroPro but have never tried doing this... 256MB is a lot of room to work with, to be honest. I've never taken the time to do that, though... so I can't vouch for it working ... and can't give the specifics/nuts-and-bolts on how to do it.

Conceivably, it should even be possible to tftp in the kernel to start with, and then just pull in the rootfs from the flash drive.

In regards to uboot, it is correct that the version that we are "shackled" with here is lacking a lot of capabilities that so many of us would really like to have . :evil: the emoticon I use may be a polite understatement. I find it ... well... chafing, to say the least. ('nuff of knocking around the stock and stockish uboots )

_________________
LS1 (foonas, nfs, Tranmission & p910nd print server, Firefly for my Roku)
LS-HG500 (Lenny)
Various LS-Pros v1,v2 (unbricked w/ serial & jtag)
KuroPro, LS2 & KuroHG (foonas)
Working on davysweather.dyndns.org lately...

=> wooohooo!
wooohooo!
Unknown command 'wooohooo!' - try 'help'


Top
 Profile  
 
PostPosted: Sat Sep 06, 2008 11:16 pm 
Offline
Regular Member
User avatar

Joined: Tue Oct 09, 2007 9:01 am
Posts: 117
Mymy, a "half-solution". Maybe i didnt have the time to complete this project ;).

Take into consideration that davy-gravy's kernel is using a different partition scheme than the stock one. If you use his you have to modify u-boot-env variables as well (the starting point etc.).

A better way would be to use the new 2.6.27-rc4-EXPERIMENTAL!-kernel provided by Martin Michlmayr (thats the kind of kernels which are in the debian orion kernel package), since its using the stock partition scheme again, and its using an initrd.

http://people.debian.org/~tbm/armel/kernel/r12120/

Should boot according to Per Andersson.

Be advised that this is an EABI kernel so you better have an EABI FS too.

P.S: XFS for root could be bad, test it and if it doesnt work get an EXT3 root.

Modern kernels have problems with XFS on arm platforms.

So we get to do this:

1) Put 2.6.2x kernel into mtd1 (stock partition scheme)

2) Modifiy uboot to boot from there

3) root=/dev/mtd3 or /dev/sdc (flash or usb, according to space needs), rootdelay=10

4) use an ext3 root (to be sure) (of course only if using an usb stick or harddrive, nand has jffs2 as fs).

5) use an EABI system.

6) look if booting works.

I can test this myself tomorrow, mldonkey has to finish its job first ;).


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 2:40 am 
Offline
Total Newbie

Joined: Sat Sep 06, 2008 8:49 pm
Posts: 3
Thanks for the quick responses. One of my problems was that I was ignorant of how the boot partition works; I thought I could just copy the boot image into /mnt/mdt and then boot from that partition. I didn't realize that the boot image needs to be written directly into the nand flash. I could have used mdt1, but my concern is that if something goes wrong I will have no way to undo it (is there a way?). So instead I use the mdt3 partition to load the new boot image. That way I can use uboot to switch between booting from the old kernel in mdt1 and the new kernel in mdt3. I lose the jffs2 partition on mdt3, but that is not a big deal because I have plenty of storage on my external drive.

Also you were right not to use xfs. When I successfully booted from the armel-lenny kernel it said
Code:
No file system could mount root, tried:  reiserfs ext3 ext2 cramfs jfs

Apparently just about every file system you can think of except XFS works.

But after correctly setting up the boot image and reformatting to ext3 it works! So thanks again for the tips. I have documented my steps to boot from a usb drive and I will attach them as a separate post. Of course my way may not be the best, so feel free to offer suggestions for improvement.


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 2:56 am 
Offline
Total Newbie

Joined: Sat Sep 06, 2008 8:49 pm
Posts: 3
The following instructions will allow you to boot from an external usb drive. You will lose the mtd3(samba) partition on the internal nand flash, but I assume you will not need this storage once you are running off of an external drive. This guide assumes you are already comfortable using uboot and that you have already read the instructions for the conventional way to manually install Armel Debian on an internal SATA drive http://buffalo.nas-central.org/index.ph ... al_install

1. Prepare Your Drive

Just follow the instructions provided for the manual installation of Armel Debian. It will not make any difference that you are using a usb drive, it should still show up as /dev/sda. You need to partition your drive, create the file systems, and create the armel-lenny root file system.

2. Prepare the Kernel

Assuming your external drive is on /dev/sda do the following to load the kernel into nand flash. This will erase anything stored in your samba directory.
Code:
mount /dev/sda1 /mnt/sda1
flash_eraseall -j /dev/mtdchar3
nandwrite -p /dev/mtdchar3 /mnt/sda1/uImage


3. Prepare uboot

Get into uboot and enter the following.
Code:
setenv default_kernel_addr 0x00100000
setenv bootargs_base console=ttyS0,115200
setenv bootargs_root 'root=/dev/sda2 rw; rootdelay=10'
setenv bootargs $(bootargs_base) $(bootargs_root) $(buffalo_ver)
setenv uImage_block 0
setenv uImage_offset 0x04400000
setenv bootcmd 'nboot $(default_kernel_addr) $(uImage_block) $(uImage_offset); bootm $(default_kernel_addr)'
saveenv
boot


Thats it. You should now be able to boot into Debian Linux and the root will be on your external usb drive.

4. How to Go Back

If you decide that you want to go back to the way it was and not boot from an external drive just do the following. In uboot:
Code:
setenv default_kernel_addr 0x00100000
setenv bootargs_base console=ttyS0,115200
setenv bootargs_root root=/dev/mtdblock2 rw
setenv bootargs $(bootargs_base) $(bootargs_root) $(buffalo_ver)
setenv uImage_block 0
setenv uImage_offset 0x00020000
setenv bootcmd 'nboot $(default_kernel_addr) $(uImage_block) $(uImage_offset); bootm $(default_kernel_addr)'
saveenv
boot

Then to get back the /dev/mtd3 partition the way it was:
Code:
flash_eraseall -j /dev/mtdchar3
mkfs.jffs2 /dev/mtdchar3

Note: you may have to install mkfs.jffs2 as it appears to not be installed by default.


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 3:44 am 
Offline
Site Admin
User avatar

Joined: Mon Aug 28, 2006 1:15 am
Posts: 2606
nicely done fhakey - that didn't take you very long! :)

Thank you for the contribution to the community. I will link what you've done here to the armel article that you reference, as it is clearly related and others may wish to do what you've shown. EDIT : done -> KuroPro Armel - Related Forum Threads - HowTo: Boot Kurobox Pro from USB drive

I agree that the mtd3 (samba) partition is not very useful on nand flash - not really sure why they ever put it in. (this is my opinion only, Buffalo may have had some grain of wisdom that I don't see... but there's just not much room there for a samba share in flash...)

Glad this has worked out for you... ;)

btw, the XFS issue is something that has been hanging around the neck of ARM9 users now like a dead albatross, for quite some time. XFS worked on ARM9 back in the old days of OABI 2.6.16, but is quite buggy now in 2.6.25+ and it is generally advisable to stay away from it with the newer kernels ... there have been some hints at work to try to fix it, but the issue seems to have become protracted. Most of us find that JFS is a reasonable substitute...

_________________
LS1 (foonas, nfs, Tranmission & p910nd print server, Firefly for my Roku)
LS-HG500 (Lenny)
Various LS-Pros v1,v2 (unbricked w/ serial & jtag)
KuroPro, LS2 & KuroHG (foonas)
Working on davysweather.dyndns.org lately...

=> wooohooo!
wooohooo!
Unknown command 'wooohooo!' - try 'help'


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 6:11 am 
Offline
Moderator
User avatar

Joined: Thu Apr 06, 2006 1:33 pm
Posts: 1082
Location: United States of America
with apologies to fhakey and davygravy, I turned it into a wiki article
http://buffalo.nas-central.org/index.ph ... _USB_drive

please fix it up as appropriate

_________________
-Ramuk

LinkStation HG *250 Uboot - Foonas-EM - Freelink
Kuro HG *750 Uboot - Foonas-EM - Debian Squeeze
Kuro HD *60 Uboot - Foonas-EM - Debian Squeeze (For Sale)
KuroPro *2TB Debian Lenny Armel- Kernel 2.6.26
KuroPro *1TB Debian Lenny Armel- Kernel 2.6.25.6


Top
 Profile  
 
PostPosted: Sun Sep 07, 2008 4:57 pm 
Offline
Site Admin
User avatar

Joined: Mon Aug 28, 2006 1:15 am
Posts: 2606
thanks ramuk :)
I would like to test this out myself... when I get some free time...

_________________
LS1 (foonas, nfs, Tranmission & p910nd print server, Firefly for my Roku)
LS-HG500 (Lenny)
Various LS-Pros v1,v2 (unbricked w/ serial & jtag)
KuroPro, LS2 & KuroHG (foonas)
Working on davysweather.dyndns.org lately...

=> wooohooo!
wooohooo!
Unknown command 'wooohooo!' - try 'help'


Top
 Profile  
 
PostPosted: Wed Sep 24, 2008 7:56 am 
Offline
Regular Member
User avatar

Joined: Tue Oct 09, 2007 9:01 am
Posts: 117
Small addendum:

If you cant the hell figure out what the uImage offset is (like i did because i use the foonas non-standard flash partition scheme of davy-gravy's armel-lenny-images and thus couldn't use any of the default numbers in any of the howtos) you can use the following procedure to write the kernel image to flash and know the starting adress afterwards.

Base article:
http://wiki.davincidsp.com/index.php?ti ... NAND_Flash

You need:
- serial device (for uboot access)
- tftp server (for kernel image uploading)

In our case:

Code:
tftpboot


gives something like

Code:
TFTP from server <tftp server ip address>; our IP address is <dvevm ip address>
   Filename 'uImage'
   Load address: 0x80700000
   Loading:
   ######################################################################################
   ######################################################################################
   .
   .
   .
   ######################################################################################
   #######################################################
   done
   Bytes transferred = 1397368 (155278 hex)


Note the load adress and Byte count (the hex number).
Code:
nand info

shows us
Code:
Device 0: Samsung K9K1208Q0C at 0x2000000 (256 MB, 128 kB sector)

Important here is the sector size. Its 0x20000 in hex on a Kuropro.
Now for the actual math:
Code:
Kernel size = 0x225000
Number of sectors = 0x225000/0x20000 = 0x11
Rounded size = <number of sectors> * <sector size> = 0x11 * 0x20000 = 0x220000

As you can notice this would trim our image by some bytes, so we have to round up to the next sector, i.e. use the rounded kernel size = 0x240000.

Now we write it to flash, note that this ignores (and overwrites) any filesystem and data whatsoever on that specific place in flash, so backup any data you might need beforehand:
Code:
nand erase offset rounded-kernel-size

Note that the offset can be virtually any address allowed on your flash, but better place the kernel image on the first sectors.

in our example:
Code:
nand erase 0x60000 0x240000

You should see output like the following:
Code:
NAND erase: device 0 offset 393216, size 1397760 ... OK

and finally write the image to flash
Code:
nand write Load-Adress offset rounded-kernel-size

in our example:
Code:
nand write 0x400000 0x60000 0x240000

should give:
Code:
NAND write: device 0 offset 393216, size 1397760 ... 1397760
bytes written: OK


Now the image is written.

Finally set the bootcmd to our shiny new kernel and boot.
Code:
setenv bootcmd 'nboot 0x400000 0 0x60000;bootm'

which should boot your kernel from flash.

P.S.: Some numbers are still from the original article as im writing this from work. I will update the post in the evening with the correct Kuropro numbers (its only the first kernel size and nand info which is wrong though, the actual kernel-rounded-size and the erase and write commands are correct.)


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

All times are UTC [ DST ]


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:

Protected by Anti-Spam ACP
Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group