What's new

RS232 Serial Port from USB

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

latenitetech

Regular Contributor
Newbie here, acquired an RT-AC68U a month or so ago, installed AsusWRT-Merlin, currently running 380.64. I've installed entware, and am running Samba, minidlna and pyTivo as media servers (they work great!). My latest project is to get 'heyu' (an X10 home automation package) installed and running. It requires a simple RS232 connection to an external device (an X-10 CM11A controller). I have a couple of USB->serial adapters, both with Prolific chip sets. When I plug either one into the USB2 port, they of course come up as a "GSM modem" per the default drivers built into the router.

So my relatively simple question is, short of rebuilding the kernel myself (obviously a huge learning curve for a newbie), is there a way to get the router to allow me to use that USB->serial adapter as a vanilla 'com' port?

From what I've picked up scouring the internet, the standard solution seems to be to acquire a properly built pl2303.ko file, then use modprobe to remove the current 'option.ko' and install the 'pl2303.ko' module in its place. OK, I can handle that, but I can't for the life of me find a current pl2303.ko file. Are there any repositories for such drivers?

Looking at this post from 2014:
http://www.snbforums.com/threads/libftdi-usbserial.18231/#post-127901
it appears perhaps those extra modules used to be included in the firmware? I can't seem to find them if they're still there.

OR, could someone build and supply me such a driver file? (I would be extremely grateful.)

OR, I have set up a limited native build environment on the router itself, using gcc from entware. In fact I had to build the heyu executable from source that way and was successful. (It’s a small program and only took a few minutes, once I addressed the makefile issues.) Can anyone point me to a how-to for building that .ko module natively using the entware gcc (if that’s even possible)?

Assuming I eventually get heyu working, I'd be happy to write a Wiki how-to for this community. I'm a bit surprised there isn't more interest in it, as it seems like a natural fit for this router platform and those of us still running old-school home automation.

Thx!

-Mark
 
Zirescu,

Thanks for the response. Yes, I had come across that thread previously, which is one of the places I learned where you can use modprobe and/or insmod to replace a kernel module. But I don't see anywhere in that thread where I can find the 'pl2303.ko' module (for the Prolific chip set). The archive link provided by ryzhov_al is for MIPSEL architecture (I need ARM for RT-AC68U).

The last 'ftdi_sio.ko' file built by EsTeTicu is for a different USB->serial chip set (FTDI vs Prolific). I tried to load it anyway (just to see if it would work if I were to acquire an FTDI USB->Serial adapter), and it failed to load with "insmod: can't insert 'ftdi_sio.ko': invalid module format" and in the system log "kernel: ftdi_sio: disagrees about version of symbol module_layout." So I'm thinking it was either built incorrectly, or is too old for the current Merlin firmware build. (EsTeTicu provided that module in Apr 2015 for Merlin v378.52.)

So I believe I'm still on the hunt for the elusive 'pl2303.ko' file compatible with the most current Merlin build for the RT-AC68U, unless I'm missing something here (which is of course, very possible).

More help? Thx

-Mark
 
Just as an FYI -- both the FTDI and Prolific drivers have a strong relationship back to the Option.KO driver -

Goes back to 2G/3G cards for tethered WAN PPP services... these devices were RS232 out, and Profilic and FTDI were the primary Serial/USB driver vendor for cables - there's also the KLSI chipset, which is really old...
 
Zirescu,

Thanks for the response. Yes, I had come across that thread previously, which is one of the places I learned where you can use modprobe and/or insmod to replace a kernel module. But I don't see anywhere in that thread where I can find the 'pl2303.ko' module (for the Prolific chip set). The archive link provided by ryzhov_al is for MIPSEL architecture (I need ARM for RT-AC68U).

The last 'ftdi_sio.ko' file built by EsTeTicu is for a different USB->serial chip set (FTDI vs Prolific). I tried to load it anyway (just to see if it would work if I were to acquire an FTDI USB->Serial adapter), and it failed to load with "insmod: can't insert 'ftdi_sio.ko': invalid module format" and in the system log "kernel: ftdi_sio: disagrees about version of symbol module_layout." So I'm thinking it was either built incorrectly, or is too old for the current Merlin firmware build. (EsTeTicu provided that module in Apr 2015 for Merlin v378.52.)

So I believe I'm still on the hunt for the elusive 'pl2303.ko' file compatible with the most current Merlin build for the RT-AC68U, unless I'm missing something here (which is of course, very possible).

More help? Thx

-Mark
How about LAN <> RS232 must be USB<>RS232?
 
TonyH - Interesting idea, but I'm not even aware of an ethernet<->RS232 adapter (if that's what you're suggesting), but it doesn't sound cheap, and then I'd be on the hunt for yet another driver that presents that device to the application as a serial port. Sounds way more complicated than me just biting the bullet and setting up my own build environment to build the pl2303.ko module myself.

sfx2000 - Any chance you're aware of a way to simply use the option/modem driver as something close to a standard serial port? I took a look at the option.c code and frankly it's beyond me what it actually does, but it appears to just be a shim of some sort between the USB and RS232. Since I'm already building the heyu application, if there was a reasonable set of changes I could make to the serial port handling code in heyu to make it play nice with the option driver, that would actually be a good solution. Then I wouldn't have to get in the business of always having to update the kernel module in the router when Merlin puts out a new release.
 
So I believe I'm still on the hunt for the elusive 'pl2303.ko' file compatible with the most current Merlin build for the RT-AC68U, unless I'm missing something here (which is of course, very possible).
I had to do a compile, so enabled it on (380.64). It has dependencies which should already be there, but you need to load it with modprobe and not insmod. (rename the file from pl2303.ko.pdf to pl2303.ko of course)
 

Attachments

  • pl2303.ko.pdf
    21.1 KB · Views: 545
John -

WooHoo - success! Thank you so much for building and supplying that file! This is the command set that ultimately worked:
Code:
modprobe -r option
modprobe usbserial
insmod pl2303.ko
I tried 'modprobe pl2303.ko' and got "module kl2303.ko not found in modules.dep", so I'm thinking modprobe can only load modules known to it in the firmware's modules.dep file. That's why I used 'insmod' and it worked! And I had to reload 'usbserial' via modprobe because the removal of 'option' also removed usbserial, which is needed by pl2303.

Heyu is now talking to my CM11A and I can control my X-10 modules through the router. Yay!

A slightly strange side effect is that the 'GSM modem' driver still loaded as well (after the pl2303) when I plugged in the USB adapter. I'm thinking that's built into the usbserial.ko module (which I obviously didn't replace). It doesn't seem to impact my ability to communicate through the serial port though. And I was also able to run 'modprobe -r option' again (after the USB adapter was plugged in), and it successfully removed the modem again, without impacting the pl2303. Here is the complete log:
Code:
[usb adapter _not_ plugged in, execute commands above]
kernel: USB Serial deregistering driver GSM modem (1-port)
kernel: usbcore: deregistering interface driver usbserial_generic
kernel: USB Serial deregistering driver generic
kernel: usbcore: deregistering interface driver usbserial
kernel: USB Serial support registered for generic
kernel: usbcore: registered new interface driver usbserial_generic
kernel: usbserial: USB Serial Driver core
kernel: USB Serial support registered for pl2303
kernel: usbcore: registered new interface driver pl2303
kernel: pl2303: Prolific PL2303 USB to serial adaptor driver 

[plug in USB adapter ...]
kernel: usb 2-2.4: new full speed USB device using ehci_hcd and address 4
kernel: pl2303 2-2.4:1.0: pl2303 converter detected
kernel: usb 2-2.4: pl2303 converter now attached to ttyUSB0
kernel: USB Serial support registered for GSM modem (1-port)
kernel: usbcore: registered new interface driver option
kernel: option: v0.7.2:USB Driver for GSM modems

[run 'heyu'  - it works!]

[execute modprobe -r option]
kernel: usbcore: deregistering interface driver option 
kernel: USB Serial deregistering driver GSM modem (1-port)
['heyu' is still working fine ...]

I still need to incorporate the commands into the init-start script so it will survive a reboot, and I'll probably play with adding that extra "modprobe -r option" somewhere later in the boot sequence, after I'm sure the USB adapter loaded all the driver modules (perhaps in the init.d script that starts the 'heyu' program).

I will report back here what I finally end up with. I personally hate threads that don't bring closure to an issue, as I'm sure this will be read in the future by someone doing something similar. And I also apologize for being long-winded, but I'm really trying to make my experience here a valuable contribution to this knowledge base for future hackers.

Thanks again!
-Mark
 
Always like to get a WooHoo! :D Glad to help out.

You are also probably correct about modules.dep
When I tried to load it with modprobe, it automatically loaded usbserial and pl2303.
 
OK, I believe this is my closure on this issue. Everything seems to be working fine. This is what my init-start script (under /jffs/scripts) looks like:
Code:
#!/bin/sh

# Load the pl2303 module for USB serial port support
modprobe usbserial
insmod /jffs/modules/pl2303.ko
Despite some other threads where they also included "modprobe -r option" and "modprobe usbcore" in the init-start, I don't believe those 2 lines are necessary. What I have above worked fine through several test reboots.

But I do still see in the system log the GSM modem (from option.ko) registering about 5 seconds after the pl2303 is detected and attached to ttyUSB0. It doesn't seem to hurt anything, but I decided to kill it again in my init.d start-up script for 'heyu'. A simple one-liner "modprobe -r option" there, and per the system log, it's deregistered.

Thanks to those that responded here, and especially to john9527 for supplying the pl2303.ko file for which I am sincerely appreciative.

-Mark
 
Always like to get a WooHoo! :D Glad to help out.

You are also probably correct about modules.dep
When I tried to load it with modprobe, it automatically loaded usbserial and pl2303.

Nice to see some level of success - the usbserial mod sets up things, so that pl2303 can attach to it...

WebGUI might get confused - so go under the hood... it'll probably be right as rain...
 
... But I do still see in the system log the GSM modem (from option.ko) registering about 5 seconds after the pl2303 is detected and attached to ttyUSB0. It doesn't seem to hurt anything, but I decided to kill it again ...
Maybe a bind mount will prevent automatic loading of option.ko module?
Code:
# disable automatic loading of option.ko module
/sbin/modprobe -r option
/bin/mount -o bind /dev/null /lib/modules/2.6.36.4brcmarm/kernel/drivers/usb/option.ko
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top