Hi everyone! I tried to add a module to the kernel and then build CE. While the CE image gets built and is working fine the kernel module I added is missing. Is there a log somewhere that tells me why the module didn’t get built?
I’m a beginner just playing around so any help is appreciated.
Alright, so the module I’m trying to add is gpio-ir-tx, which is included in linux 4.14 and up. I managed to get it built in linux-amlogic 4.9 with some dirty hacking in rc-core related files, without knowing C so I’m fairly certain the module won’t even work in the state I compiled it in but I would like to test it anyways. I put my modifications up on Github if anyone feels like checking it.
Anyways, to test the module I need to define a GPIO pin for it in my dVIM3’s device tree file as per the documentation over here. Can somebody show me the right way to do this either in the device tree source (VIM3 dts file over here) or from commandline using fdtput (which is suited for this purpose, right?)?
Thanks, I added that to the device tree source and built a new CE image (confirmed binding by decompiling dtb.img with dtc). But I don’t see another lirc device for sending IR signals. Just the standard /dev/lirc0 and it can only be used for receiving (not sending):
# ir-ctl -f -d /dev/lirc0
Receive features /dev/lirc0:
- Device can receive raw IR
warning: /dev/lirc0: device supports setting receiving timeout but min timeout is 0
- Can set receiving timeout min:0 microseconds max:1250000 microseconds
Send features /dev/lirc0:
- Device cannot send
I can see the gpio-ir-tx module on my system:
# modinfo gpio-ir-tx
filename: /lib/modules/4.9.113/kernel/drivers/media/rc/gpio-ir-tx.ko
license: GPL
author: Sean Young <sean@mess.org>
description: GPIO IR Bit Banging Transmitter
alias: of:N*T*Cgpio-ir-txC*
alias: of:N*T*Cgpio-ir-tx
depends: rc-core
intree: Y
vermagic: 4.9.y SMP preempt mod_unload aarch64
Could you just confirm that I put the device tree binding in the right place in the dts file? Because then I can just assume that I broke the module with my source code modifications. That would explain why it can’t create a /dev/lirc1 device.
[ 3.106706@3] gpio-ir-tx irled@1: failed to register rc device
[ 3.106719@3] gpio-ir-tx: probe of irled@1 failed with error -22
That error comes from the module source gpio-ir-tx.cat line 183.
I took the gpio-ir-tx.cfrom a newer kernel and had to make a few changes to the source right around the part that that takes care of registering the rc device (because devm_rc_allocate_device and devm_rc_register_device don’t exist in kernel 4.9 and work with their counterparts without devm_ prefix. To make the changes I looked at gpio-ir-recv.c and copied parts of the code from there.
Any suggestions on how to fix this and get the rc device to register properly?
P.S. when booting my VIM3 with the non-modified dtb the module is not loaded unless I manually load it with modprobe, and then it’s only visible as using rc_core module (nothing in dmesg either):
Right again, that resolved the error, new dmesgoutput shows:
[ 3.227292@0] Registered IR keymap rc-empty
[ 3.227535@0] input: GPIO IR Bit Banging Transmitter as /devices/virtual/rc/rc0/input6
[ 3.227726@0] rc rc0: GPIO IR Bit Banging Transmitter as /devices/virtual/rc/rc0
But I must say, the more I look at the code the more I think the entire gpio_ir_tx_probe function needs to be rewritten. When gpio-ir-tx was added to the kernel an overhaul was done to rc-core as well, simplifying the individual drivers. If you compare the probe function from gpio-ir-recv from 4.9 with 4.14 you can see how it was rewritten for that module as well.
I’m afraid this is over my head unfortunately. But if you have any more (easy) suggestions I would love to hear them of course.
I don’t see much changes and should probably work. Maybe some little changes are missing.
Did you test if it works? How to transmit something? And what hw is needed? Maybe I could play with it.
You could also look lirc which also supports transmitter.
Yes, I tested by building the entire image and updating my VIM3 with it but there is no new lirc device so I can’t transmit anything. As you can see in my previous post dmesg output mentions /devices/virtual/rc/rc0 (but that path doesn’t exist).
If you’re willing to test things: in terms of hardware all that’s needed is an IR LED with a resistor (or a regular LED to visually check if it’s working) connected to the GPIO pin. As I understand it, when the module is working, a new /dev/lirc device is supposed to show up that can be used to send IR commands. The lirc device can be checked with ir-ctl -f -d /dev/lirc1. Commands can easily be sent like ir-ctl -d /dev/lirc1 -S nec:0x810.
Maybe it’s also useful to know that Raspberry Pi’s (that run an updated kernel) have this module out of the box and there it can be enabled with a simple device tree overlay setting, e.g. on LibreELEC (it’s the same for gpio-ir-tx and pwm-ir-tx).
Regarding the reason the module is not working: there may also be an issue with dependencies, for example in rc-main.c there are no references to RC_DRIVER_IR_RAW_TX at all. Which are added in kernel 4.14. And if you browse the kernel source at the commit that added gpio-ir-tx it is also visible that a lot of changes were made to various files dealing with IR and the rc-core.
Anyways I forked linux-amlogic and CoreELEC and put my attempt up on Github in separate branches. So you could just download branch CE-9.2-with-ir-tx of my CoreELEC fork and it will automatically get the modified kernel as well.
Seems it is not just this module but few other pieces around rc subsystem. You should look commits from 4.9 to rc and took everything in regards to rc.