Adding USB support into firmware

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Author Message
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Thu Mar 20, 2008 19:58    Post subject: Reply with quote
I'll see what I can do. Alot of this will be done via the usb.startup and usbdaemon.sh scripts that I had written up before however usb.startup is broken down to the bare basics. I do want to check something and if it proves that it is what I think of it then I may never have to worry about implementing mknod into busybox. Also I'll see about the swap support. One step at a time here.
Sponsor
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Fri Mar 21, 2008 4:58    Post subject: Reply with quote
Ahh... yes. Got p910nd printer daemon into the build cycle. It will build along with everything else. If I did it right then it will only build for USB enabled versions. The p910nd 0.92 binary will be at /sbin in the firmware. I havn't actually tested it yet but it compiled at only 12KB which makes it very small. A section that branches off of the usb printer item may be added that allows you to enable/disable the daemon at will and to enable/disable bi-directional support.

Here is everything I have done so far...

USB Serial Support

Added Firmware
/lib/modules/2.4.35/usbserial.o
/lib/modules/2.4.35/ftdi_sio.o
/lib/modules/2.4.35/pl2303.o

New files
Replace usb serial with one from usb.2.4.28. Mix and match drivers. Don't like it but it does work. :(

Changed Files
sysinit-broadcom.c (src/router/services/sysinit/sysinit-broadcom.c) -- added support for usb_serial nvram and added insmod lines
defaults.c (src/router/services/sysinit/defaults.c) -- added support for usb_serial nvram variable
usb.nvramconfig (src/router/usb/usb.nvramconfig) -- added usb_serial entry
usb.webservices (src/router/usb/usb.webservices) -- added usb serial entry
english.js (src/router/kromo/dd-wrt/lang_pack/english.js) -- added english translation
Makefile (src/router/Makefile) -- added lines to move usb serial modules
.config_mini (src/router/busybox/.config_mini) -- new one -- Enable STTY
.config_std (src/router/busybox/.config_std) -- new one -- Enable STTY
.config_std (src/linux/brcm/linux.v24_2/.config_std) -- enable CONFIG_USB_SERIAL, CONFIG_USB_SERIAL_FTDI_SIO, CONFIG_USB_SERIAL_PL2303 to m (module)

Added nvram setting
usb_serial


USB Automount

Modified Files
rootprep.sh (src/router/misc/rootprep.sh) -- added /usb symlink (/usb -> /tmp/usb)
defaults.c (src/router/services/sysinit/defaults.c) -- added usb_automount
usb.nvramconfig (src/router/usb/usb.nvramconfig) -- usb_automount added
usb.webservices (src/router/usb/usb.webservices) -- usb automount added to webgui
english.js (src/router/kromo/dd-wrt/lang_pack/english.js) -- added english translation for usb automount

Added Files
usb.startup (src/router/usb/usb.startup) -- startup script -- implement load of usbdaemon.sh and facilitate usbfs
usbdaemon.sh (src/router/usb/usbdaemon.sh) -- automount script -- automount capability to /usb and complete usb serial support

Added nvram
usb_automount


USB printer daemon

Added Firmware
/sbin/p910nd

Added Files
p910nd added to /src/router/p910nd -- Modified makefile for cross compilation and build system integration

Modified Files
configs.mk (src/router/rules/configs.mk) -- added p910nd to CONFIG_USB


The bit for /opt isn't implemented yet and I havn't created a script for the p910nd daemon. I'll do that seperate from the standard usb stuff.

Oh and I'll add swap to my todo list. Once everything else is done then I'll get to setting up swap support into busybox. Trying to not inflate the firmware too much.

From what I can tell it looks like the usb serial support is complete. It is adding and removing nodes in /dev/usb/tts automatically. The first usb serial device will get /dev/usb/tts/0 and it goes up from there. The dmesg output will state which it was bound to.

P.S. - If anyone wants a build then just ask. I can create and post one here without issue. I have been testing them on my router and the last build was posted to show that I was getting there.
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Fri Mar 21, 2008 12:48    Post subject: Reply with quote
Great job. The p910nd is only 12k on my setup, so it looks like it should be ok. I am not sure how big swap support is in busybox, but if it is too big we can install a full blown busybox via Optware. That is how I have swap enabled now. Starting Optware programs from the script is more important. You really are getting this to the point of being the "Swiss army knife" of USB. I can wait for when it is ready unless you are looking to have someone beta test it.

Thanks
Bkmo
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Fri Mar 21, 2008 15:24    Post subject: Reply with quote
Yep. If you want to test any build then let me know. Since you are using p910nd already can you let me know what the device node locations are at for usb printers and what command line you use? I can create a script around that I think.
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Fri Mar 21, 2008 16:00    Post subject: Reply with quote
shinji257 wrote:
Yep. If you want to test any build then let me know. Since you are using p910nd already can you let me know what the device node locations are at for usb printers and what command line you use? I can create a script around that I think.

This is what I am using now and was tested as working when a printer is attached:
Code:

#Load USB Printer support for 1 USB Printer Bi-directional
if [ -e /dev/usb/lp0 ]; then /jffs/sbin/p910nd -b -f /dev/usb/lp0 0
 fi

The -b switch is for bi-directional support. The 0 at the end is for the port it will use, 0 being 9100. If you have a second printer at say /dev/usb/lp1 you would probably put a 1 at the end to use port 9101, and so on. The -f switch is placed in front of the device.
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Fri Mar 21, 2008 16:50    Post subject: Reply with quote
Ahh... ok. Thanks! If I keep this up we will need to move USB support to it's own tab eventually. Once that is done then maybe we can even do the mount/unmount via the web gui like Eko suggested. Unfortunately the code work involved is above me at the moment until I decipher the template layout for the asp files in the source.

P.S. - One thing I would like to do is move everything over to work with hotplug event notification. Contrary to what I had thought hotplug is enabled in the kernel and it is actively setup in the firmware. /sbin/hotplug exists already for example... ;)

The problem is that /etc/hotplug does not exist and it would normally contain scripts to handle the hotplug events. Right now hotplug provides devfs and usbfs which is also part of the kernel which allows the device nodes to be created on the fly. This doesn't mean I won't finish what I am going with now. I am nearing completion and finishing up the final bits that make those usb modules useful. There are baseline hotplug scripts already available. I'll try adding those and see what kind of effect is made. I'll disable my automounting startup script in the meantime.

From the linux-hotplug CVS repository:
http://linux-hotplug.cvs.sourceforge.net/linux-hotplug/admin/etc/hotplug/

EDIT: When I get time I'll create a branch from my current work that will attempt to see what will happen if the remaining hotplug scripts were implemented into the firmware.


Last edited by shinji257 on Fri Mar 21, 2008 17:01; edited 1 time in total
bkmo
DD-WRT User


Joined: 18 Oct 2007
Posts: 385
Location: Grecia, Costa Rica

PostPosted: Fri Mar 21, 2008 17:00    Post subject: Reply with quote
I know OpenWRT has hotplug support. Also something called hotplug2, but I am not sure whether hotplug was working under WhiteRussian, or just Kamikaze with the 2.6 kernel. Do you think you can select the mountpoints for the partitions with hotplug?
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Fri Mar 21, 2008 17:29    Post subject: Reply with quote
I honestly don't know. Right now the script is timed to wait 5 seconds before re-scanning. It scans for any new devices and un-mounts any that are no longer connected. I found the following in /proc while hunting around for other stuff...

/proc/scsi contains usb storage devices and if they are attached or not
This would make device detection alot more fool-proof.
Sample (/proc/scsi/usb-storage-0/0):
Code:

   Host scsi0: usb-storage
       Vendor: LEXAR MEDIA
      Product: JUMPDRIVE SECURE
Serial Number: 106A7801005359260305
     Protocol: Transparent SCSI
    Transport: Bulk
         GUID: 05dca4007801005359260305
     Attached: No


/proc/partitions contain a list of partitions for each device
Will make it a bit easier to mount partitons.
Sample:
Code:

major minor  #blocks  name

   8     0     251440 scsi/host0/bus0/target0/lun0/disc
   8     1     249856 scsi/host0/bus0/target0/lun0/part1
   8    16     250879 scsi/host1/bus0/target0/lun0/disc
   8    17     248976 scsi/host1/bus0/target0/lun0/part1

Major is the device type
Minor is the device node number
The disc item will be multiples of 16 starting with 0 being the first one
individual partitions will be between each mark so the first device will have 0 for disc then 1-15 for partitions
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Sat Mar 22, 2008 1:51    Post subject: Latest Changes Reply with quote
Just giving an update on this. None of my todo is actually done but some other stuff has been taken care of.

Modified Files
usb.nvramconfig -- add additional choices to usb_storage and usb_printer // removed usb_automount
usb_storage = 2 means enable automount
usb_printer = 2 means enable printer daemon

usb.startup -- remove /dev/usb/tts creation and usbfs mount (moved to sysinit) // changed automount test to check usb_storage option and see if it is set to 2.
usb.webservices -- add additional choices for automount and print server // removed usb automount
defaults.c -- removed usb_automount
english.js -- remove service.usb_automount -- add usb.printsvr language items
sysinit-broadcom.c -- changed condition for usb_printer and usb_storage to also match set 2 -- works if not equal to 0 // added line to mkdir /dev/usb/tts (please make this work!) // added line to mount usbfs.

If none of the files I have changed have been modified since 4330 then I'll probably start a new codebase from 4333. I'll copy it over the modified files then do a diff process on it with the existing code. I'll have to create a change list and make sure to copy over new files or ones that were replaced.
tacothekid
DD-WRT Novice


Joined: 16 Sep 2007
Posts: 28

PostPosted: Sun Mar 23, 2008 1:13    Post subject: Include acm.o in usb serial builds? Reply with quote
shinji257,
I have a question as to why acm.o isn't included in your usb serial builds. Isn't abstract control model basically another type of USB serial port?

The reason I'm asking this is that I'm trying to connect a EVDO cell phone to the USB port on a Asus router and use EVDO as my internet connection. I've tried so many different builds, with or without native usb support, and can't seem to get it to work. I installed the necessary usb drivers when needed. When I start sending or receiving data over the port, /dev/usb/acm/0, it crashes the whole router. Sometimes ppp will run for a minute, sometimes crashes as soon as it's connected.
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Mon Mar 24, 2008 5:26    Post subject: Reply with quote
Looks like it. I'll see about adding it in as it may be needed for certain other usb devices (i.e. usb based modems...) although I don't know how far I can really go with usb serial support built in. These modules have to be small. If I do it then I may need to create /dev/usb/acm during sysinit like I am doing now for the regular one. BTW, that bit isn't in my last relased build.

EDIT: Looks like the USB ACM module is a new device class in itself. It will be on a rather low priority as this will be moving off the beaten path quite a bit. I'll look into adding it after all other bits are complete. On the other hand maybe I'll just drop it into the firmware to see the size effect and do nothing more until later. Wink I did take a look at it and it appears I won't hit the tty_ldisc_ref issue I hit with usbserial.

Also keep in mind that these are building using the usb serial drivers from kernel 2.4.28. In other words bugs fixed in the usb serial code starting on version 2.4.29 will not be included here unless I can figure out why tty_ldisc_ref isn't being considered as resolved.

Look for a new build release once I finish up the optware and printer support. Not much to do really....

Probably write an opt.startup script (can be enabled/disabled?)

Write a quick script to start the print daemon when a usb printer is detected. For now I will only support one usb printer. If you want the others to run then you can start additional servers manually. The binary is already in my builds but no script has been written.

Actually I'll probably just finish up the print server support first then release a new one then get the optware bit done. It is only going to mount /opt and optionally create a swapfile for the server. Someone in this thread requested swap support enabled into busybox so I will see what kind of firmware size impact it creates.
myhtpc
DD-WRT Novice


Joined: 20 Dec 2007
Posts: 15

PostPosted: Thu Apr 03, 2008 14:41    Post subject: Reply with quote
Hi shinji257,

are there any news?

I'd like to set up my Linksys WRT350N with USB, but I think it would make sense to wait until your optware version is ready.

Thanks for your great work

Juergen
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Sat Apr 05, 2008 17:41    Post subject: Reply with quote
Unfortunately I am at a stall right at the moment. Work and other things have been preventing me from being able to test them. I still have to test my new builds that I did last week (new nvram settings, gui change, and building acm module) and I also want to test my code changes to tty_io.c (linux kernel source -- drivers/char/tty_io.c). This change was to change the exports from GPL ones to non-GPL. I actually don't even know if they will compile but if it does then it may allow me to use 2.4.35 usb serial drivers therefore getting all the fixes into play that were introduced after 2.4.28.

The nvram changes involved some prep work for optware and swapfile support. I don't plan on putting in a swapfile size option into the gui but there will be a nvram variable that will allow for it's control. The setting will be the size in MB and it will be a range from 32 to 512. If it is set to below 32 then it will be reset to 0 and treated as such. Optware will be a separate script that will terminate upon the first drive insertion.

The gui changes involved changing certain options to checkboxes rather than Enable/Disable options. If it works then I can add those for some of the future ones and maybe change the filesystem one to that as well. This will save some space in the gui.
zemitras
DD-WRT Novice


Joined: 21 Mar 2008
Posts: 20

PostPosted: Sat Apr 12, 2008 19:11    Post subject: Reply with quote
shinji257, first of all thank you for your work on this

Is there a plan to enable any kind of feature like an USB automount like in oleg's firmware?

A FTP server, or a samba share would be possible too?

Oleg's firmware has it all working out-of-the box, but I prefer much more dd-wrt firmwares, so it would be perfect to have the best of the 2 worlds :)

Thanks!
shinji257
DD-WRT User


Joined: 02 May 2007
Posts: 222

PostPosted: Sat Apr 12, 2008 20:15    Post subject: Reply with quote
The automount is done. See the link in my signature to get the last firmware I released. I won't be doing any more for a few days since I have to redo my laptop but I will get back to it afterwards. I actually don't know how oleg implemented it but I used a looping script to do it. I think it works quite well although it could use some tweaking.
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next Display posts from previous:    Page 9 of 10
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
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 vote in polls in this forum
You can attach files in this forum
You can download files in this forum