New filters on the Home Feed, take a look!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

0
Linux USB Driver: "Unknown symbol in module" on insmod
Post Flair (click to view more posts with a particular flair)
Post Body

EDIT: Issue is resolved! I added MODULE_LICENSE("GPL"); to my code, and now it works!

Hello everyone!

I'm currently learning how to create USB drivers for Linux, and I absolutely love it so far! However, I've come across an issue when trying to insert my .ko file. I keep receiving the following error: "Unknown symbol in module".

Below, you will find my code. What is weird is if I comment out the code in my __init function, the module loads just fine, however after going through my code, and comparing it to other USB driver code, I am unable to locate any issues. Could you please help me out? Thanks so much for your help. Also, here is what error messages appear in dmesg: ""Unknown symbol usb_register_driver (err 0) and Unknown symbol usb_deregister (err 0)"

struct xb1_controller {
    struct usb_device *udev;
    struct usb_interface *interface;
    unsigned char minor;

    char *int_in_buffer;
    struct usb_endpoint_descriptor *endpoint;
    struct urb *int_in_urb;
};

static struct usb_device_id xb1_table [] = {
    {USB_DEVICE(xb1_vendor_id, xb1_product_id) },
    {}
};

MODULE_DEVICE_TABLE(usb, xb1_table);

static int xb1_open(struct inode *inode, struct file *file) {
    //Sys call
}

static int xb1_release(struct inode *inode, struct file *file) {
    //Sys call
}

static ssize_t xb1_read(struct file *file, const char __user *user_buf,    
size_t count, loff_t *ppos) {
    //Sys call
}

static struct file_operations xb1_fops = {
    .owner = THIS_MODULE,
    .open = xb1_open,
    .release = xb1_release,
    .read = xb1_read,
};

static struct usb_class_driver xb1_class = {
    .name = "xb1driver",
    .fops = &xb1_fops,
    .minor_base = MINOR_BASE,
};

static int xb1_probe(struct usb_interface *interface, const struct  
usb_device_id *id) {
    printk(KERN_INFO "xb1driver probe function called");
}

static void xb1_disconnect(struct usb_interface *interface) {
    printk(KERN_INFO "xb1driver disconnect function called");
}

static struct usb_driver xb1_driver = {
    .name = "xb1driver",
    .id_table = xb1_table,
    .probe = xb1_probe,
    .disconnect = xb1_disconnect,
};

static int __init xb1_init(void) {
    int result;

    result = usb_register(&xb1_driver);

    if(result) {
        printk(KERN_INFO "usb_register has failed..");
        return 5;
    }

    return result;
}

static void __exit xb1_exit(void) {
    usb_deregister(&xb1_driver);
}

module_init(xb1_init);
module_exit(xb1_exit);

Author
Account Strength
80%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
398
Link Karma
165
Comment Karma
233
Profile updated: 3 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago