简体   繁体   English

如何为Android构建ch341.ko USB串行驱动程序?

[英]How to build ch341.ko usb-serial driver for android?

we require the ch341.ko module on our android device. 我们需要我们的android设备上的ch341.ko模块。

This is an optional module that has been included in the kernel source since 2.4.x (maybe 2.3.x). 这是自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. Install the crosscompiler I gathered the first thing was to locate the correct cross compiler, so running cat /proc/version on from the adb shell yeilded: 安装我收集的交叉编译器,第一件事是找到正确的交叉编译器,因此从yeilded的adb shell上运行cat /proc/version

    root@android:/ # cat /proc/version root @ android:/#cat / proc / version
    Linux version 3.0.8+ (android2@Linux) (gcc version 4.5.1 (Sourcery G++ Lite 2010.09-50) ) #47 PREEMPT Mon Jul 9 16:32:14 CST 2012 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

    Downloaded and setup Sourcery G++ on version 50 on my Fedora 16 box. 在我的Fedora 16盒子上下载并设置了Sourcery G ++的版本50。 Then added the directory of to the PATH variable: 然后将的目录添加到PATH变量中:

    EXPORT PATH=$PATH:(Path to installed CodeSourcery)/CodeSourcery/Sourcery_G++_Lite/bin 导出路径= $ PATH :(已安装CodeSourcery的路径)/ CodeSourcery / Sourcery_G ++ _ Lite / bin

    or manually add it in ~/.bash_profile: 或手动将其添加到〜/ .bash_profile中:

    sudo gedit ~/.bash_profile 须藤gedit〜/ .bash_profile

    Then update the PATH variable: 然后更新PATH变量:

    source ~/.bash_profile 来源〜/ .bash_profile

  2. Download the Kernel Source - 下载内核源-

    Trying to find the correct source can prove difficult, however knowing the device was an A10 most likely from Allwinner, I found the following git repository and also handy tutorial: 试图找到正确的来源可能很困难,但是,从Allwinner知道该设备很可能是A10时,我发现了以下git信息库和便捷的教程:

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

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

    After installing git, cloning the tree I tried compiling against 2 branches: 安装git后,克隆了我尝试针对2个分支进行编译的树:

    "allwinner-v3.0-android-v2" (The main one) “ allwinner-v3.0-android-v2”(主要的一个)

    "lichee-3.0.8-sun4i" (Which is more inline with my device) “ lichee-3.0.8-sun4i”(与我的设备更内联)

    I cross-compiled with the following commands: 我交叉编译了以下命令:

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

    After each compilation, I pushed the ch341.ko file to the device: 每次编译后,我将ch341.ko文件推送到设备:

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

    Then tried insmod" 然后尝试了insmod”

    adb shell root@android:/ # insmod /mnt/sdcard/LKMz/ch341.ko insmod: init_module '/mnt/sdcard/LKMz/ch341.ko' failed (Exec format error) adb shell root @ android:/#insmod /mnt/sdcard/LKMz/ch341.ko insmod:init_module'/mnt/sdcard/LKMz/ch341.ko'失败(执行格式错误)

    dmesg returned: dmesg返回:

    dmesg ch341: disagrees about version of symbol module_layout dmesg ch341:关于符号module_layout的版本存在异议

    And trying with the -f (force) option: 并尝试使用-f(强制)选项:

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

    So it appears that there is an issue with the version or the compile options I'm using to compile the source with. 因此看来,我用来编译源代码的版本或编译选项存在问题。

    Does anybody have any suggestions on how to compile the ch341.ko module? 有人对如何编译ch341.ko模块有任何建议吗?

turn off the CONFIG_MODVERSIONS and check if it works. 关闭CONFIG_MODVERSIONS并检查其是否有效。 If not, "dmesg" and check new errors. 如果不是,请“ dmesg”并检查新错误。

check this page, it may helps. 检查页面,可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM