【问题标题】:How to build ch341.ko usb-serial driver for android?如何为 android 构建 ch341.ko usb-serial 驱动程序?
【发布时间】:2012-09-03 08:34:22
【问题描述】:

我们需要在我们的 android 设备上安装 ch341.ko 模块。

这是一个可选模块,自 2.4.x(可能是 2.3.x)以来已包含在内核源代码中。

The source is located under (kernel)/drivers/usb/serial/ch341.c

    I endevoured to learn how to build modules, then found it was already in the source so no need for makefiles and the like, then endevoured to find how to crosscompile the linux source with the ch341 option to add it to the device.
  1. 安装交叉编译器 我收集到的第一件事是找到正确的交叉编译器,因此从 adb shell 运行 cat /proc/version yield:

    root@android:/ # cat /proc/version
    Linux 版本 3.0.8+ (android2@Linux) (gcc 版本 4.5.1 (Sourcery G++ Lite 2010.09-50)) #47 PREEMPT Mon Jul 9 16:32:14 CST 2012

    在我的 Fedora 16 机器上下载并设置版本 50 的 Sourcery G++。然后将目录添加到PATH变量中:

    EXPORT PATH=$PATH:(已安装 CodeSourcery 的路径)/CodeSourcery/Sourcery_G++_Lite/bin

    或者手动添加到~/.bash_profile:

    sudo gedit ~/.bash_profile

    然后更新PATH变量:

    来源 ~/.bash_profile

  2. 下载内核源代码 -

    尝试找到正确的来源可能很困难,但是知道该设备最有可能来自 Allwinner 的 A10,我找到了以下 git 存储库和方便的教程:

    https://github.com/amery/linux-allwinner

    http://rhombus-tech.net/allwinner_a10/kernel_compile/

    安装 git 后,克隆树我尝试针对 2 个分支进行编译:

    “allwinner-v3.0-android-v2”(主要)

    “lichee-3.0.8-sun4i”(更适合我的设备)

    我使用以下命令进行了交叉编译:

    使 ARCH=arm sun4i_defconfig 使 ARCH=arm menuconfig 使 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -j16 uImage 模块 make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- INSTALL_MOD_PATH=output modules_install

    每次编译后,我将ch341.ko文件推送到设备:

    adb push output/lib/modules/3.0.8+/kernel/drivers/usb/serial/ch341.ko /mnt/sdcard/LKMz/ch341.ko

    然后尝试了 insmod"

    adb 外壳 root@android:/ # insmod /mnt/sdcard/LKMz/ch341.ko insmod: init_module '/mnt/sdcard/LKMz/ch341.ko' 失败(执行格式错误)

    dmesg 返回:

    dmesg ch341: 不同意符号 module_layout 的版本

    并尝试使用 -f(强制)选项:

    ./system/xbin/busybox insmod -f /mnt/sdcard/LKMz/ch341.ko insmod: 无法插入'/mnt/sdcard/LKMz/ch341.ko': 无效的模块格式

    看来我用来编译源代码的版本或编译选项存在问题。

    有人对如何编译 ch341.ko 模块有任何建议吗?

【问题讨论】:

    标签: android linux kernel


    【解决方案1】:

    关闭 CONFIG_MODVERSIONS 并检查它是否有效。如果没有,“dmesg”并检查新的错误。

    检查this页面,它可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-26
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多