OpenWrt Forum Archive

Topic: OpenWRT on a Regular x86 Computer using USB Flash

The content of this topic has been archived on 7 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Ok, I am now totally lost and I'm sure I would have pulled my hair out if I could get a grip on it.  This might have a simple solution, but "simple" looks like a mighty high mountain right now.

THIS IS WHAT I WANT:
I have an x86 computer that I need to turn into a router and I want to boot OpenWRT from an USB Flash drive.  It "seems" simple enough and a really good application for old comptuers.

There is no hard drive in the computer, I do not have access to a router to run OpenWRT, and this is my first ever build.

POSSIBLE SOLUTION:
I suspect the solution involves including various "modules" into the build image and making tweaks to the files system (i.e., fstab, init, arrrrrgggghhhhh)...and that is where all the tips around the web get muddled together in my head.

SO FAR...WHAT I HAVE DONE:
I've installed all the tools for making OpenWRT (backfire)
I've told "make menuconfig" to compile the following into the output images (combined ext2 and squahfs):
  block-mount
  kmod-fs-ext3
  kmod-fs-ext2
  kmod-usb-core
  kmod-usb-ohci
  kmod-usb2
  kmod-usb-storage
  block-hotplug
  block-extroot
  fdisk
  e2fsprogs

Who knows if they are the right ones, but...there ya go.

I use dd to copy the image to the flash drive, boot, get grub, get a bunch of stuff that ends with:
input: SynPS/2 ... and then the power just cut out so I can't read the screen of that computer (Im in rural Uganda), but just after that I recall that I get "waiting for root device /dev/mtdblock0" or "waiting for root device /dev/sda2" and then the system hangs...waiting..,until power goes out of course.

So, I figure boot works and init starts, but it has no way of knowing where the filesystem really is.  Its all set up assuming everything is installed on an internal HD/flash.  Arrrrghhh.  I think the

Anyone have any experience with this?

First of all: you need to embed the filesystem and usb support into the kernel itself. Just including the kmod packages is not enough since OpenWrt lacks any support for initrd mechanisms.

Launch "make kernel_menuconfig"
Go to  Device Drivers -> [*] USB support
  Select <*> Support for Host-side USB
  Select <*> USB Mass Storage support
Go to File systems
  Select <*> Second extended fs support
  Select <*> Ext3 journalling file system support
  Select <*> The Extended 4 (ext4) filesystem
Exit and save

Proceed with "make target/linux/clean world V=99"

You are probably going to spend more $$$ on operation costs if you use a computer as a router.

Thank you for being the first teachers of my OpenWRT education!  As I wait for your suggestions to compile...

Jow - Question 1:  I want to set menuconfig and kernel_menuconfig back to the default (how is was when downloaded from SVN).  Can I just copy over .config from the pristine download I saved?  What about the config for kernel_menuconfig, or is that the same file.  I want to trouble-shoot methodically one small step at a time, but instead I am compiling your suggestions along with all of the other changes I previously made to menuconfig.

Jow - Question 2:  In "make target/linux/clean world V=99" is it important for me to know what "target/linux/clean work" is right now?  Before I just did "make V=99".

Mazilo - I agree.  The problem is I'm located in rural Uganda, there are limited router choices, and no money, but there is a computer with a celeron and 64MB ram.  Our 3G network will vastly increase in speed, but with a capacity cap.  My organization will likely zip right through the cap so I need to implement some Quality of Service rules.  The current router can't do that, so I have to find a creative solution.  That does give me an idea though: I should do some electrical load tests to calculate just what the financial difference is.  Ill need a psychologist to determine the mental differences and an educator to determine the personal educational gain.

Ok, Ive compiled and dd'ed the combined file-system (tried both squashfs and ext2) with the modules you suggested added.

It still hangs at "Waiting for root device /dev/mtdblock0..."

...but, at the top of that same screen it says "USB Mass Storage support registered" and proceeds to tell me that usbcore: registered new interface driver ..."


----

When I select the following after entering make kernel_menuconfig:
  Select <*> Support for Host-side USB
  Select <*> USB Mass Storage support
A bunch of other options appear.  Should I be enabling those, or should I just leave them as is?

Should  "USB device filesystem (DEPRECATED)" be selected?

Maybe this helps.

Same error message as before with this build using both ext2 and squashfs combined, but this time in menuconfig I made sure I ONLY specified the target and NOTHING else (I started with a brand new .config file).  I then did exactly the following (I did not select ANY sub-options):

jow wrote:

Launch "make kernel_menuconfig"
Go to  Device Drivers -> [*] USB support
  Select <*> Support for Host-side USB
  Select <*> USB Mass Storage support
Go to File systems
  Select <*> Second extended fs support
  Select <*> Ext3 journalling file system support
  Select <*> The Extended 4 (ext4) filesystem
Exit and save

Proceed with "make target/linux/clean world V=99"

I did notice that "USB device filesystem (DEPRECATED)" was selected.  Perhaps that is by default.

Any ideas?  Should I select some of the USB related sub-entries in kernel_menuconfig (there are a lot for my head)?  Any modifications in the filesystem (scripts, configs, etc) to point the root device to the right device?  Wash the computer with coffee?  Thanks everyone.

--

vpritiskovic: This is a USB Flash drive that I need to boot so I don't think it uses ATA related resources....I....think....maybe?...ish...hmmm.  Thanks for the suggestion and glad you got your CF setup working.

You should use a pure ext2 image. The squashfs version relies on block2mtd which does not work well together with usb.
Deprecated usbfs support is not needed.

Ok, got further this time.  Now I get the following:

...........
Waiting for root device /dev/sda2...
scsi 2:0:0:0: Direct-Access     Single   flash reader     1.00 PQ: 0 ANSI: 0
sd 2:0:0:0: [sda] 1984000 512-byte logical blocks: (1.01 GB/968 MiB)
sd 2:0:0:0: [sda] Write Protect is off
sd 2:0:0:0: [sda] Assuming drive cache: write through
sd 2:0:0:0: [sda] Assuming drive cache: write through
  sda: sda1 sda2
sd 2:0:0:0: [sda] Assuming drive cache: write through
sd 2:0:0:0: [sda] Attached SCSI removable disk
VFS: Mounted root (ext2 filesystem) readonly on device 8:2.
Freeing unused kernel memory: 300k freed
Please be patient, while OpenWrt loads ...
Kernel panic - not syncing: Attempted to kill init!
atkbd.c: Spurious NAK on isa0060/serio0.  Some program might be trying to access hardware directly
.........

Note that this was based on using an SD card on an internal reader.  However, I also tried the same thing using the SD card in a external card reader (I had to change a the boot setting "root=sda1" to "root=sdb2"...or something like that) AND a USB Flash drive.  The last 5 lines of the error are the same for all the attempts.  Also my caps/num lock light is kindly blinking at me.  The very last line shows up after waiting for awhile (10 minutes?).

As per your suggestion, I am using the pure ext2 image.  However the depreciated usbfs is still selected (will de-select on next build).

lspci on my test laptop gave the following:
  00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller #4 (rev 02)
  00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI Controller (rev 02)

So, in make "kernel_menuconfig > Device Drivers > USB Support" I enabled the following:
  <*> EHCI HCD (USB 2.0) support
         [*] Root Hub Transaction Translators   <--Did I activate this?  Anyway, its selected.
  <*> UHCI HCD (most Intel and VIA) support
In make "kernel_menuconfig > Device Drivers" I have:
  <*> MMC/SD/SDIO card support

-----

I'll let this build again (make target/linux/clean world V=99) while I sleep without the usbfs support AND without MMC/SD/SDIO card support and test again in the morning.

Anything stand out as obviously wrong?  My brain is full and partly off so naturally it all looks like a cross between wrong, soup, and pillows.

Ok, my brain is on and I've had my coffee. I've gotten somewhere in troubleshooting (results and questions at the end):

SAME OLD ERROR:
----------------------
I get the same error:
    "Kernel panic - not syncing: Attempted to kill init!"
When using a normal USB Flash drive this time (and tried it using VirtualBox as well) with the following kernel options enabled:
   <*> Support for Host-side USB
   <*> EHCI HCD (USB 2.0) support
        [*] Root Hub Transaction Translators
   <*> Second extended fs support
   <*> Ext3 journalling file system support
   <*> The Extended 4 (ext4) filesystem

I DID NOT enable either depreciated usbfs or MMC/SD/SDIO card support

I did try using debug mode in grub, but the error is sadly exactly the same (perhaps I'm not entering it correctly?).

BUT IT WORKS WHEN...
-------------------------
I read this ticket: <a href="https://dev.openwrt.org/ticket/8050">https://dev.openwrt.org/ticket/8050</a  and decided to try .vdi in VirtualBox.
I got the same error.  So I decided to see if a COM port was enabled.  NOPE.
Sooo, I enabled a COM port and had it redirect to a file.
IT WORKED.  IT BOOTED ALL THE WAY.

CONCLUSIONS (I THINK)
----------------
The laptop I am testing on has only USB ports.
I did nothing with serial anything in make kernal_menuconfig or make menuconfig.
I figure I need to enable a serial port somehow.

HAVE ANY IDEAS?:
--------
An ideas for how to enable a serial port when I only seem to have USB ports?
Can I direct serial through a USB port?
What about if I use a USB to Serial converter?  Think that would work?
...and is the serial port really my problem?  There is always room for confusion.

Jow, might I add that I am very thankful for your help in getting me over the first couple of mountains.  Thanks.

AH HA!!!!!  One more time AH HA!!!!  IT BOOTS!

So there was a problem with the serial port.  This is what I did
Sooo, in grub I went to edit the kernel.

I changed:

"...console=tty0 console=ttyS0,38400n8 noinitrd reboot=bios"

to:

"...console=tty0 noinitrd reboot=bios"

SUMMARY
-----------
I removed the reference to the serial port ttyS0 in the kernal boot options.

Cool! Sorry I didn't think of the serial port issue.

I have the same problem?
Waiting for root device /dev/sda2...
ide or usb Do not know how to solve,

The discussion might have continued from here.