Missing ch340 / usbserial modules for uart converter in resin 2.2.0

kernelmodules

#1

Hi,

I want to work with usb serial converter that uses driver ch341 and depends on usbserial module. In desktop linux it is present in /lib/modules/4.10.0-28-generic/kernel/drivers/usb/serial/. However in ResinOS 2.2.0 the folder does not exist. That I assume is that by choice those modules were not built in into kernel. What is the idea on how to add them / load them into kernel? Of course to load them correctly they should be compiled with the kernel version of ResinOS.

Kind regards,
llap


#2

Hi @llap, there’s an experimental project to show how to add your custom kernel modules. It’s very work in progress, and feedback is appreciated.

We are also working on a quite different approach to add kernel modules, will keep everyone posted here in the forums, that should fix a lot of these more complicated issues by a much more powerful solution.


#3

I am trying to connect it all (by the way I am trying to build module that in standard is in kernel tree, wouldnt it be easier for me just to compile the exact same kernel as I am using intel? Can you provide the link to the kernel you are using?).

  1. I have cloned mentioned repository (kernel-module-build)
  2. I have checked version of kernel for 2.2.0.dev which is 4.8.17
  3. I have downloaded file ch431.c from kernel version from source code
    https://github.com/torvalds/linux/tree/v4.8/drivers/usb/serial
  4. I have changed Makefiles and Dockerfile

[[Dockerfile]]

FROM resin/intel-nuc-debian
RUN apt-get update && apt-get install -y curl wget build-essential
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN ./build.sh intel-nuc '2.2.0+rev1.dev' ch341
CMD ./run.sh

[[Makefile]]

KERNEL_TREE_PATH?=/lib/modules/$(shell uname -r)/build
EXTRA_CFLAGS="-DDEBUG"

obj-m+=ch341.o
all: ch341.ko

ch341.ko: ch341.c
                make -C $(KERNEL_TREE_PATH) M=$(PWD) modules
clean:
                make -C $(KERNEL_TREE_PATH) M=$(PWD) clean

.PHONY: all clean

I get the result

Step 5/6 : RUN ./build.sh intel-nuc '2.2.0+rev1.dev' ch341
 ---> Running in 4b0607a3ef86
Building images/intel-nuc/2.2.0+rev1.dev/kernel_modules_headers.tar.gz...
--2017-08-05 16:26:35--  https://files.resin.io/images/intel-nuc/2.2.0%2Brev1.dev/kernel_modules_headers.tar.gz
Resolving files.resin.io (files.resin.io)... 34.226.173.211, 54.152.194.198
Connecting to files.resin.io (files.resin.io)|34.226.173.211|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9883956 (9.4M) [application/x-tar]
Saving to: ‘kernel_modules_headers.tar.gz’

     0K .......... .......... .......... .......... ..........  0%  201K 48s

  9650K ..                                                    100% 4388G=4.6s

2017-08-05 16:26:40 (2.05 MB/s) - ‘kernel_modules_headers.tar.gz’ saved [9883956/9883956]

make: Entering directory '/tmp/tmp.zmkPme4h3t'
  CC [M]  /usr/src/app/ch341_intel-nuc_2.2.0+rev1.dev/ch341.o
/bin/sh: 1: scripts/basic/fixdep: not found
scripts/Makefile.build:295: recipe for target '/usr/src/app/ch341_intel-nuc_2.2.0+rev1.dev/ch341.o' failed
make[1]: *** [/usr/src/app/ch341_intel-nuc_2.2.0+rev1.dev/ch341.o] Error 127
Makefile:1473: recipe for target '_module_/usr/src/app/ch341_intel-nuc_2.2.0+rev1.dev' failed
make: Leaving directory '/tmp/tmp.zmkPme4h3t'
make: *** [_module_/usr/src/app/ch341_intel-nuc_2.2.0+rev1.dev] Error 2
 ---> f598afc579b1

#4

Hey, looks like that is might be an library linking issue, the fixdep tool is looking for /lib/ld-linux-x86-64.so.2 but that should be symlinked to /lib64/ld-linux-x86-64.so.2, and it’s not. Since it doesn’t find the relevant library, it cannot run. It’s fixed up by having this line somewhere in your Dockerfile before the build step.

RUN ln -s /lib64/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2

I’ve tried it out, and the module seems to be building fine with that. The rest of the changes you made seem to be spot on. Hope this will help!

Will be following up with this issue to see what’s up with those libraries.


#5

Hey @imrehg, you mentioned in your post that you are working on different approach to adding kernel modules. Do you have any updates on that?


#7

@llap we are adding support for host apps, these will allow you to customise the host using the same Dockerfile + git push solution we provide for user apps. The feature is currently in for review.


#10

Hey @joe is that functionality operational? Or anytime soon?


#11

@llap it should be available in the next month or so.