Kernel Module Compilation Howto

Looking for discussion about hardware compatibility? Look no further.
spinningplanet
Posts: 15
youtube meble na wymiar Warszawa
Joined: Wed Nov 02, 2016 11:04 am

Re: Kernel Module Compilation Howto

Post by spinningplanet »

Thanks guys. With your help I got it working. Didn't have to do any cross compiling. Just compiled it on my NAS like this:

Downloaded the kernel source (GPL_linux-3.10.70.tar.bz2) and config (linux-3.10.70-arm.config) from here: https://sourceforge.net/projects/asgpl/ ... 4RF42/arm/
Downloaded the driver source: xr_usb_serial_common_lnx-3.6-and-newer-pak.zip from https://www.exar.com/design-tools/software-drivers
Decompressed files onto NAS at /volume1/home/spinningplanet/asustor/
Renamed linux-3.10.70-arm.config to .config and put in linux-3.10.70 kernel source folder
Ran Make with:

Code: Select all

make oldconfig && make prepare KERNEL_SRC=/volume1/home/spinningplanet/asustor/linux-3.10.70 KERNELDIR=/volume1/home/spinningplanet/asustor/linux-3.10.70
I had to compile the kernel modules to get the xr driver to compile:

Code: Select all

make modules KERNEL_SRC=/volume1/home/spinningplanet/asustor/linux-3.10.70 KERNELDIR=/volume1/home/spinningplanet/asustor/linux-3.10.70
Changed to xr_usb_serial_common_lnx-3.6-and-newer-pak folder and ran:

Code: Select all

make KERNEL_SRC=/volume1/home/spinningplanet/asustor/linux-3.10.70 KERNELDIR=/volume1/home/spinningplanet/asustor/linux-3.10.70
It created xr_usb_serial_common.ko which I was able to load.

Again. Thanks heaps for your help. No way I wold have worked it out by myself.

brynn :-)
spinningplanet
Posts: 15
Joined: Wed Nov 02, 2016 11:04 am

Re: Kernel Module Compilation Howto

Post by spinningplanet »

I've upgraded my AS1002T to an AS604T and have compiled a xr_usb_serial_common.ko driver for it which loads fine but I have this issue. I need to unload /dev/ttyACM0 but when I "rmmod cdc-acm" nothing happens and /dev/ttyACM0 remains. Is there something unique to the AS604T that stops the ability to unload cdc-acm? I can unload it on my AS1002T then I'm able to access /dev/ttyXRUSB0.
User avatar
father.mande
Posts: 1817
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: Kernel Module Compilation Howto

Post by father.mande »

Hi,
spinningplanet wrote:I've upgraded my AS1002T to an AS604T and have compiled a xr_usb_serial_common.ko driver for it which loads fine but I have this issue. I need to unload /dev/ttyACM0 but when I "rmmod cdc-acm" nothing happens and /dev/ttyACM0 remains. Is there something unique to the AS604T that stops the ability to unload cdc-acm? I can unload it on my AS1002T then I'm able to access /dev/ttyXRUSB0.
A device can stay define after an rmmod
... is lsmod always show the module after rmmod ?

If yes :
... use first lsof (available in Entware APKG) to verify if some program use the /dev/ttyxxxx
... also try fuser (provide by asustor)
ex. for a random device

Code: Select all

 # fuser /dev/dri/card0
5999
 # ps -eaf | grep " 5999 "
root      1182   628  0 12:19 pts/1    00:00:00 grep  5999
root      5999  5995  0 Feb07 tty2     00:05:02 /usr/local/AppCentral/xorg/usr/bin/X :0 -config /usr/local/AppCentral/xorg/xorg.conf
... in this case try to kill it (if possible)
if no :
... normally just removing (rm) the dev is enough to clear the situation
... this can appear if the hotplug mechanism or udev is not complete or not configured as well

BUT in fact why removing the dev ... if the rmmod release the module ... it's not important ?

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
spinningplanet
Posts: 15
Joined: Wed Nov 02, 2016 11:04 am

Re: Kernel Module Compilation Howto

Post by spinningplanet »

Hi Phillipe!

When I do "lsof /dev/ttyACM0" nothing shows.
After running "rmmod cdc-acm" /dev/ttyACM0 still remains

So, I unplug the cable and plug it back in and this is what dmesg shows:

Code: Select all

new full-speed USB device number 11 using xhci_hcd
New USB device found, idVendor=04e2, idProduct=1411
New USB device strings: Mfr=1, Product=2, SerialNumber=3
Product: XR21B1411
Manufacturer: Exar Corp.
SerialNumber: G5631476441
cdc_acm 1-2.1:1.0: ttyACM0: USB ACM device
Then I run:

Code: Select all

rmmod cdc-acm
modprobe -r usbserial
insmod /volume1/home/spinningplanet/asustor/xr_usb_serial_common.ko
and this is what dmesg shows:

Code: Select all

[usbcore: registered new interface driver cdc_xr_usb_serial
xr_usb_serial_common: Exar USB UART (serial port) driver
The problem still remains. /dev/ttyACM0 hasn't been removed and replaced with /dev/ttyXRUSB0
User avatar
father.mande
Posts: 1817
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

Re: Kernel Module Compilation Howto

Post by father.mande »

Hi,

In fact not sure I have answer to the real question ...

Your problem is that cdc-acm generate a device name (dmesg trace) that are not the name you want ?
... so seem that cdc-acm module source used is not the correct one ... generating a name correct but not your need

Or you can get a compatible source code ... to generate the good device name, or you change in the existing code
Another way is to try to link correct name to the generated name or create a new device with the good name and the same MAJOR / MINOR use by ttyACM0

If it works ... you can I think add the creation of the device in the script launching your application (and destroy it after)

Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
Jhinta
Posts: 39
Joined: Tue May 19, 2015 11:43 pm

Re: Kernel Module Compilation Howto

Post by Jhinta »

rmmod cdc-acm dmesg?
spinningplanet
Posts: 15
Joined: Wed Nov 02, 2016 11:04 am

Re: Kernel Module Compilation Howto

Post by spinningplanet »

Hi Jhinta!

When I rmmod cdc-acm absolutely nothing happens. Nothing shows as changed in dmesg.

When I lsmod the correct driver is showing (xr_usb_serial_common 36864 0 - Live 0xffffffffa03ac000 (O)) but there is no cdc_acm module. Here's what I can see when I lsmod | grep usb:

Code: Select all

xr_usb_serial_common 36864 0 - Live 0xffffffffa03ac000 (O)
snd_usb_audio 147456 0 - Live 0xffffffffa037d000
snd_usbmidi_lib 28672 1 snd_usb_audio, Live 0xffffffffa0375000
snd_rawmidi 28672 2 snd_seq_midi,snd_usbmidi_lib, Live 0xffffffffa036d000
usbip_host 20480 0 - Live 0xffffffffa00ef000
usbip_core 16384 1 usbip_host, Live 0xffffffffa00d1000
snd_hwdep 16384 2 snd_usb_audio,snd_hda_codec, Live 0xffffffffa0057000
snd_pcm 94208 5 snd_usb_audio,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_controller,snd_hda_codec, Live 0xffffffffa01fe000
snd 65536 13 snd_usb_audio,snd_usbmidi_lib,snd_rawmidi,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek,snd_hda_codec_generic,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer, Live 0xffffffffa01e5000
Could it be loading the correct driver (xr_usb_serial_common) but getting confused and think it needs to be using cdc_acm? I try to run my pointing at /dev/ttyACM0 but it just times out.

Or, could the cdc_acm be inside another module?

I've compiled the latest Exar driver from here: https://www.exar.com/content/document.ashx?id=21651

brynn :-)
spinningplanet
Posts: 15
Joined: Wed Nov 02, 2016 11:04 am

Re: Kernel Module Compilation Howto

Post by spinningplanet »

I thought I could try blacklisting cdc_acm but there is no /etc/modprobe.d folder. Anyone know how to blacklist a module on Asustor?
Post Reply

Return to “Hardware Compatibility”