You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ubuntu 17.10上编译qmi_wwan驱动?仅编译相关源文件方法

Hey there! Let's walk through compiling your modified qmi_wwan driver for your 4G LTE MIFI on Ubuntu 17.10, including the crucial part of building only the relevant source files instead of the entire kernel—no need to waste time on unnecessary builds.

Compiling Modified qmi_wwan Driver on Ubuntu 17.10

1. Set Up the Compilation Environment

First, you need all the tools and matching kernel headers to build kernel modules. The headers are non-negotiable because your driver has to align exactly with the kernel you’re running. Run this command to install everything:

sudo apt update && sudo apt install build-essential linux-headers-$(uname -r) git

The $(uname -r) part automatically grabs your current kernel version, so you don’t have to look it up manually.

2. Get the Relevant Kernel Source Files

You don’t need the entire kernel source tree, but grabbing the specific directory for USB network drivers will make things easier. Ubuntu 17.10 uses the 4.13.x kernel series, so clone the matching Ubuntu kernel repo:

# Replace "xx" with the minor version from your kernel (check with uname -r)
git clone --depth 1 -b ubuntu-4.13.0-xx-generic git://kernel.ubuntu.com/ubuntu/ubuntu-artful.git

Once cloned, navigate to the directory where qmi_wwan lives:

cd ubuntu-artful/drivers/net/usb/

Now replace the original qmi_wwan.c (and any modified header files, if you changed those) with your custom version.

3. Compile Only the qmi_wwan Module (Skip Full Kernel Build)

This is the part you care about—building just your modified driver, not the whole kernel. Run this command from the usb/ directory:

make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

Let me break that down:

  • -C /lib/modules/$(uname -r)/build: Points to your kernel’s build/headers directory
  • M=$(pwd): Tells the kernel Makefile to focus on the current directory’s files
  • modules: The target to generate kernel module files

When it finishes, you’ll see a qmi_wwan.ko file in the directory—that’s your compiled driver.

4. Test the Modified Driver

Before making it permanent, test if it works with your MIFI:

  1. Unload the existing qmi_wwan module (if it’s loaded):
    sudo rmmod qmi_wwan
    
  2. Load your custom module:
    sudo insmod qmi_wwan.ko
    
  3. Verify it loaded correctly and detected your device:
    • Check loaded modules: lsmod | grep qmi_wwan
    • Check kernel logs for device recognition: dmesg | tail -20
      Look for lines like qmi_wwan 1-2:1.0: cdc-wdm0: USB WDM device or references to your MIFI model—those mean success.

5. Optional: Make the Driver Persistent (After Successful Testing)

If everything works, replace the system’s default qmi_wwan module so it loads automatically on boot:

sudo cp qmi_wwan.ko /lib/modules/$(uname -r)/kernel/drivers/net/usb/
sudo depmod -a

Quick Notes

  • Double-check that your kernel headers match your running kernel—if they don’t, the module will fail to load.
  • If you modified any header files (not just qmi_wwan.c), make sure those are placed in the correct include directories before compiling.
  • If you hit compile errors, read the output carefully—most issues are missing dependencies or syntax tweaks in your modified code.

内容的提问来源于stack exchange,提问作者artificerpi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:32:27