DEV: [PLUGIN] MPD_OLED for x86 based systems

I plugged in a cheapo 7inch LCD with controller and resistive touch into my Wyse 3040 and everything just worked. I didn’t have to set anything up! WTF! :exploding_head::exploding_head::exploding_head:

The x86 has already the drivers onboard. Tried the same with my Waveshare 1280x400 screen. Only it was in portrait mode. Didn’t want to sort it out as I am not going to use a display with it.

I never knew that, it’s very handy! Do you know if there’s an on screen keyboard available? I’m gonna check the forums…

I don’t think I need to have a screen on my player. This screen hasn’t got the best view angles.

Yes I know, there isn’t Due to the chromium version. Several attempts were made, without success.
Airmouse to the resqueue :slight_smile:

1 Like

@Wheaten Ah yes, I’ve just seen some of the issues on the forum. From a usability point of view I don’t think it’s a deal breaker - using the touchscreen to type would take ages and would totally get on your nerves. The touchscreen is best though as another way to control playback :slight_smile: Besides we all have smartphones and they’re the best for user input and configuring volumio :slight_smile: Cheers!

Fast delivery. Just received my “CP2112” within 10 days.
Let’s see what it brings. Not much…

need to compile and install drivers. So if someone feels sorting this out, please do.
I won’t spend much time on this, as it keeps nagging on missing kernel files.

volumio@volumio-dev:~$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 10c4:ea90 Cygnal Integrated Products, Inc.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
volumio@volumio-dev:~$ dmesg | grep CP2112
[    1.515156] usb 3-13: Product: CP2112 HID USB-to-SMBus Bridge
[    1.518127] hid-generic 0003:10C4:EA90.0001: hiddev0,hidraw0: USB HID v1.01 Device [Silicon Laboratories CP2112 HID USB-to-SMBus Bridge] on usb-0000:00:14.0-13/input0

@wheaten that’s a bummer :frowning:

Yeah tried to compile “hid-mcp2221.c” with gcc, but it keeps nagging on missing kernel files, even though they are on the system (installed kernel-headers as showed in previous post).
Since the ch341 is doing it’s job, I won’t spend time on this.

1 Like

From a quick search, it appears that one way people build a single modules from the linux source tree is by using the whole source tree. The module-assistant program can help building the module

ModuleAssistant - Debian Wiki

I don’t know how often the Volumio kernel version changes, but this may require getting new source and rebuilding the module each time.

A possible way to avoid this is to extract all the files needed from the kernel source and build with dkms

ubuntu - Using DKMS, to automatically patch and install kernel on update - Unix & Linux Stack Exchange

I don’t know how easy it is to prepare the source files needed, or how often the module build, or the binary produced, would be broken by a kernel update.

Adrian.

I got the hid-mcp2221 module built with dkms on Ubuntu as follows

I created a directory /usr/src/my-hid-mcp2221-1.0.0.0 and copied hid-mcp2221.c and hid-ids.h from the kernal source into it. Then created dkms.conf

PACKAGE_NAME=my-hid-mcp2221
PACKAGE_VERSION=1.0.0.0
BUILT_MODULE_NAME[0]="my-hid-mcp2221"
DEST_MODULE_LOCATION[0]="/kernel/extra"
AUTOINSTALL=yes

And Makefile (those long spaces need to be tabs!)

EXTRA_CFLAGS+=-DLINUX_DRIVER -mhard-float

obj-m += my-hid-mcp2221.o
my-hid-mcp2221-objs:= hid-mcp2221.o

all:
        make -C /lib/modules/$(kenelver)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(kernelver)/build M=$(PWD) clean

Now

sudo dkms add -m my-hid-mcp2221 -v 1.0.0.0
sudo dkms build -m my-hid-mcp2221 -v 1.0.0.0

I had a few errors on the way while setting up the build. If you have errors I recommend deleting all the generated files in the source directory (i.e. just leave the original four files). I had to do this on ubuntu to avoid a build error relating to vmlinux

sudo apt install dwarves
sudo cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/

I didn’t install thr driver, but the command should be

sudo dkms install -m my-hid-mcp2221 -v 1.0.0.0

Adrian.

In case there is a real demand for it, I would be willing to add this into the kernel tree as a patch, like I promised @Wheaten for the ch341 adapter.
The x86 kernel build is mostly automated, once the patch has been done, it will be picked up for following kernel builds.
Imalready have some patches (mainly wireless drivers), this patch only needs to be created once, the

It is an existing kernel module in 6.1 (and 5.10), just needs to be selected when we move to kernel 6.1, no patches needed.
I will not recompile the current kernel 5.10, as I need the time for testing 6.1

I was just replying to say that the modules were already in the tree! Also, the hid-cp2112 module will be useful for the small purple board posted earlier in the thread [and which Wheaten bought!].

yeah that didn’t go well:

image

volumio@volumio-dev:/usr/src$ sudo dkms add -m my-hid-mcp2112 -v 1.0.0.0

Creating symlink /var/lib/dkms/my-hid-mcp2112/1.0.0.0/source ->
                 /usr/src/my-hid-mcp2112-1.0.0.0

DKMS: add completed.
volumio@volumio-dev:/usr/src$ sudo dkms build -m my-hid-mcp2112 -v 1.0.0.0

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make -j4 KERNELRELEASE=5.10.139-volumio -C /lib/modules/5.10.139-volumio/build M=/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build...(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.10.139-volumio (x86_64)
Consult /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/make.log for more information.
volumio@volumio-dev:/usr/src$

Make.log:

DKMS make.log for my-hid-mcp2112-1.0.0.0 for kernel 5.10.139-volumio (x86_64)
Thu Dec 15 18:43:40 CET 2022
make: Entering directory '/usr/src/linux-headers-5.10.139-volumio'
make[1]: *** No rule to make target '/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/my-hid-mcp2112.o', needed by '/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/my-hid-mcp2112.mod'.  Stop.
make: *** [Makefile:1832: /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.10.139-volumio'

You have a file called hid-mcp2112.c, which I believe you have renamed from the name of the file in the kernel (extra ‘m’). It might be worth checking the names in dkms.conf and Makefile are consistent with this.

dkms.conf:

PACKAGE_NAME=my-hid-mcp2112
PACKAGE_VERSION=1.0.0.0
BUILT_MODULE_NAME[0]="my-hid-mcp2112"
DEST_MODULE_LOCATION[0]="/kernel/extra"
AUTOINSTALL=yes

Makefile (including TAB :smile: )

EXTRA_CFLAGS+=-DLINUX_DRIVER -mhard-float

obj-m += my-hid-mcp2112.o
my-hid-mcp2221-objs:= hid-mcp2112.o

all:
	make -C /lib/modules/$(kenelver)/build M=$(PWD) modules
clean:
	make -C /lib/modules/$(kernelver)/build M=$(PWD) clean

euh…my-hid-mcp2221-objs ??

You have a 2221 instead of a 2112

typos?

yes yes, saw it and corrected it.

DKMS make.log for my-hid-mcp2112-1.0.0.0 for kernel 5.10.139-volumio (x86_64)
Thu Dec 15 19:51:02 CET 2022
make: Entering directory '/usr/src/linux-headers-5.10.139-volumio'
  CC [M]  /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.o
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:132:2: error: expected specifier-qualifier-list before 'struct_group_attr'
  struct_group_attr(contents, __packed,
  ^~~~~~~~~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c: In function 'pstr_store':
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:16: error: 'struct cp2112_string_report' has no member named 'string'
          report.string, ARRAY_SIZE(report.string));
                ^
In file included from ./include/asm-generic/bug.h:20,
                 from ./arch/x86/include/asm/bug.h:93,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/gpio/consumer.h:6,
                 from /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:19:
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:42: error: 'struct cp2112_string_report' has no member named 'string'
          report.string, ARRAY_SIZE(report.string));
                                          ^
./include/linux/kernel.h:48:33: note: in definition of macro 'ARRAY_SIZE'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                 ^~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:42: error: 'struct cp2112_string_report' has no member named 'string'
          report.string, ARRAY_SIZE(report.string));
                                          ^
./include/linux/kernel.h:48:48: note: in definition of macro 'ARRAY_SIZE'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                ^~~
In file included from ./include/linux/bits.h:22,
                 from ./include/linux/gpio/consumer.h:5,
                 from /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:19:
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:42: error: 'struct cp2112_string_report' has no member named 'string'
          report.string, ARRAY_SIZE(report.string));
                                          ^
./include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO'
 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
                                                              ^
./include/linux/compiler.h:240:46: note: in expansion of macro '__same_type'
 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                                              ^~~~~~~~~~~
./include/linux/kernel.h:48:59: note: in expansion of macro '__must_be_array'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                           ^~~~~~~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:25: note: in expansion of macro 'ARRAY_SIZE'
          report.string, ARRAY_SIZE(report.string));
                         ^~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:42: error: 'struct cp2112_string_report' has no member named 'string'
          report.string, ARRAY_SIZE(report.string));
                                          ^
./include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO'
 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
                                                              ^
./include/linux/compiler.h:240:46: note: in expansion of macro '__same_type'
 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                                              ^~~~~~~~~~~
./include/linux/kernel.h:48:59: note: in expansion of macro '__must_be_array'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                           ^~~~~~~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:25: note: in expansion of macro 'ARRAY_SIZE'
          report.string, ARRAY_SIZE(report.string));
                         ^~~~~~~~~~
./include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
                                                   ^
./include/linux/compiler.h:240:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
                            ^~~~~~~~~~~~~~~~~
./include/linux/kernel.h:48:59: note: in expansion of macro '__must_be_array'
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
                                                           ^~~~~~~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:967:25: note: in expansion of macro 'ARRAY_SIZE'
          report.string, ARRAY_SIZE(report.string));
                         ^~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:968:8: error: 'struct cp2112_string_report' has no member named 'report'
  report.report = attr->report;
        ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:969:8: error: 'struct cp2112_string_report' has no member named 'length'
  report.length = ret * sizeof(report.string[0]) + 2;
        ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:969:37: error: 'struct cp2112_string_report' has no member named 'string'
  report.length = ret * sizeof(report.string[0]) + 2;
                                     ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:970:8: error: 'struct cp2112_string_report' has no member named 'type'
  report.type = USB_DT_STRING;
        ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:972:39: error: 'struct cp2112_string_report' has no member named 'report'
  ret = cp2112_hid_output(hdev, &report.report, report.length + 1,
                                       ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:972:54: error: 'struct cp2112_string_report' has no member named 'length'
  ret = cp2112_hid_output(hdev, &report.report, report.length + 1,
                                                      ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:974:19: error: 'struct cp2112_string_report' has no member named 'length'
  if (ret != report.length + 1) {
                   ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c: In function 'pstr_show':
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:996:56: error: 'struct cp2112_string_report' has no member named 'contents'
  ret = cp2112_hid_get(hdev, attr->report, (u8 *)&report.contents,
                                                        ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:997:22: error: 'struct cp2112_string_report' has no member named 'contents'
         sizeof(report.contents), HID_FEATURE_REPORT);
                      ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1006:12: error: 'struct cp2112_string_report' has no member named 'length'
  if (report.length < 2) {
            ^
In file included from ./include/linux/device.h:15,
                 from ./include/linux/gpio/driver.h:5,
                 from /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:21:
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1008:28: error: 'struct cp2112_string_report' has no member named 'length'
    kattr->attr.name, report.length);
                            ^
./include/linux/dev_printk.h:112:32: note: in definition of macro 'dev_err'
  _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
                                ^~~~~~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1007:3: note: in expansion of macro 'hid_err'
   hid_err(hdev, "invalid %s string length: %d\n",
   ^~~~~~~
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1012:17: error: 'struct cp2112_string_report' has no member named 'length'
  length = report.length > ret - 1 ? ret - 1 : report.length;
                 ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1012:53: error: 'struct cp2112_string_report' has no member named 'length'
  length = report.length > ret - 1 ? ret - 1 : report.length;
                                                     ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1013:39: error: 'struct cp2112_string_report' has no member named 'string'
  length = (length - 2) / sizeof(report.string[0]);
                                       ^
/var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.c:1014:30: error: 'struct cp2112_string_report' has no member named 'string'
  ret = utf16s_to_utf8s(report.string, length, UTF16_LITTLE_ENDIAN, buf,
                              ^
make[1]: *** [scripts/Makefile.build:286: /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build/hid-mcp2112.o] Error 1
make: *** [Makefile:1832: /var/lib/dkms/my-hid-mcp2112/1.0.0.0/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.10.139-volumio'


Summary:

Makefile:

EXTRA_CFLAGS+=-DLINUX_DRIVER -mhard-float

obj-m += my-hid-mcp2112.o
my-hid-mcp2112-objs:= hid-mcp2112.o

all:
	make -C /lib/modules/$(kenelver)/build M=$(PWD) modules
clean:
	make -C /lib/modules/$(kernelver)/build M=$(PWD) clean

dkms.conf:

PACKAGE_NAME=my-hid-mcp2112
PACKAGE_VERSION=1.0.0.0
BUILT_MODULE_NAME[0]="my-hid-mcp2112"
DEST_MODULE_LOCATION[0]="/kernel/extra"
AUTOINSTALL=yes

commands executed:

sudo dkms add -m my-hid-mcp2112 -v 1.0.0.0
sudo dkms install -m my-hid-mcp2112 -v 1.0.0.0

The build worked fine for me on Ubuntu. Perhaps you could use the kernel files hid-cp2112.c and hid-ids.h from the Volumio kernel source. The files you used might be expecting different headers.