OLIMEX / ch340-dkms

10 stars 4 forks source link

binary package for ch340: 1.0.0 not found #4

Open ghost opened 2 years ago

ghost commented 2 years ago

After updating my system to Ubuntu 22.04 I can connect anymore to your ESP32-POE board:

[ 4026.435289] usb 1-2: new full-speed USB device number 8 using xhci_hcd
[ 4026.584263] usb 1-2: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 4026.584268] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4026.584269] usb 1-2: Product: USB Serial
[ 4026.586499] ch341 1-2:1.0: ch341-uart converter detected
[ 4026.586921] usb 1-2: ch341-uart converter now attached to ttyUSB0
[ 4027.133018] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input25
[ 4027.134345] usb 1-2: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
[ 4027.134928] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 4027.134950] ch341 1-2:1.0: device disconnected

So I'm trying to compile this drivers but I get this error:

$ sudo dkms build .
Creating symlink /var/lib/dkms/ch340/1.0.0/source -> /usr/src/ch340-1.0.0

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
make -j8 KERNELRELEASE=5.15.0-27-generic default KERNELVERSION=5.15.0-27-generic...(bad exit status: 2)
ERROR (dkms apport): binary package for ch340: 1.0.0 not found
Error! Bad return status for module build on kernel: 5.15.0-27-generic (x86_64)
Consult /var/lib/dkms/ch340/1.0.0/build/make.log for more information.

Here the full output of the log:

$ cat /var/lib/dkms/ch340/1.0.0/build/make.log 
DKMS make.log for ch340-1.0.0 for kernel 5.15.0-27-generic (x86_64)
mar 17 mag 2022, 16:15:21, CEST
make -C /lib/modules/5.15.0-27-generic/build M=/var/lib/dkms/ch340/1.0.0/build modules
make[1]: ingresso nella directory «/usr/src/linux-headers-5.15.0-27-generic»
  CC [M]  /var/lib/dkms/ch340/1.0.0/build/ch340.o
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c: In function ‘ch340_set_baudrate_lcr’:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:171:28: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
  171 |         dev_dbg(&dev->dev, "clk: x1, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:171:9: note: in expansion of macro ‘dev_dbg’
  171 |         dev_dbg(&dev->dev, "clk: x1, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |         ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:171:48: note: format string is defined here
  171 |         dev_dbg(&dev->dev, "clk: x1, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |                                              ~~^
      |                                                |
      |                                                long unsigned int
      |                                              %u
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:28: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat=]
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                            ^~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:9: note: in expansion of macro ‘dev_dbg’
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |         ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:36: note: format string is defined here
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                  ~~^
      |                                    |
      |                                    long unsigned int
      |                                  %u
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:28: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘unsigned int’ [-Wformat=]
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                            ^~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:9: note: in expansion of macro ‘dev_dbg’
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |         ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:176:42: note: format string is defined here
  176 |         dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                        ~~^
      |                                          |
      |                                          long unsigned int
      |                                        %u
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:196:36: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
  196 |                 dev_dbg(&dev->dev, "clk: x2, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:196:17: note: in expansion of macro ‘dev_dbg’
  196 |                 dev_dbg(&dev->dev, "clk: x2, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |                 ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:196:56: note: format string is defined here
  196 |                 dev_dbg(&dev->dev, "clk: x2, factor: %lu, divisor: %d (/%d)\n", factor, divisor, div);
      |                                                      ~~^
      |                                                        |
      |                                                        long unsigned int
      |                                                      %u
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:36: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat=]
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                    ^~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:17: note: in expansion of macro ‘dev_dbg’
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                 ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:44: note: format string is defined here
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                          ~~^
      |                                            |
      |                                            long unsigned int
      |                                          %u
In file included from ./include/linux/printk.h:559,
                 from ./include/linux/kernel.h:19,
                 from /var/lib/dkms/ch340/1.0.0/build/ch340.c:16:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:36: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘unsigned int’ [-Wformat=]
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                    ^~~~~~~~~~~~~~~~~~
./include/linux/dynamic_debug.h:134:29: note: in definition of macro ‘__dynamic_func_call’
  134 |                 func(&id, ##__VA_ARGS__);               \
      |                             ^~~~~~~~~~~
./include/linux/dynamic_debug.h:166:9: note: in expansion of macro ‘_dynamic_func_call’
  166 |         _dynamic_func_call(fmt,__dynamic_dev_dbg,               \
      |         ^~~~~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:9: note: in expansion of macro ‘dynamic_dev_dbg’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |         ^~~~~~~~~~~~~~~
./include/linux/dev_printk.h:155:30: note: in expansion of macro ‘dev_fmt’
  155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
      |                              ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:17: note: in expansion of macro ‘dev_dbg’
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                 ^~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:201:50: note: format string is defined here
  201 |                 dev_dbg(&dev->dev, "%u - %lu = %lu\n", priv->baud_rate, res, diff);
      |                                                ~~^
      |                                                  |
      |                                                  long unsigned int
      |                                                %u
/var/lib/dkms/ch340/1.0.0/build/ch340.c: At top level:
/var/lib/dkms/ch340/1.0.0/build/ch340.c:682:30: error: initialization of ‘void (*)(struct usb_serial_port *)’ from incompatible pointer type ‘int (*)(struct usb_serial_port *)’ [-Werror=incompatible-pointer-types]
  682 |         .port_remove       = ch340_port_remove,
      |                              ^~~~~~~~~~~~~~~~~
/var/lib/dkms/ch340/1.0.0/build/ch340.c:682:30: note: (near initialization for ‘ch340_device.port_remove’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:285: /var/lib/dkms/ch340/1.0.0/build/ch340.o] Errore 1
make[1]: *** [Makefile:1875: /var/lib/dkms/ch340/1.0.0/build] Errore 2
make[1]: uscita dalla directory «/usr/src/linux-headers-5.15.0-27-generic»
make: *** [Makefile:5: default] Errore 2
jeremiahrose commented 2 years ago

I am having the same issue, also on Ubuntu 22.04

joscherrer commented 2 years ago

Same issue, also on Ubuntu 22.04

As a workaround, you can add the -Wno-incompatible-pointer-types flag to ignore the warning. For example :

obj-m := ch340.o
KDIR := /lib/modules/$(shell uname -r)/build
CFLAGS_ch340.o := -Wno-incompatible-pointer-types

default:
    $(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
    $(MAKE) -C $(KDIR) M=$(PWD) clean
joscherrer commented 2 years ago

Edit : Nevermind, I didn't understand the README's disclaimer, you should use the ch341 kernel driver which is already shipped with most linux distributions. The ch340 driver was only used because ch341 had speed issues until kernel 5.5.

Remove callback return type has been changed to void since kernel 5.12 : https://github.com/torvalds/linux/commit/c5d1448fa353242635fa3e1fed6ab4558e0e7d9a

I'll try to throw in a PR tomorrow.

patrickwasp commented 1 year ago

@joscherrer how do you use the ch341 driver? I have ubuntu 22.04.2 with 5.19.0-38-generic. lsusb shows

Bus 003 Device 011: ID 1a86:7523 QinHeng Electronics CH340 serial converter

but I don't see any new devices in /dev.

Should I be downloading the driver from https://www.wch.cn/downloads/CH341SER_LINUX_ZIP.html?

lightmaster commented 2 months ago

@joscherrer how do you use the ch341 driver? I have ubuntu 22.04.2 with 5.19.0-38-generic. lsusb shows

Bus 003 Device 011: ID 1a86:7523 QinHeng Electronics CH340 serial converter

but I don't see any new devices in /dev.

Should I be downloading the driver from https://www.wch.cn/downloads/CH341SER_LINUX_ZIP.html?

you figure this out?