cschramm / irda

36 stars 8 forks source link

irda module verification failed #13

Open salvojettison opened 1 year ago

salvojettison commented 1 year ago

Hi,

First of all, thank you for the out of the tree support. You are a hero! After I added your code to my kernel, I get the following in dmesg when I boot the system: [ 105.189704] usb 2-2: new full-speed USB device number 2 using xhci_hcd [ 105.338197] usb 2-2: New USB device found, idVendor=9710, idProduct=7780, bcdDevice= 0.01 [ 105.338209] usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 105.360020] irda: module verification failed: signature and/or required key missing - tainting kernel [ 105.361728] NET: Registered PF_IRDA protocol family [ 105.363995] usbcore: registered new interface driver mcs7780

I am still struggling to make irda work on my computer. Can it be that the failed verification block the irda?

Thank you and cheers!

cschramm commented 1 year ago

You're welcome. :slightly_smiling_face:

That message is totally expected as the module is not signed. It's locally built and taints the kernel anyway. I'd actually also expect irda: loading out-of-tree module taints kernel., at least when installed via dkms. Anyway, all that does not mean that the module will not work.

What problem do you have? I assume you got irda-utils and are trying to use irattach with no success?

salvojettison commented 1 year ago

All right, thanks for the info! I am trying to make connect my old Polar CS600X, but as I am very new to linux, it is quite challenging.

Yes, I have irda-utils, which seems to work well. In irdadump the Polar HRM is visible. Unfortunately I could not make an of the Linux alternatives of the Polar ProTrainer 5 software to work, so I am trying to connect the HRM through wine.

When I try to sync, there is no change to the irdadump and the progress window closes either after a second or two, or about half a minute, whether I link ircomm0 to one of the COM ports of Wine or not... If I type cat < /dev/ircomm0 in terminal, there is some serious action in irdadump, whether I do something in wine or not...

My assumption now is that the PPT5 in wine does not find the irda somehow... I spent already couple days trying to find correct linking, but no success.

There are multiple report of success based on this simple description: https://guriandersen.no/polar-pulse-watch-infrared-communication-and-ubuntu/

I have the exact same chip and thanks to your irda module I can make use of it, but the last step is still missing...

salvojettison commented 1 year ago

In the meantime I have installed an old Ubuntu (14.04), where the irda stack was still included. To my greatest amusement, surprise and celebration, it has worked right away with the simple description from here: http://www.jbackes.de/wiki/doku.php?id=polar_protrainer_5_wine

I didn't even had to do irattach by myself. It took considerably longer to connect to the watch than on windows, so it was behaving very similar than on the latest Linux Mint. Than came the biggest surprise, the watch has appeared in the program and transfer has been started! :)

So at least I have now a successful reference which keeps my hopes up that this thing could actually work under the latest linux distributions.

Below is an excerpt of what I was doing. I take any kind of suggestion, critic of what to do different (even if it is not related to the topic). Specially because I really novice in Linux. My installation is not even two weeks old...:)

The main differences that I have noticed between the countless unsuccessful tries and the latest successful one: => S1. and S2. below represents Scenario 1 (successful) and Scenario 2 (unsuccesful)

  1. Linux distribution: S1. Ubuntu 14.4 S2. Linux Mint 21.2

  2. Recognizing IrDA device when plugged in: S1. The IrDA device is recognized immediately thanks to the included irda stack. I get the following by "lsmod | grep irda" irda 196608 1 mcs7780 crc_ccitt 16384 2 irda,mcs7780 => the second line does not appear in S2. I don't know what this is and I could make it appear. S2. I use your irda stack I get the following by "lsmod | grep irda" irda 270336 1 mcs7780

  3. No difference in dmesg (other than module signature verification fails by your irda stack) S

  4. Way to install irda-utils: S1. "sudo apt -get install irda-utils" works like a charm S2. irda-utils is not available in the packagamanager anymore! I do the following:

  5. Same in S1. and S2. /etc/modprobe.d/irda-utils.conf

    • add the following alias irda0 mcs7780 /etc/default/irda-utils
    • change the following ENABLE="true" DEVICE="irda0" MAX_BAUD_RATE="9600"
  6. having to use "sudo irattach irda0 -s" to activate IrDA device S1. no S2. yes

  7. irdadump sees the Polar CS600x in both S1. and S2.

  8. wine installation S1. "sudo apt -get install wine" version wine1.6 1:1.6.2-0ubuntu4 version winetricks 0.0+20140302-0ubuntu2 S2. latest stable branch from https://wiki.winehq.org/Ubuntu (8.0.2) no winetricks

  9. "connecting" IrDA device to wine S1. I did nothing at all no additional device appears by "ls /dev" S2. After irda connection was failing to work in wine I was trying to connect irda to com in regedit of wine. a whole bunch of ircomm0, ircomm1, .. devices has appeared in /dev

Result S1. works S2. either error window "Communication port couldn't be opened" or closes the connection window in Polar ProTrainer 5 after a second or with various modification the connection window was longer open, but irdadump never got more exciting while trying to connect

Thanks for any kind of help!:)

cschramm commented 1 year ago

Perfect, I already wanted to suggest trying an old kernel for comparison.

irda-utils might be a source of problems. Using the irda-utils 0.9.18-15ubuntu1 package should be fine, but the make install trials probably installed user-local stuff that shadows the system-wide installation. You can try make uninstall in the source to get rid of it and / or just clear ~/.local.

The Debian package ships udev rules that run irattach for USB IrDA devices automagically. I think dpkg should take care that they are loaded, no matter how you install it. The only thing I can think of to go wrong is that you first add the device and then install the rules along the package. I think the device has to get added after installation to get the rules applied. udevadm monitor might shed some light if that's not the problem, also journalctl -u systemd-udevd.service might be worth checking, but anyway, calling irattach manually should be just as fine.

Step 7 sounds promising. The question remains why things do not work in Wine then. The same /dev/ttyS* and /dev/ir* files are visible at that point?

The CRC module should be fine. While there is no explicit dependency specified and msc7780 does use a function from it, it's most probably built into the kernel anyway (zgrep CONFIG_CRC32=y /proc/config.gz should find it) and would result in obvious errors otherwise.

salvojettison commented 1 year ago

Thank you for all your help!

you can try make uninstall in the source to get rid of it and / or just clear ~/.local.

I did a 2nd installation where I don't try to make install, but I directly install the downloaded .dev. That is where I got the result of 'Connection port couldn't get opened'. In the meantime I have figured, that if I add my user into the groups 'tty' and 'dialout', then I don't have the error message. It tries to connect quite long, but it times out eventually without error message. Nothing extraordinary happens in irdadump..

udevadm monitor gives very different results in the two installations: For Ubuntu 14.04: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/udevadm%20monitor%20ubuntu%2014.04 For Linux Mint: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/udevadm%20monitor%20linux%20mint%2021.2 The 2nd Linux Mint installation where I didn't try to compile and install irda-utils from the source, but from the downloaded .deb the lines with CRC do not appear. (Same for ubuntu install upon the 2nd attach, remove combination).

journalctl does not work for me under Ubuntu 14.04, but here is a copy for the Linux Mint install: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/journalctl%20-u%20systemd-udevd.service%20Linux%20Mint%2021.2

Here is the '/dev' list of the Ubuntu 14.04: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/dev%20ubuntu%2014.04 Here is the same for the non working Linux Mint: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/dev%20Linux%20Mint%2021.4

zgrep CONFIG_CRC32=y /proc/config.gz gives: gzip: /proc/config.gz: No such file or directory

lsmod | grep crc gives: libcrc32c 16384 1 btrfs crct10dif_pclmul 16384 1 crc32_pclmul 16384 0

I will try now a clean installation, where I attach the IrDA device only after irda-utils have been installed..

cschramm commented 1 year ago

The udev logs clearly indicate that it calls irattach as expected. The second installation always shows the following for that call:

executing: '/sbin/modprobe irda0'
executing: 'echo DMLaptop > /proc/sys/net/irda/devname'
executing: 'echo 1 > /proc/sys/net/irda/discovery'
Starting device irda0
socket(AF_IRDA): Address family not supported by protocol
Stopping device irda0
socket(AF_IRDA): Address family not supported by protocol
exiting ...

The socket(AF_IRDA) errors surprise me. Do you see the same a) when calling irattach manually and b) in Ubuntu 14.04? tail -f /var/log/messages should probably reveal the irattach output when it gets called.

You said you have to call irattach manually in Linux Mint. For what to achieve?

I do not get the /dev lists. There's not even an ircomm0, but you said you're reading from that using cat.

Regarding /proc/config.gz: Mhm, no configs module (loaded) in Ubuntu then. I think there's are plaintext /boot/config-$(uname -r) for the kernel that you could grep for CONFIG_CRC32. Anyway, I'm sure it's built-in and at least dmesg or something would SCREAM if it would be missing.

One thing that totally suprises me is ali-ircc showing up at some points: In the first installation udev logs you see irattach trying to load it (but failing to find it) after it failed to parse /etc/modprobe.d/irda-utils.conf. The udevadm output also shows that it gets loaded (and immediately removed again). That does not make any sense to me, assuming that the output is from the second installation. I do not know of anything that defaults to ali-ircc (well, it's alphabetically the first FIR driver :shrug:), neither in irda-utils code nor Ubuntu-added stuff. I'm not sure what exactly gets written to /etc/default/irda-utils and /etc/modprobe.d/irda-utils.conf, but it should probably be the same as on Ubuntu 14.04.

cschramm commented 1 year ago

Just checked the irattach code. The socket call should absolutely not fail after irda was loaded and the kernel emitted NET: Registered PF_IRDA protocol family. It's completely independent of the device or anything.

A quick test if it works: Run python and type:

import socket
socket.socket(family=socket.AF_IRDA)

It works fine for me and even loads the irda module if not already loaded.

salvojettison commented 1 year ago

In the meantime I have made a fresh Ubuntu 20.04 install. This does not have the built in irda stack anymore, but I can still get the irda-utils through package manager. One source of error less, while troubleshooting... This is now called Scenario 3. I have terminal log: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/terminal%20log%20S3 journalctl -u systemd-udevd.service: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/journalctl%20-u%20systemd-udevd.service%20S3 udevadm monitor: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/udevadm%20monitor%20S3

And here is my general log of this whole journey: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/00%20installation%20scenarios This includes the steps I do for Scenario 3.

It gives however the same socket(AF_IRDA) error.

The socket(AF_IRDA) errors surprise me. Do you see the same a) when calling irattach manually and b) in Ubuntu 14.04? tail -f /var/log/messages should probably reveal the irattach output when it gets called.

a) nothing new pops up in udevadm monitor b) i do not know how to check this as journalctl -u systemd-udevd.service is not available in Ubuntu 14.04. How can I enable this?

I do not have /var/log/messages

You said you have to call irattach manually in Linux Mint. For what to achieve? irattach I run manually only if the red LED of the IrDA device is not flashing. This also start things going on in irdadump.

I do not get the /dev lists. There's not even an ircomm0, but you said you're reading from that using cat

If I run 'sudo modprobe ircomm-tty', this will add the ircommx in /dev. If I cat into this, there is some stuff going on in irdadump. I do not normally fo this, was just part of the journey of a lost sole trying to find his way...:) This was not necessary in Ubuntu 14.04 at all. This is probably a dead end anyways.

Regarding /proc/config.gz: Mhm, no configs module (loaded) in Ubuntu then. I think there's are plaintext /boot/config-$(uname -r) for the kernel that you could grep for CONFIG_CRC32. Anyway, I'm sure it's built-in and at least dmesg or something would SCREAM if it would be missing.

You are absolutely right /boot/config-5.15.0-88-generic contains the following.

CONFIG_LIB_MEMNEQ=y
CONFIG_CRC_CCITT=y
CONFIG_CRC16=y
CONFIG_CRC_T10DIF=y
CONFIG_CRC_ITU_T=m
CONFIG_CRC32=y
# CONFIG_CRC32_SELFTEST is not set
CONFIG_CRC32_SLICEBY8=y
# CONFIG_CRC32_SLICEBY4 is not set
# CONFIG_CRC32_SARWATE is not set
# CONFIG_CRC32_BIT is not set
CONFIG_CRC64=m
CONFIG_CRC4=m
CONFIG_CRC7=m
CONFIG_LIBCRC32C=m
CONFIG_CRC8=m
CONFIG_XXHASH=y

One thing that totally suprises me is ali-ircc showing up at some points: In the first installation udev logs you see irattach trying to load it (but failing to find it) after it failed to parse /etc/modprobe.d/irda-utils.conf. The udevadm output also shows that it gets loaded (and immediately removed again). That does not make any sense to me, assuming that the output is from the second installation. I do not know of anything that defaults to ali-ircc (well, it's alphabetically the first FIR driver 🤷), neither in irda-utils code nor Ubuntu-added stuff. I'm not sure what exactly gets written to /etc/default/irda-utils and /etc/modprobe.d/irda-utils.conf, but it should probably be the same as on Ubuntu 14.04.

ali-ircc does not show up in Scenario 3 installation anymore! Yes, this was happening in the Linux Mint installation. I write the same into '/etc/default/irda-utils' and '/etc/modprobe.d/irda-utils.conf'

salvojettison commented 1 year ago

A quick test if it works:

Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>> import socket
>> socket.socket(family=socket.AF_IRDA)
<socket.socket fd=3, family=AddressFamily.AF_IRDA, type=SocketKind.SOCK_STREAM, proto=0>
>> 

There is no new entry neither in udevadm monitor nor in ournalctl -u systemd-udevd.service. Do I check it right?

salvojettison commented 1 year ago

What is still weird to me. In Ubuntu 14.04 I don't need to add my user in groups tty and dialout and it just works. If I don't do this in newer ubuntu or linux mint, under wine I get the "Communication port can't be opened error" immediately. If I do this, then it tries to connect to the watch, but it never happens.

salvojettison commented 1 year ago

It might have no significance, but an other thing that I notice: in dmesg of Ubuntu 14.04: NET: Registered protocol family 23 in dmesg of Ubuntu 20.04 NET: Registered PF_IRDA protocol family

cschramm commented 1 year ago

It gives however the same socket(AF_IRDA) error.

The socket(AF_IRDA) errors surprise me. Do you see the same a) when calling irattach manually and b) in Ubuntu 14.04? tail -f /var/log/messages should probably reveal the irattach output when it gets called.

a) nothing new pops up in udevadm monitor b) i do not know how to check this as journalctl -u systemd-udevd.service is not available in Ubuntu 14.04. How can I enable this?

I do not have /var/log/messages

/var/log/syslog maybe? :sweat_smile:

The logs for the manual call should be visible in sudo journalctl -f.

Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.socket(family=socket.AF_IRDA)
<socket.socket fd=3, family=AddressFamily.AF_IRDA, type=SocketKind.SOCK_STREAM, proto=0>
>>> 

There is no new entry neither in udevadm monitor nor in ournalctl -u systemd-udevd.service. Do I check it right?

To me that shows exactly the same call working that seems to fail in (udev-called) irattach.

What is still weird to me. In Ubuntu 14.04 I don't need to add my user in groups tty and dialout and it just works.

Might be a default for the primary user in 14.04. :shrug:

in dmesg of Ubuntu 14.04: NET: Registered protocol family 23 in dmesg of Ubuntu 20.04 NET: Registered PF_IRDA protocol family

That message just changed in Linux 5.14.

Anyway, I guess irattach might not really do anything necessary for you anyway. It seems like mcs7780 is loaded and does its job - eventually initializing the irda0 network interface correctly.

You should probably be able to see some debug output from mcs7780 in dmesg with echo 'file drivers/mcs7780.c +p' | sudo tee /sys/kernel/debug/dynamic_debug/control, especially MCS7780 USB-IrDA bridge found ... and IrDA: Registered MosChip MCS7780 device ..., but from ip a it all looks as I'd expect.

socket(AF_IRDA): Address family not supported by protocol might hint at the problem but I do not get it. It could be that Wine tries the same and silently runs into the same error (you could call it in strace and look for socket calls). It could also be that Wine just changed something (in its defaults), so that some additional configuration is necessary now.

cschramm commented 1 year ago

I think you're absolutely right that you have to set up a custom device mapping in Wine, see https://wiki.winehq.org/index.php?title=Wine_User's_Guide#Serial_and_Parallel_Ports. I tested a trial version of Polar ProTrainer and it seems what it does is try to use Com1. If I get the intention of the guides right, ~/.wine/dosdevices/com1 thus is expected to point at /dev/irda0 but by default point at /dev/ttyS0. I'm surprised that you do not have to set it up for Wine 1.6 at all, though.

salvojettison commented 12 months ago

Still huge thanks for your further invested time!

Here are the syslogs for both system. There is some difference... I don't get the error with manual execution of irattach, but also not the same result as under 14.04 https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/syslog%20ubuntu%2014.04 https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/syslog%20S3

Anyway, I guess irattach might not really do anything necessary for you anyway. It seems like mcs7780 is loaded and does its job - eventually initializing the irda0 network interface correctly.

Without manual irattach I get nothing in irdadump.

This is the debug log for S3: https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/debug%20S3

I couldnt find my way with strace. If I runs strace wine , it closes once the wine window opens.

Which connection option in preferences do you use in wine? IrDA, USB, Comm1... In windows and also in Ubuntu 14.04 I use IrDA. When I click on the Edit Polar Settings button (the one with the orange cog, under 14.04 it shows IrDA, same as in windows. However under 20.04 it shows Infrared connection (USB).

cschramm commented 12 months ago

Yeah, running wine with WINEDEBUG=+file is probably much more helpful here then strace. It seems like the connections just might not work as expected in recent wine (out of the box). No matter if I choose IrDA or Com1, I always see an access to Com1:. USB tries some \\.\Polarusb devices and then falls back to Com1: as well. Instead of IrDa that dialog always shows USB or COM1 for me, whatever was configured before switching to IrDA. Unless it does not matter if you choose IrDA or Com1 in Ubuntu 14.04 either, that's probably the issue.

salvojettison commented 12 months ago

How can I see which device wine is trying to use?

cschramm commented 12 months ago

CreateFileW visible when running with WINEDEBUG=+file

salvojettison commented 12 months ago

It seems the wine is calling the correct sockets, but the transfer closes prematurely. https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/winedebug%20winesock%20ubuntu%2014.04 https://github.com/salvojettison/PolarCS600x-on-Linux/blob/main/winedebug%20winesock%20S3

cschramm commented 12 months ago

Aha, it's via sockets. From a quick glance at the Wine code, I'm surprised that Com1 has any influence on that at all. It looks like sockets just get translated directly between Windows and UNIX, so that if the application opens a socket, a matching socket should get opened on the host and eventually I'd expect the irda0 network interface to get used by that. Maybe Com1 gets used as a fallback somehow or I understand Wine sockets completely wrong. :shrug: You might be able to check into what happens on the interface e.g. with Wireshark. Could shed some light on whether the device gets accessed there and if the communication shows some problem.

cschramm commented 12 months ago

By the way: SampleIrDAService made my day. That name is directly from the Microsoft socket examples. :laughing:

salvojettison commented 11 months ago

Still thank you for the hints. I have put the project on hold for a while, but I will look at it like this as soon as I have time again for this.

Btw. I have stumbled upon your name in the plugins of blueman...:) Kudos!:)