Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insmod: ERROR: could not insert module ch34x.ko: Invalid module format #3

Open
satech-domo opened this issue Oct 22, 2016 · 21 comments

Comments

@satech-domo
Copy link

Raspberry pi3 with NOOBS Debian installed 2016 oct 19
did a reboot,
show "ch341 4932 0 at lsmod,
show "ch341.ko" at ls /lib/modules/$(uname -r)/kernel/drivers/usb/serial
nothing at sudo depmod -a

previously installed libusb-1.0.0-dev, mochad-0.1.15, usbutils
but got at command $ Isusb
bash: Isusb: command not found

Salutations

here the terminal output for ch34x

_> pi@raspberrypi:~ $ sudo insmod ch34x.ko

insmod: ERROR: could not insert module ch34x.ko: Invalid module format
pi@raspberrypi:~ $ lsmod
Module Size Used by
bnep 10340 2
hci_uart 17943 1
btbcm 5929 1 hci_uart
bluetooth 326105 22 bnep,btbcm,hci_uart
brcmfmac 186339 0
brcmutil 5661 1 brcmfmac
joydev 9024 0
evdev 11396 6
sg 18319 0
cfg80211 427855 1 brcmfmac
snd_bcm2835 20447 1
rfkill 16037 4 cfg80211,bluetooth
snd_pcm 75762 1 snd_bcm2835
snd_timer 19288 1 snd_pcm
snd 51908 5 snd_bcm2835,snd_timer,snd_pcm
spi_bcm2835 6678 0
bcm2835_gpiomem 3040 0
i2c_bcm2708 4834 0
bcm2835_wdt 3225 0
ch341 4932 0
usbserial 22115 1 ch341
w1_gpio 3657 0
wire 25219 1 w1_gpio
cn 4374 1 wire
uio_pdrv_genirq 3164 0
uio 8000 1 uio_pdrv_genirq
i2c_dev 5859 0
fuse 83653 3
ipv6 347466 52
pi@raspberrypi:~ $ ls /lib/modules/$(uname -r)/kernel/drivers/usb/serial
aircable.ko io_edgeport.ko mos7720.ko sierra.ko
ark3116.ko io_ti.ko mos7840.ko spcp8x5.ko
belkin_sa.ko ipaq.ko navman.ko ssu100.ko
ch341.ko ipw.ko omninet.ko symbolserial.k_

_

@giova-fr
Copy link

same problem here

@t2ac32
Copy link

t2ac32 commented Jan 27, 2017

same problem raspberry pi 3

@jdieg0
Copy link

jdieg0 commented Feb 10, 2017

Same error on my Raspberry Pi 2 with Raspbian Jessie.

@marcosavini
Copy link

Unfortunately, same here. RPI3

@peterchylewski
Copy link

same here raspberry 2 jessie

@a1rb4Ck
Copy link

a1rb4Ck commented Jul 31, 2017

For recent kernel, you need to compile from source this specifically fixed driver: https://github.com/skyrocknroll/CH341SER_LINUX.
First, update to the last kernel and prepare the env. Then, download, make and insert this CH341SER. It worked well on my RPi3, thanks to @aperepel and @skyrocknroll great works.

@AlexandreToledo
Copy link

  1. download
    pi@raspberrypi:~ $ wget https://github.com/aperepel/raspberrypi-ch340-driver/releases/download/4.4.11-v7/ch34x.ko

  2. check
    pi@raspberrypi:~ $ lsmod
    Module Size Used by
    bnep 12051 2
    hci_uart 20020 1
    btbcm 7916 1 hci_uart
    bluetooth 365511 22 hci_uart,bnep,btbcm
    brcmfmac 222874 0
    brcmutil 9092 1 brcmfmac
    cfg80211 543027 1 brcmfmac
    rfkill 20851 4 bluetooth,cfg80211
    snd_bcm2835 24427 1
    snd_pcm 98501 1 snd_bcm2835
    snd_timer 23968 1 snd_pcm
    snd 70032 5 snd_timer,snd_bcm2835,snd_pcm
    bcm2835_gpiomem 3940 0
    evdev 12423 6
    joydev 9988 0
    uio_pdrv_genirq 3923 0
    uio 10204 1 uio_pdrv_genirq
    fixed 3285 0
    i2c_dev 6913 0
    fuse 99603 3
    ipv6 408971 70

  3. go towards
    pi@raspberrypi:~ $ cd /lib/modules/$(uname -r)/kernel/drivers/usb/serial

  4. Install first
    pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ sudo insmod usbserial.ko

  5. Check once again
    pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ lsmod
    Module Size Used by
    usbserial 29943 0 <===== Need be installed FIRST
    bnep 12051 2
    hci_uart 20020 1
    btbcm 7916 1 hci_uart
    bluetooth 365511 22 hci_uart,bnep,btbcm
    brcmfmac 222874 0
    brcmutil 9092 1 brcmfmac
    cfg80211 543027 1 brcmfmac
    rfkill 20851 4 bluetooth,cfg80211
    snd_bcm2835 24427 1
    snd_pcm 98501 1 snd_bcm2835
    snd_timer 23968 1 snd_pcm
    snd 70032 5 snd_timer,snd_bcm2835,snd_pcm
    bcm2835_gpiomem 3940 0
    evdev 12423 6
    joydev 9988 0
    uio_pdrv_genirq 3923 0
    uio 10204 1 uio_pdrv_genirq
    fixed 3285 0
    i2c_dev 6913 0
    fuse 99603 3
    ipv6 408971 68

  6. NOW, install ch341.ko
    pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ sudo insmod ch341.ko

  7. Voilá !!!
    pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ lsmod
    Module Size Used by
    ch341 6086 0 <==== Must be here first
    usbserial 29943 1 ch341 <==== Can you see me now ?
    bnep 12051 2
    hci_uart 20020 1
    btbcm 7916 1 hci_uart
    bluetooth 365511 22 hci_uart,bnep,btbcm
    brcmfmac 222874 0
    brcmutil 9092 1 brcmfmac
    cfg80211 543027 1 brcmfmac
    rfkill 20851 4 bluetooth,cfg80211
    snd_bcm2835 24427 1
    snd_pcm 98501 1 snd_bcm2835
    snd_timer 23968 1 snd_pcm
    snd 70032 5 snd_timer,snd_bcm2835,snd_pcm
    bcm2835_gpiomem 3940 0
    evdev 12423 6
    joydev 9988 0
    uio_pdrv_genirq 3923 0
    uio 10204 1 uio_pdrv_genirq
    fixed 3285 0
    i2c_dev 6913 0
    fuse 99603 3
    ipv6 408971 68

Greetings
Alexandre Toledo
alex_cefet_rj@yahoo.com.br

@AlexandreToledo
Copy link

And everytime you need, you will have to recharge them, like that:

pi@raspberrypi:~ $ cd /lib/modules/$(uname -r)/kernel/drivers/usb/serial
pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ sudo insmod usbserial.ko
pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ sudo insmod ch341.ko
pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ lsmod

@mschlen
Copy link

mschlen commented Nov 7, 2017

First of all thank you very much for this manual how to get it running. I´ve done it step by step and the last lsmod shows me that everything should be fine. The problem is, that the Arduino IDE (2.1.0.5) doesnt show me a serial port. I have connected an Arduino Uno with CH34x to my Rasp3B. The weird thing: only one time it was working, but I tried different times after that and it never showed a serial port again. I also checked with lsmod before every time, but shows the two lines correctly. So do you have any suggestion or is there maybe a common mistake i made? Thanks in advance!
screenshot

@rodydavis
Copy link

How do you get it to show up in lsusb? it is showing up now under usbserial.

@mschlen
Copy link

mschlen commented Dec 7, 2017

Sry, didn't get you point. I am not an english native speaker. Think I mentioned the way I tried to get it running. See my comments to the picture.

@rodydavis
Copy link

Unfortunately I am on a headless raspberry pi lite “Sketch”. I decided to plug in the UNO I have and it’s recgonized no problem

@valerierx
Copy link

I have compiled the driver for the latest rpi kernel version.
wget https://dl.dropboxusercontent.com/s/nkglyp57i2vl7ao/ch34x.ko
sudo insmod ch34x.ko

@AlexandreToledo
Copy link

AlexandreToledo commented Jun 3, 2018 via email

@kadon70
Copy link

kadon70 commented Mar 3, 2019

1. download
   pi@raspberrypi:~ $ wget https://github.com/aperepel/raspberrypi-ch340-driver/releases/download/4.4.11-v7/ch34x.ko

2. check
   pi@raspberrypi:~ $ lsmod
   Module                  Size  Used by
   bnep                   12051  2
   hci_uart               20020  1
   btbcm                   7916  1 hci_uart
   bluetooth             365511  22 hci_uart,bnep,btbcm
   brcmfmac              222874  0
   brcmutil                9092  1 brcmfmac
   cfg80211              543027  1 brcmfmac
   rfkill                 20851  4 bluetooth,cfg80211
   snd_bcm2835            24427  1
   snd_pcm                98501  1 snd_bcm2835
   snd_timer              23968  1 snd_pcm
   snd                    70032  5 snd_timer,snd_bcm2835,snd_pcm
   bcm2835_gpiomem         3940  0
   evdev                  12423  6
   joydev                  9988  0
   uio_pdrv_genirq         3923  0
   uio                    10204  1 uio_pdrv_genirq
   fixed                   3285  0
   i2c_dev                 6913  0
   fuse                   99603  3
   ipv6                  408971  70

3. go towards
   pi@raspberrypi:~ $ cd /lib/modules/$(uname -r)/kernel/drivers/usb/serial

4. Install first
   pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $  sudo insmod usbserial.ko

5. Check once again
   pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ lsmod
   Module                  Size  Used by
   usbserial              29943  0                             <===== Need be installed FIRST
   bnep                   12051  2
   hci_uart               20020  1
   btbcm                   7916  1 hci_uart
   bluetooth             365511  22 hci_uart,bnep,btbcm
   brcmfmac              222874  0
   brcmutil                9092  1 brcmfmac
   cfg80211              543027  1 brcmfmac
   rfkill                 20851  4 bluetooth,cfg80211
   snd_bcm2835            24427  1
   snd_pcm                98501  1 snd_bcm2835
   snd_timer              23968  1 snd_pcm
   snd                    70032  5 snd_timer,snd_bcm2835,snd_pcm
   bcm2835_gpiomem         3940  0
   evdev                  12423  6
   joydev                  9988  0
   uio_pdrv_genirq         3923  0
   uio                    10204  1 uio_pdrv_genirq
   fixed                   3285  0
   i2c_dev                 6913  0
   fuse                   99603  3
   ipv6                  408971  68

6. NOW, install ch341.ko
   pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ sudo insmod ch341.ko

7. Voilá !!!
   pi@raspberrypi:/lib/modules/4.9.35-v7+/kernel/drivers/usb/serial $ lsmod
   Module                  Size  Used by
   ch341                   6086  0                          <==== Must be here first
   usbserial              29943  1 ch341            <==== Can you see me now ?
   bnep                   12051  2
   hci_uart               20020  1
   btbcm                   7916  1 hci_uart
   bluetooth             365511  22 hci_uart,bnep,btbcm
   brcmfmac              222874  0
   brcmutil                9092  1 brcmfmac
   cfg80211              543027  1 brcmfmac
   rfkill                 20851  4 bluetooth,cfg80211
   snd_bcm2835            24427  1
   snd_pcm                98501  1 snd_bcm2835
   snd_timer              23968  1 snd_pcm
   snd                    70032  5 snd_timer,snd_bcm2835,snd_pcm
   bcm2835_gpiomem         3940  0
   evdev                  12423  6
   joydev                  9988  0
   uio_pdrv_genirq         3923  0
   uio                    10204  1 uio_pdrv_genirq
   fixed                   3285  0
   i2c_dev                 6913  0
   fuse                   99603  3
   ipv6                  408971  68

Greetings
Alexandre Toledo
alex_cefet_rj@yahoo.com.br

full of thanks sir,,,
step by step as u describe was really help me...
i just followed exactly as it is, now i could say "viola" also,,,
thanks again,,,

image

@valerierx
Copy link

Or use the mainline driver

@BillerB
Copy link

BillerB commented Nov 20, 2019

Thanks so much, this thread got me sorted connecting my nodeMCU board to Rasberry pi, never been so happy to see a simple LED flashing

@AlexandreToledo
Copy link

AlexandreToledo commented Nov 21, 2019 via email

@AlexandreToledo
Copy link

AlexandreToledo commented Nov 21, 2019 via email

@AlexandreToledo
Copy link

First of all thank you very much for this manual how to get it running. I´ve done it step by step and the last lsmod shows me that everything should be fine. The problem is, that the Arduino IDE (2.1.0.5) doesnt show me a serial port. I have connected an Arduino Uno with CH34x to my Rasp3B. The weird thing: only one time it was working, but I tried different times after that and it never showed a serial port again. I also checked with lsmod before every time, but shows the two lines correctly. So do you have any suggestion or is there maybe a common mistake i made? Thanks in advance!
screenshot

Hi!

Try starting your Arduino pre-connect to your RPi BEFORE powering both.

@xevilstar
Copy link

root@raspberrypi:/home/pi/Downloads/CH340_LINUX# cd CH341SER_LINUX/
root@raspberrypi:/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX# make
make -C /lib/modules/5.4.51-v8+/build M=/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX
make[1]: Entering directory '/root/linux-f2f7e4b23d8788e96f81a7522b2f703e51c53e70'
CC [M] /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.o
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c: In function ‘ch34x_close’:
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:562:2: error: unknown type name ‘wait_queue_t’; did you mean ‘wait_event’?
wait_queue_t wait;
^~~~~~~~~~~~
wait_event
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:573:24: error: passing argument 1 of ‘init_waitqueue_entry’ from incompatible pointer type [-Werror=incompatible-pointer-types]
init_waitqueue_entry( &wait, current );
^~~~~
In file included from ./include/linux/mmzone.h:10,
from ./include/linux/gfp.h:6,
from ./include/linux/slab.h:15,
from /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:79:66: note: expected ‘struct wait_queue_entry *’ but argument is of type ‘int *’
static inline void init_waitqueue_entry(struct wait_queue_entry *wq_entry, struct task_struct *p)
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:574:36: error: passing argument 2 of ‘add_wait_queue’ from incompatible pointer type [-Werror=incompatible-pointer-types]
add_wait_queue( &tty->write_wait, &wait );
^~~~~
In file included from ./include/linux/mmzone.h:10,
from ./include/linux/gfp.h:6,
from ./include/linux/slab.h:15,
from /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:163:86: note: expected ‘struct wait_queue_entry *’ but argument is of type ‘int *’
wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:578:5: error: implicit declaration of function ‘signal_pending’; did you mean ‘timer_pending’? [-Werror=implicit-function-declaration]
signal_pending(current) || port->serial->disconnected )
^~~~~~~~~~~~~~
timer_pending
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:585:39: error: passing argument 2 of ‘remove_wait_queue’ from incompatible pointer type [-Werror=incompatible-pointer-types]
remove_wait_queue( &tty->write_wait, &wait );
^~~~~
In file included from ./include/linux/mmzone.h:10,
from ./include/linux/gfp.h:6,
from ./include/linux/slab.h:15,
from /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:21:
./include/linux/wait.h:165:89: note: expected ‘struct wait_queue_entry *’ but argument is of type ‘int *’
wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c: In function ‘wait_modem_info’:
/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.c:756:3: error: implicit declaration of function ‘interruptible_sleep_on’; did you mean ‘interrupts_enabled’? [-Werror=implicit-function-declaration]
interruptible_sleep_on( &priv->delta_msr_wait );
^~~~~~~~~~~~~~~~~~~~~~
interrupts_enabled
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:266: /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX/ch34x.o] Error 1
make[1]: *** [Makefile:1709: /home/pi/Downloads/CH340_LINUX/CH341SER_LINUX] Error 2
make[1]: Leaving directory '/root/linux-f2f7e4b23d8788e96f81a7522b2f703e51c53e70'
make: *** [Makefile:5: default] Error 2
root@raspberrypi:/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX# uname -a
Linux raspberrypi 5.4.51-v8+ #1333 SMP PREEMPT Mon Aug 10 16:58:35 BST 2020 aarch64 GNU/Linux
root@raspberrypi:/home/pi/Downloads/CH340_LINUX/CH341SER_LINUX# gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests