USB Support
Hardware
Some of the SupportedDevices, e.g. BR6104KP have usb plugs. On other devices like the BR6104K the USB stuff is not soldered in. You can add these parts using this tutorial. Depending on the oszillator you added you have to change the power supply for the oszillator from +5V to +3.3V (Pin 2 on JP2) to make USB working. Error messages like device nor accepting new address point to this problem.
USB storage devices
Preparing the USB stick
with a Linux PC
You can get additional disk space by plugging in an USB stick. But the for USB sticks common VFAT filesystem is not supported by midge at the moment (why ?). So you have to make a ext2 or ext3 filesystem on your stick first. To make the filesystem, plug your stick into your Linux PC. Find out the device name of the partition on the usb stick by checking the difference between the output of the mount command (as root) before and after you plug in the stick. After the stick was plugged in, the should be an additional line like
/dev/sda1 on /media/sda1 type vfat (rw,noexec,nosuid,nodev)
You device is /dev/sda1.
Unmount it now as root:
umount /dev/sda1
You have been warned. Make the new filesystem:
mkfs.ext2 /dev/sda1
Dependeing on your stick size and speed this will take a while. If ready, plug out and in your stick. It should be mounted again. Copy now to it what you want.
with a Windows PC
Please write down how to write an ext2 filesystem under Windows, if you own a Windows PC und you know how to do it.
It is not a comlete solution, but it is a workaround: You can use a Live-CD, these are really fast to download, don’t touch your Harddisk and are easy to use. I prefer Ubuntu.
USB support on midge
USB not as root device
Install the USB and ext2 modules (drivers) into your running midge:
ipkg install kmod-fs-ext2 ipkg install kmod-usb-core ipkg install kmod-usb-ohci ipkg install kmod-usb-shci ipkg install kmod-usb-storage
and load them into the running kernel:
insmod scsi_mod insmod sd_mod insmod ext2 insmod usbcore insmod usb-storage insmod usb-shci
Type dmesg to see, that the kernel found your USB plugs:
SCSI subsystem driver Revision: 1.00 usb.c: registered new driver hub Initializing USB Mass Storage driver... usb.c: registered new driver usb-storage USB Mass Storage support registered. usb-shci.c: Start Init AHCI_INIT usb.c: new USB bus registered, assigned bus number 1 hub.c: USB hub found hub.c: 2 ports detected
Now plug in your USB stick and type dmesg again:
hub.c: new USB device HUB-2, assigned address 2 scsi0 : SCSI emulation for USB Mass Storage devices Vendor: TOSHIBA Model: TransMemory Rev: 1.04 Type: Direct-Access ANSI SCSI revision: 02 Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 1001472 512-byte hdwr sectors (513 MB) sda: Write Protect is off Partition check: /dev/scsi/host0/bus0/target0/lun0: p1 WARNING: USB Mass Storage data integrity not assured USB Mass Storage device found at 2
device not accepting new address on a device with self added USB plugs, try to connect the oszillator power supply pin to +3.3V (JP2 Pin 2) instead of +5V.
Now mount the partition into the routers filesystem tree. You get the partition name from the dmesg output above:
mount /dev/scsi/host0/bus0/target0/lun0/part1 /mnt
The data from the USB stick should now appear in the folder /mnt.
Be shure that you have unmounted the partition and the sticks led has stopped to blink before you plug the stick out.
unmount /mnt
unmount or while the led ist blinking.
USB root device
Kernel
First we need a kernel, which searchs for the root filesystem on the USB media. Assuming you have already build a midge image make the following changes:
cd build_mipsel/linux-2.4-adm5120/linux-2.4.32/ make menuconfig
In the appearing menu change the kernel command line
General setup --->
[*] Default bootloader kernel arguments
Initial kernel command string:
from
root=/dev/mtdblock2 rootfstype=squashfs ro panic=10 console=/dev/ttyS0
to
root=/dev/scsi/host0/bus0/target0/lun0/part1 rw panic=10 console=/dev/ttyS0
or whatever the partition on your USB stick is (see above). Then change the SCSI and USB support from m to * , what meens that the drivers are direct in the kernel, no in lodable modules:
SCSI support --->
<*> SCSI support
<*> SCSI disk support
(2) Maximum number of SCSI disks that can be loaded as modules
File systems --->
<*> Ext3 journalling file system support
<*> Second extended fs support
USB support --->
<*> Support for USB
<*> OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support
<*> AHCI ADM5120 (USB 1.1) Host controller support (EXPERIMENTAL)
<*> USB Mass Storage support
Exit menuconfig an say yes to the Save-Question. Stay in this directory and download and apply the following patches:
wget http://schimmelnetz.de/projekte/eddi/files/do_mounts.c.diff wget http://schimmelnetz.de/projekte/eddi/files/usb-shci.c.diff wget http://schimmelnetz.de/projekte/eddi/files/usb-shci.h.diff patch -p0 < do_mounts.c.diff patch -p0 < usb-shci.c.diff patch -p0 < usb-shci.h.diff
If you want another baudrate than 115200 for /dev/ttyS0, change line 104 in arch/mips/am5120/serial.c. See also second_uart.
Only if you have the original, not the extended bootloader, apply the kernel entry patch:
wget http://midge.vlad.org.ua/tmp/004-kernel-entry.patch patch -p0 < 004-kernel-entry.patch
Now make your usb-root kernel
make
After complete, you find in the current directory a file vmlinuz, which is the new kernel. With the extended bootloader you can load this kernel direct in the SDRAM of your router and run it from there for testing. To make this kernel persistent in the router it has to be loaded into the flash. But the bootloader accepts only images with csys header. So you have to add it with the mksyshdr command, which we have to download and build using the normal system compiler, not the crosscompiler.
wget http://midge.vlad.org.ua/svn/trunk/openwrt-midge/target/linux/image/adm5120/src/mksyshdr.c gcc mksyshdr.c -o mksyshdr && chmod 755 mksyshdr ./mksyshdr csys vmlinuz cat csys vmlinuz > firmware.img
You can now flash firmware.img to your router.
Change to the openwrt root directory.
cd ../../..
root filesystem on USB media
You need now a root file system on your USB media.
You can also build your own usb root filesystem. Or to be exact, you already have it. It was generated with the normal midge image. So just make an ext2 filesystem on your stick and mount in on your Linux PC as described above. Then put the filesystem on your stick:
cd /media/sda1 # or where your empty USB stick filesystem is mounted (cd <path-to-your-kamikaze-src>/trunk/openwrt/build_mipsel/linux-2.4-adm5120/root && tar cBplf - . ) | tar xBpvf -
Before you unmount your stick, change on the stick filesystem in etc/midge.conf the MIDGE_TYPE to usb. You can also edit etc/resolv.conf, etc/hostname, etc/network/interfaces and etc/ipkg.conf to your needs, but you can do this later in the router too.
Unmount your stick, plug in into your router, boot the usb-root-kernel and be happy with midge on usb.
/tmp and /var are on a ramdisk, so that there is as less write access to the usb stick, as possible. If somebody has done that, please upload this filesystem to the wiki.
USB to serial adapter
You an connect a modem, a mobile phone or another serial device to the USB ports with a common USB-RS232 adapter cable. Install the usb and usb-serial modules, if not already done above:
ipkg install kmod-usb-core ipkg install kmod-usb-ohci ipkg install kmod-usb-shci ipkg install kmod-usb-serial insmod usbcore insmod usb-shci insmod usbserial
Install the device specific modules:
ipkg install kmod-usb-serial-ftdi && insmod ftdi_sio # my USB-RS232 adapter cable or ipkg install kmod-usb-serial-pl2303 && insmod pl2303 # Siemens mobile phone cable
Connect your mobile phone with modem emulation or a real modem to the cable. Now there should be a device file like this:
crw——- 1 root root 188, 0 Jan 1 1970 /dev/usb/tts/0
If yes you can now test it usin two shells on your router:
# In the first shell listen to the serial device, stop with Ctrl-C: cat /dev/usb/tts/0 # In the second shell write something to the serial device: echo AT > /dev/usb/tts/0
In the fist shell now you should see
AT
OK
That means, your modem answered OK to yout AT. Be happy now.
USB bluetooth adapter
has to be written...
