Topic: how can I build a module for an unrecognized device

Hello
I have a MSR HCR331 which communicates through a onboard ( as in on device's board ) PL2303X serial to USB chip adapter
It should be supported by pl2303.ko module , but , as you can see here - http://kerneltrap.org/mailarchive/git-c … 4/30/32388 - it isn't , because it presents itself ( by a lsusb ) as 067b:331a and not 067b:2303 .
I can use it on a Redhat9 vmware machine by building its .o module from source ( found here : http://www.prolific.com.tw/eng/downloads.asp?ID=31 ) - the result is a hcr331.o which is practically a pl2303.o modified to know this device's PID ; after insmod hcr331 i can stty -F /dev/ttyUSB0 9600 raw cs8 and I can communicate ( r/w ) with the magnetic card reader
I can't use something like modprobe pl2303 vendor=0x067b product=0x331a because the command throws an error complains about vendor unrecognized argument ( probably the pl2303 module doesn't support arguments )
I tried to :
cross_compile - I did not succeeded
scratchbox - I did not succeeded
So , basically , i have a Chumby hacker board and a ( very smart ) Magnetic Card Reader - I can't make the two to communicate.
The H in HCR331 came from hybrid , cause this reader can also read smart cards , IC and so on - I just need to read magnetic card - this can be accomplished by setting it to MODE 2 - by sending an ESC M2 to it ( done it in Windows/Redhat9 )
I am a n00b , please help me .

Re: how can I build a module for an unrecognized device

I tried to :
cross_compile - I did not succeeded
scratchbox - I did not succeeded

did not succeed in what way? Where did you get an error and what was the error?

3 (edited by Madox 2011-01-25 13:15:01)

Re: how can I build a module for an unrecognized device

How about trying "modprobe usbserial vendor=0x067b product=0x331a"

You shouldn't need to compile a module just because VID/PID don't match if you don't mind the modprobing tongue

Re: how can I build a module for an unrecognized device

@madox : I did that , it did not trow any error , in fact it even add me an /dev/ttyUSB0  ,but I could not communicate with the device

@n6nz : I cross_compile on a debian machine the kernel source ( like here : http://wiki.chumby.com/mediawiki/index. … _Toolchain ) but I ( somehow ) manage to not do something right , because when I copied the pl2303.ko to the chumby device and modprobe pl2303 chumby told me that the module is an incorect version ( a "file pl2303.ko" on the debian machine show an ARM in the begining of the module - but probably I did not choose the right kernel source )

scratchbox - I tried this :http://wiki.chumby.com/mediawiki/index.php/Scratchbox , compiled the same kernel source as above ( ie http://files.chumby.com/toolchain/arm-2 … nu.tar.bz2 ) but I ended up the same way , chumby did not liked the module ( "incorect module version" )

Re: how can I build a module for an unrecognized device

@madox: I was going to suggest that, but I think that only forces the module to load, I don't believe you can force the module to claim the device.  The driver is probably testing for known device id's and refusing the rest. I could be wrong, I'm no USB expert.

@inad: That most definitely is caused by simply compiling the driver against the wrong kernel headers.  I have a driver with exactly the same issue (see my WiFi woes thread).  If you can sort out exactly which set of kernel sources goes with the kernel on your board, you should be good to go.  In fact, if you find out what sources you need, those are probably the ones I need, too, for my CHB V1.

Re: how can I build a module for an unrecognized device

Yup your observation you're probably compiling for a wrong kernel source is probably right...
http://wiki.chumby.com/mediawiki/index. … for_chumby

Re: how can I build a module for an unrecognized device

Ok , I will try again with the other kernel source found on http://files.chumby.com/source/
I don't know wich one do I have to choose , so I'll try all :
http://files.chumby.com/source/falconwi … .mx233.tgz
http://files.chumby.com/source/falconwi … .mx233.tgz
http://files.chumby.com/source/falconwi … .mx233.tgz

( I see a Falconwing reference in boot messages shown on serial terminal , so I'm guessing it's one of those and uname -a it's reporting a 2.6.28 kernel )

8 (edited by Madox 2011-01-25 14:00:08)

Re: how can I build a module for an unrecognized device

Two of those are the same (2370), why not just the latter 2430?

Re: how can I build a module for an unrecognized device

Ok , I'll begin with 2430 big_smile

Re: how can I build a module for an unrecognized device

I get:

chumby-:/ # uname -a
Linux chumby- 2.6.28-chumby #302 PREEMPT Wed Jul 28 14:40:46 PDT 2010 armv5tejl GNU/Linux
chumby-:/ # 

From a CHB V1.  Do you have a Beta or a V1?

11 (edited by inad 2011-01-25 15:15:01)

Re: how can I build a module for an unrecognized device


chumby-:/mnt/storage # uname -a
Linux chumby- 2.6.28-chumby #302 PREEMPT Wed Jul 28 14:40:46 PDT 2010 armv5tejl GNU/Linux

But in this moment i have a spare SD loaded with the firmware posted by bunnie ( http://forum.chumby.com/viewtopic.php?id=5439 )  because I don't want to mess with the original SD that came ( 6 days ago ) in it . And I'm working remotely with it  ( it's connected to my work computer and I'm at home )
I think ( I'll know for sure tommorow ) it is a V1 .

Re: how can I build a module for an unrecognized device

OK, so same build as here.  Your experiment will be very useful to me. The V1 has a different I/O layout, so it's easy to identify.  Yeah, the first thing I did was slap the uSD into a reader and dd the image off to a file -- good insurance.

Re: how can I build a module for an unrecognized device


chumby-:/lib/modules/2.6.28-chumby/kernel/drivers/usb/serial # modprobe pl2303
[33795.440000] pl2303: disagrees about version of symbol struct_module
FATAL: Error inserting pl2303 (/lib/modules/2.6.28-chumby/kernel/drivers/usb/serial/pl2303.ko): Invalid module format

after ARCH=arm CROSS_COMPILE=arm-linux- make on http://files.chumby.com/source/falconwi … .mx233.tgz
( on a debian 5 machine ; wget-ing the pl2303.ko from there to chumby )
So I manage to do something wrong , but I don't know what
It's kinda late here ( likw 2 AM ) , so I'll carry on tomorow .
I'll give it a try with make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- as seen on http://wiki.chumby.com/mediawiki/index. … 1.7_kernel
at Building and installing a new chumby One kernel
but I need to work on it , because right now I'm having something like
debian:~/kernel2/linux-2.6.28.mx233# make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
make: arm-none-linux-gnueabi-gcc: Command not found
  CHK     include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-arm
  CC      kernel/bounds.s
/bin/sh: arm-none-linux-gnueabi-gcc: command not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2

Re: how can I build a module for an unrecognized device

\[33795.440000] pl2303: disagrees about version of symbol struct_module

This is the "Compiled against wrong kernel, thank you for playing." message.

Re: how can I build a module for an unrecognized device

Copy /proc/config.gz from the CHB to your kernel source directory, then uncompress it and rename it to .config .  That's the most reliable way I've found for avoiding the "disagrees about version of symbol" errors.

Re: how can I build a module for an unrecognized device

Hello ChumbyLurker , thank you for you suggestion ; I did that and I issued the following comand

debian:~/kernel2/linux-2.6.28.mx233# ARCH=arm CROSS_COMPILE=arm-linux- make
  CHK     include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-arm
  CALL    scripts/checksyscalls.sh
<stdin>:1097:2: warning: #warning syscall fadvise64 not implemented
<stdin>:1265:2: warning: #warning syscall migrate_pages not implemented
<stdin>:1321:2: warning: #warning syscall pselect6 not implemented
<stdin>:1325:2: warning: #warning syscall ppoll not implemented
<stdin>:1365:2: warning: #warning syscall epoll_pwait not implemented
  CHK     include/linux/compile.h
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/zImage is ready
  Building modules, stage 2.
  MODPOST 162 modules
  LD [M]  drivers/usb/serial/pl2303.ko
debian:~/kernel2/linux-2.6.28.mx233#

and that against falconwing 2430 kernel source

copied the .ko to device, but , again :


chumby-:/lib/modules/2.6.28-chumby/kernel/drivers/usb/serial # modprobe pl2303
[67432.120000] pl2303: disagrees about version of symbol struct_module
FATAL: Error inserting pl2303 (/lib/modules/2.6.28-chumby/kernel/drivers/usb/serial/pl2303.ko): Invalid module format
chumby-:/lib/modules/2.6.28-chumby/kernel/drivers/usb/serial #

17 (edited by inad 2011-01-27 13:33:22)

Re: how can I build a module for an unrecognized device

Problem solved.
Tryed to recompile the kernel ( or just the module I needed - after modified it to add the necessary VID/PID ) but no luck - it seems that I just could not find the right kernel for my device ( CHB beta ) on files.chumby.com/source
Anyhow , the solution from http://www.ha19.no/usb worked just fine
Thank you .
This is my script (ALL INSPIRED FROM THE LINK ABOVE):
rmmod pl2303                             
sleep 1                                   
# "close" the USB ports ( as in /usr/chumby/scripts/reset_usb.sh )
regutil -w HW_PINCTRL_DOUT0_CLR=0x04000000
sleep 1                                   
# load the module wich should work , but who isn't , cause it doesn't know my device's PID
modprobe pl2303                           
sleep 1                                   
# THE line smile  : now we learn the module our device's VID/ PID
# because it's a usb-serial device observe the "usb-serial" , otherwise we should use usb in the line above
echo 067b 331a > /sys/bus/usb-serial/drivers/pl2303/new_id
sleep 2           
# "open" the USB ports :                                       
regutil -w HW_PINCTRL_DOUT0_SET=0x04000000               
sleep 1 
# setting the communication parameters with the device                                                 
stty -F /dev/ttyUSB0 9600 raw cs8

Re: how can I build a module for an unrecognized device

Oh, wow.  That's pure gold.   I didn't realize that there is now a way in Linux to force a USB driver to take a device it won't claim on its own.

That's cool that it solved your problem, and I'm sure it will be handy to others in the future.  Unfortunately, we still need figure out how to reliably compile against the CHB kernel, whatever it may be.

Re: how can I build a module for an unrecognized device

@inad,
Got time to try another compile?
see http://forum.chumby.com/viewtopic.php?id=6065 for a link to what I suspect is the correct source tree.

Re: how can I build a module for an unrecognized device

sorry to necro an old thread but i have the same issue. i am trying to compile the same driver for mirabox and i get:

pl2303: version magic '3.2.36 mod_unload ARMv7 p2v8 ' should be '3.2.36 mod_unload ARMv7 '

what does the p2v8 stand for and how can i get the versions to match? i am using the same kernel versions.

any help would be appreciated.

thanks