LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-15-2010, 04:06 PM   #1
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
Exclamation Problem inserting a USB serial modem kernel module


(Questions scattered throughout this post are highlighted in bold text)

Hi everyone, I'm a long time Linux user and user space developer with very little kernel development experience. At my current contract job I'm developing some software for a new CDMA modem and I'm having some issues with it. Unfortunately the circumstances surrounding the developers of this driver is complicated, but for brevity I'll just say that I do not have contact with anyone who knows anything about this driver, or about Linux driver development in general.


Our target system for this driver is a Busy Box distribution running a 2.6.27 kernel on an embedded system with an ARM9 CPU. This driver was built for x86 Ubuntu and a 2.6.32 kernel but has been backported to our system. The driver works fine on Ubuntu. The driver itself is for a CDMA modem over a USB serial connection.


The problem occurs when I try to install the module. It compiles fine without any warnings. Here's what gets printed when I attempt to insmod the kernel:

Code:
Atlas-Telemetry:/root# insmod FWUSBModem.ko
------------[ cut here ]------------
WARNING: at fs/sysfs/dir.c:463 sysfs_add_one+0x34/0x48()
sysfs: duplicate filename 'usb-serial' can not be created
Modules linked in: FWUSBModem(+) HAL_T(P)
[<c0312818>] (dump_stack+0x0/0x14) from [<c0041b08>] (warn_slowpath+0x5c/0x94)
[<c0041aac>] (warn_slowpath+0x0/0x94) from [<c00d79a8>] (sysfs_add_one+0x34/0x48)
 r3:c3ab8d60 r2:c03af1b4
 r6:c3ba69a8 r5:c3a1bbbc r4:ffffffef
[<c00d7974>] (sysfs_add_one+0x0/0x48) from [<c00d80ac>] (create_dir+0x58/0xac)
 r5:c3a1bbbc r4:c2417e30
[<c00d8054>] (create_dir+0x0/0xac) from [<c00d8138>] (sysfs_create_dir+0x38/0x4c)
 r8:c380a9e8 r7:c3ba69a8 r6:00000000 r5:c3ba69a8 r4:c3ba69a8
[<c00d8100>] (sysfs_create_dir+0x0/0x4c) from [<c013da64>] (kobject_add_internal+0xf0/0x1c4)
 r4:c3ba69a8
[<c013d974>] (kobject_add_internal+0x0/0x1c4) from [<c013db60>] (kset_register+0x28/0x44)
 r8:c0025ec4 r7:c3ba69a8 r6:00000000 r5:c3ba69a8 r4:c3ba69a0
[<c013db38>] (kset_register+0x0/0x44) from [<c016e7ec>] (bus_register+0x90/0x230)
 r5:bf00cf3c r4:c3ba69a0
[<c016e75c>] (bus_register+0x0/0x230) from [<bf00f04c>] (usb_serial_init+0x4c/0x20c [FWUSBModem])
 r8:c0025ec4 r7:bf00f20c r6:bf00d440 r5:00000000 r4:0000cb82
[<bf00f000>] (usb_serial_init+0x0/0x20c [FWUSBModem]) from [<bf00f21c>] (__viausbmodem_init+0x10/0x78 [FWUSBModem])
 r7:bf00f20c r6:000e4038 r5:bf00d300 r4:0000cb82
[<bf00f20c>] (__viausbmodem_init+0x0/0x78 [FWUSBModem]) from [<c00252d0>] (__exception_text_end+0x50/0x17c)
 r4:0000cb82
[<c0025280>] (__exception_text_end+0x0/0x17c) from [<c00661c4>] (sys_init_module+0x98/0x184)
[<c006612c>] (sys_init_module+0x0/0x184) from [<c0025d20>] (ret_fast_syscall+0x0/0x2c)
 r7:00000080 r6:00000069 r5:00000000 r4:00000000
---[ end trace 82e73782338028ba ]---
kobject_add_internal failed for usb-serial with -EEXIST, don't try to register things with the same name in the same directory.
[<c0312818>] (dump_stack+0x0/0x14) from [<c013db08>] (kobject_add_internal+0x194/0x1c4)
[<c013d974>] (kobject_add_internal+0x0/0x1c4) from [<c013db60>] (kset_register+0x28/0x44)
 r8:c0025ec4 r7:c3ba69a8 r6:00000000 r5:c3ba69a8 r4:c3ba69a0
[<c013db38>] (kset_register+0x0/0x44) from [<c016e7ec>] (bus_register+0x90/0x230)
 r5:bf00cf3c r4:c3ba69a0
[<c016e75c>] (bus_register+0x0/0x230) from [<bf00f04c>] (usb_serial_init+0x4c/0x20c [FWUSBModem])
 r8:c0025ec4 r7:bf00f20c r6:bf00d440 r5:00000000 r4:0000cb82
[<bf00f000>] (usb_serial_init+0x0/0x20c [FWUSBModem]) from [<bf00f21c>] (__viausbmodem_init+0x10/0x78 [FWUSBModem])
 r7:bf00f20c r6:000e4038 r5:bf00d300 r4:0000cb82
[<bf00f20c>] (__viausbmodem_init+0x0/0x78 [FWUSBModem]) from [<c00252d0>] (__exception_text_end+0x50/0x17c)
 r4:0000cb82
[<c0025280>] (__exception_text_end+0x0/0x17c) from [<c00661c4>] (sys_init_module+0x98/0x184)
[<c006612c>] (sys_init_module+0x0/0x184) from [<c0025d20>] (ret_fast_syscall+0x0/0x2c)
 r7:00000080 r6:00000069 r5:00000000 r4:00000000
FWUSBModem: usb_serial_init - registering bus driver failed
FWUSBModem: usb_serial_init - returning with error -17
sys_init_module: 'FWUSBModem'->init suspiciously returned 1, it should follow 0/-E convention
sys_init_module: loading module anyway...
[<c0312818>] (dump_stack+0x0/0x14) from [<c0066244>] (sys_init_module+0x118/0x184)
[<c006612c>] (sys_init_module+0x0/0x184) from [<c0025d20>] (ret_fast_syscall+0x0/0x2c)
 r7:00000080 r6:00000069 r5:00000000 r4:00000000
Despite all of these various errors and warnings, it did manage to get the driver to actually load. I haven't tried to do anything with it because I was pretty confident it wouldn't work. The only thing I tried to do was remove it, which produced additional errors and a segmentation fault.

Code:
Atlas-Telemetry:/root# lsmod
FWUSBModem 39028 0 - Live 0xbf004000
HAL_T 12248 2 - Live 0xbf000000 (P)

Atlas-Telemetry:/root# rmmod FWUSBModem
usbcore: deregistering interface driver option
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c2500000
[00000000] *pgd=82509031, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1] PREEMPT
Modules linked in: FWUSBModem(-) HAL_T(P)
CPU: 0    Tainted: P        W  (2.6.27.8_T1 #1)
PC is at usb_deregister+0x68/0xec
LR is at schedule+0x2cc/0x34c
pc : [<c01a4bec>]    lr : [<c0312ca0>]    psr: 20000013
sp : c252bf04  ip : 00000000  fp : c252bf24
r10: 00000000  r9 : c252a000  r8 : 00100100
r7 : c040fbf4  r6 : bf00d0a8  r5 : bf00d300  r4 : bf00d0d0
r3 : 00000001  r2 : c252a000  r1 : 00000000  r0 : 00000032
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 0005317f  Table: 82500000  DAC: 00000015
Process rmmod (pid: 759, stack limit = 0xc252a260)
Stack: (0xc252bf04 to 0xc252c000)
bf00:          00000000 bf00d300 00000880 c040fbf4 c252bf38 c252bf34 c252bf28
bf20: bf008e40 c01a4b94 c252bfa4 c252bf38 c0064a44 bf008e3c 53555746 646f4d42
bf40: c0006d65 c0437394 c252bf80 c252bf58 c0047508 c00473c8 c0410024 00000010
bf60: 00000000 00000001 00000000 c252a000 00f31b7d bf00d300 00000880 c252bf80
bf80: 00000000 000dc008 00000000 bed9df64 00000081 c0025ec4 00000000 c252bfa8
bfa0: c0025d20 c0064854 000dc008 00000000 bed9df64 00000880 00000000 000e4578
bfc0: 000dc008 00000000 bed9df64 00000000 00000001 00000002 00000000 bed9de94
bfe0: 40196ad0 bed9dc18 0001f8ac 40196ad4 60000010 bed9df64 ffffbfff 7ff7fdff
Backtrace:
[<c01a4b84>] (usb_deregister+0x0/0xec) from [<bf008e40>] (__viausbmodem_exit+0x14/0x2c [FWUSBModem])
 r8:c252bf38 r7:c040fbf4 r6:00000880 r5:bf00d300 r4:00000000
[<bf008e2c>] (__viausbmodem_exit+0x0/0x2c [FWUSBModem]) from [<c0064a44>] (sys_delete_module+0x200/0x278)
[<c0064844>] (sys_delete_module+0x0/0x278) from [<c0025d20>] (ret_fast_syscall+0x0/0x2c)
 r8:c0025ec4 r7:00000081 r6:bed9df64 r5:00000000 r4:000dc008
Code: e5823004 e1a04006 e5b41028 e59f8078 (e5915000)
---[ end trace 82e73782338028ba ]---
note: rmmod[759] exited with preempt_count 1
BUG: scheduling while atomic: rmmod/759/0x40000002
Modules linked in: FWUSBModem(-) HAL_T(P)
[<c0312818>] (dump_stack+0x0/0x14) from [<c003cca0>] (__schedule_bug+0x50/0x5c)
[<c003cc50>] (__schedule_bug+0x0/0x5c) from [<c0312a4c>] (schedule+0x78/0x34c)
 r4:c252a000
[<c03129d4>] (schedule+0x0/0x34c) from [<c003cd5c>] (__cond_resched+0x24/0x40)
[<c003cd38>] (__cond_resched+0x0/0x40) from [<c0312e18>] (_cond_resched+0x40/0x54)
 r4:00000001
[<c0312dd8>] (_cond_resched+0x0/0x54) from [<c007c868>] (unmap_vmas+0x4fc/0x5cc)
 r4:c045bf60
[<c007c36c>] (unmap_vmas+0x0/0x5cc) from [<c007ec70>] (exit_mmap+0x80/0x13c)
[<c007ebf0>] (exit_mmap+0x0/0x13c) from [<c003fb38>] (mmput+0x40/0x100)
 r6:c24ef340 r5:00000000 r4:c3b34360
[<c003faf8>] (mmput+0x0/0x100) from [<c004388c>] (exit_mm+0x124/0x12c)
 r5:c3b34360 r4:c252a000
[<c0043768>] (exit_mm+0x0/0x12c) from [<c0045470>] (do_exit+0x1b4/0x7f4)
 r7:00000000 r6:c01a4bf0 r5:c24ef340 r4:0000000b
[<c00452bc>] (do_exit+0x0/0x7f4) from [<c0029edc>] (die+0x2d8/0x334)
[<c0029c04>] (die+0x0/0x334) from [<c002b300>] (__do_kernel_fault+0x6c/0x7c)
[<c002b294>] (__do_kernel_fault+0x0/0x7c) from [<c002b550>] (do_page_fault+0x240/0x25c)
 r7:00000000 r6:c040bf1c r5:c24ef340 r4:c040beac
[<c002b310>] (do_page_fault+0x0/0x25c) from [<c0025220>] (do_DataAbort+0x38/0x98)
[<c00251e8>] (do_DataAbort+0x0/0x98) from [<c0025860>] (__dabt_svc+0x40/0x60)
Exception stack(0xc252bebc to 0xc252bf04)
bea0:                                                                00000032
bec0: 00000000 c252a000 00000001 bf00d0d0 bf00d300 bf00d0a8 c040fbf4 00100100
bee0: c252a000 00000000 c252bf24 00000000 c252bf04 c0312ca0 c01a4bec 20000013
bf00: ffffffff
[<c01a4b84>] (usb_deregister+0x0/0xec) from [<bf008e40>] (__viausbmodem_exit+0x14/0x2c [FWUSBModem])
 r8:c252bf38 r7:c040fbf4 r6:00000880 r5:bf00d300 r4:00000000
[<bf008e2c>] (__viausbmodem_exit+0x0/0x2c [FWUSBModem]) from [<c0064a44>] (sys_delete_module+0x200/0x278)
[<c0064844>] (sys_delete_module+0x0/0x278) from [<c0025d20>] (ret_fast_syscall+0x0/0x2c)
 r8:c0025ec4 r7:00000081 r6:bed9df64 r5:00000000 r4:000dc008
Segmentation fault
The messages that insmod prints lead me to believe that the driver is trying to create usb-serial files that already exist on the system from the kernel's own usb-serial code. I've taken a look at the code for this driver and it appears that the majority of it was simply files copied directly from the Linux kernel source. This includes files such as usb-serial.c, generic.c, bus.c, console.c, which can be found in drivers/usb/core/ and drivers/usb/serial/ in the Linux source tree.

Question 1: Is it a common practice to copy and/or modify existing files from the Linux source in creating a driver, rather than just including/linked the existing files?

Question 2: Am I on the right track in believing that the problem has something to do with the driver code conflicting with the (usb-serial) kernel code and existing files?

But do recall that Ubuntu experiences no problems with this driver and none of the source files included in the driver are removed or extensively modified. So I'm not confident in my hypothesis that the driver code is conflicting with the kernel code.

Another key factor I noticed was in the kernel module's makefile. The install target copies the compiled module to the directory /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/, but on our BusyBox system this location does not exist. The closest we can get is
/lib/modules/$(shell uname -r)/kernel/drivers, and the only subdirectory in that location is scsi. So I'm wondering if its possible that our driver does not have the necessary USB components installed. On my Ubuntu system there are about 30 kernel modules installed in the usb/serial/ directory and many other subdirectories under drivers/. Or perhaps there's another location where BusyBox prefers to keep kernel modules installed (I don't think this is the case though).

Question 3: Based on the above information, do you think its possible that this error is ultimately the cause of not having the proper support compiled into our BusyBox kernel?

I haven't taken a look at the kernel build configuration yet myself, but my co-workers said that they didn't think it was as minimal as I believed it to be.


-----


I'm not expecting someone to solve this problem for me, but I was hoping to get some leads from the community here so I could get closer to finding a solution on my own. If you are able to answer the questions I asked above, or to point out something important about the errors that I missed, that would help me greatly. Thank you for taking the time to read this.
 
Old 12-16-2010, 12:21 PM   #2
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Original Poster
Rep: Reputation: 30
One of our guys figured out that it was conflicting with the USB-ACM part of the kernel. Once we made a new kernel without that support enabled, the driver loaded just fine. Its not really an ideal solution for us to remove that feature from our kernel though, and it still makes no sense why it would work on Ubuntu, which I assume would have that feature enabled?
 
Old 12-17-2010, 09:21 AM   #3
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,657
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Hi, some distros promote multimedia more than others,

and configure the kernel for such tasks, like video for linux two (v4l2).

Watch out for the usb3 features that are coming in new kernels,

it may cause problems.

Always make oldconfig to be sure. (it's still a bit dodgy)

Cheers Glenn
 
  


Reply

Tags
kernel module, usb serial



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
issues in inserting kernel module sathishkumarr Linux - Kernel 2 05-10-2007 09:57 AM
kernel panics after inserting the module. raklo Linux - Kernel 4 02-19-2007 12:01 AM
Inserting module in the kernel nitinbaldi Linux - Kernel 2 02-17-2007 10:33 PM
info on inserting a new module to existing kernel aus9 Linux - Kernel 1 09-18-2006 01:33 AM
Problem inserting a new module to kernel hetzme Programming 2 07-18-2005 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration