7.95.1 - lirc not working correct on rpi

  • Hello,


    on the RPi2, the ir-reciever is not working correct.
    The Key KEY_RIGHT and KEY_LEFT is not working after first try.
    Under "irw /run/lirc/lircd-lirc0" all key strokes seen, but "irw /run/lirc/lircd" only the first one.
    Seems a problem with eventlircd.


    After revert of "lirc: add lircd-uinput service" (lirc: add lircd-uinput service · LibreELEC/[email protected] · GitHub) all keys are working, again
    Edit: the working/not working keys was changed, only


    Branch: libreelec-8.0 (SHA: 83ef1f2ea906ed3820edc7f366e110658c64a82f)
    Hardware: RPi2 with TSOP38238 over lirc_rpi.dts
    Remote: MCE compatible remote (rc6 standard)



    Sascha

    Edited once, last by inusasha ().

  • I'm a bit confused about what is working and not working after you revert that commit.


    The following three test builds include the recent LIRC changes:


    1. #1228: LibreELEC Testbuilds for RaspberryPi (Kodi 18.0) (bump to 0.9.4c)
    2. #0111: LibreELEC Testbuilds for RaspberryPi (Kodi 18.0) (lirc: check for socket in lircd-uinput.service)
    3. #0114: LibreELEC Testbuilds for RaspberryPi (Kodi 18.0) (lirc: fix [email protected])


    Can you test these builds to try and determine when this problem is introduced? I'm assuming your remote is working perfectly in #1227.


    HiassofT tested a GPIO receiver on RPi3 and didn't have any problems with the 0.9.4c change PR1101 that first appeared in build #1228, so are you sure this is the PR that introduces the problem?

  • I just did a test with a clean install of the latest preview of the upcoming 7.95.2 version and my remote worked fine.


    I've been using an RPi2, a gpio IR receiver, lirc-rpi overlay in the kernel plus a custom lircd.conf for my hauppauge remote (the default lircd.conf.rpi doesn't support that).


    Please run a test when the new 7.95.2 version is out, it should be released very soon.


    BTW: instead of using the lircd-rpi overlay you could also try using the gpio-ir overlay (the latter doesn't need userspace lirc but uses in-kernel decoding like most of the USB IR receivers do). To use it add the following line to config.txt (and remove the lirc-rpi overlay):

    Code
    1. dtoverlay=gpio-ir,gpio_pin=18,gpio_pull=1,rc-map-name=rc-rc6-mce


    adjust the gpio_pin and gpio_pull parameters as needed (they have the same meaning as the corresponding lirc-rpi parameters), if you want to use something else than a RC6 MCE remote change the rc-map-name parameter as well (see the module files in /lib/modules/<kernelversion>/kernel/drivers/media/rc/keymaps).


    so long,


    Hias

  • HiassofT has informed me that 7.95.2 (which is due to be released real soon) is working fine on RPi3 with GPIO, so please test again with 7.95.2 (or build latest libreelec-8.0 branch)


    Edit: Oh hang on, 83ef1f2ea906ed3820edc7f366e110658c64a82f - that's a fairly recent build from libreelec-8.0. If 7.95.2 is still an issue then please can you identify from the test builds I gave when this problem started.

    Edited once, last by milhouse ().

  • first i tried to replace my config.txt

    Code
    1. device_tree_overlay=lirc-rpi


    with Hiassofts

    Code
    1. dtoverlay=gpio-ir,gpio_pin=18,gpio_pull=1,rc-map-name=rc-rc6-mce



    Both configs tested with 7.95.2 Hiassofts is working, my not...
    Very confusing..

    Edited once, last by inusasha ().


  • Both configs tested with 7.95.2 Hiassofts is working, my not...
    Very confusing..


    Thanks a lot for testing, and it's good to know that gpio-ir-recv is working fine!


    Did you add some special customizations or config settings?


    Please run a test with a clean installation of 7.95.2 and only the following line added to config.txt (keep everything else stock):

    Code
    1. dtoverlay=lirc-rpi


    Then, run the following command and post the output (we should see that lircd is running and using /etc/lirc/lircd.conf.rpi):

    Code
    1. ps | grep lirc


    It could well be that something's not 100% working correctly with userspace lircd. As I've tested with a different remote I can't rule out that something's wrong with the MCE remotes or lircd.conf.rpi config file. But that's just a guess,it would be great if we could narrow it down. Unfortunately I don't have an MCE remote so we'll need your help.


    Or it could also be that you need to add some lirc-rpi parameters to config.txt like gpio_in_pull=up.


    so long,


    Hias

  • I test always a clean environment, before i post bugs ;)


    here the output of the ps, and additional "systemctl status"

    Code
    1. [code]
    2. LibreELEC:~ # ps | grep lirc
    3.   250 root       0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd --release=_UP
    4.   423 root       0:00 /usr/sbin/lircd --driver=default --device=/dev/lirc0 --output=/run/lirc/lircd-lirc0 --pidfile=/run/lirc/lircd-lirc0.pid --release=_UP /etc/lirc/lircd.conf.rpi
    5.   439 root       0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
    6.   443 root       0:28 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd
    7.   447 root       0:00 /usr/sbin/lircd-uinput /run/lirc/lircd-lirc0
    8.   560 root       0:00 grep lirc


    [/code]


    Tests of Milhouse builds
    1. #1228: http://forum.kodi.tv/showthread.php?tid=...pid2487956 (bump to 0.9.4c)
    working with dtoverlay=lirc-rpi


    2. #0111: http://forum.kodi.tv/showthread.php?tid=...pid2498752 (lirc: check for socket in lircd-uinput.service)
    not working with dtoverlay=lirc-rpi

    Edited once, last by inusasha ().

  • Thanks for the feedback, the output you posted looks fine.


    Could you run tests with the official 7.0.3 build and the milhouse builds linked in post #2? It would be good to know if it's some general problem or a regression introduced with some change.


    so long,


    Hias

  • Thanks again for testing!


    I'm not quite sure if the lirc socket check is actually the culprit, so could you please also test the milhouse builds in between? Do a simple bisect until you found the first build that introduces the issue (for example #0101 OK, #0102 not OK) - that should help us narrow down the exact cause.


    Full list of builds with easy access is here: LibreELEC Testbuilds for RaspberryPi (Kodi 18.0)


    so long,


    Hias

    Edited once, last by HiassofT ().

  • Yeah... this is faster then build it my own :)


    Thanks for helping,
    Sascha


    Edit:
    MvH build #110 is working

    Edited once, last by inusasha ().

  • Code
    1. LibreELEC:~ # systemctl restart [email protected]
    2. LibreELEC:~ # irw
    3. 67 0 KEY_UP devinput
    4. 67 0 KEY_UP_UP devinput
    5. 69 0 KEY_LEFT devinput
    6. 268 0 KEY_LEFT_UP devinput
    7. 6a 0 KEY_RIGHT devinput
    8. 266 0 KEY_RIGHT_UP devinput
    9. 6c 0 KEY_DOWN devinput
    10. 6c 0 KEY_DOWN_UP devinput


    The KEY_LEFT and KEY_LEFT_UP the key id is different.
    But KEY_DOWN and KEY_DOWN_UP has the same key id...
    Can this confuse lirc ore lirc-uinput?


    PS: after restart of [email protected], i can press RIGHT and LEFT one time again...


    Tested with 7.95.2


    EDIT: in /usr/include/linux/input-event-codes.h is KEY_RIGHT_UP and KEY_LEFT_UP defined... may we need an other SUFFIX, then _UP?
    (edit1.b: was introduced with v4.7-rc6)

    Code
    1. /* Diagonal movement keys */
    2. #define KEY_RIGHT_UP            0x266
    3. #define KEY_RIGHT_DOWN            0x267
    4. #define KEY_LEFT_UP            0x268
    5. #define KEY_LEFT_DOWN            0x269


    EDIT2: quick tested with these changes


    and it seems to work. But i am not sure about side-effects

    Edited once, last by inusasha ().


  • EDIT: in /usr/include/linux/input-event-codes.h is KEY_RIGHT_UP and KEY_LEFT_UP defined... may we need an other SUFFIX, then _UP?
    (edit1.b: was introduced with v4.7-rc6)


    Cool, this looks like a very possible explanation for your issues!


    I'll run some tests myself and see if I can reproduce - not sure why I haven't seen any issues yet (if KEY_RIGHT_UP is now a valid event I should be able to see some odd behaviour).


    I'll report back after I finished my tests (could maybe take until tomorrow or so).


    so long & thanks a lot for digging into this,


    Hias

  • inusasha can you test build #0114 as that included a fix for a lirc problem introduced in build #0111.


    Edit: if you've already identified the probable issue then ignore this request!

    Edited once, last by milhouse ().

  • I ran some tests with 7.95.2 but unfortunatley couldn't reproduce the issue locally. But I have a few more things for you to try to narrow down the issue.


    First of all, the --release=XXX settings of lircd and lircd-uinput have to match, otherwise we get repeating keys. lircd defaults to no release lirc event, lircd-uinput defaults to _UP.


    The --release option of eventlircd can be dropped though, kodi doesn't seem to know what to do with that.


    For testing, install the system tools addon (in the LibreELEC programs addon catetory), that'll give you evtest (you can also use ir-keytable to monitor input events but you need to know which input event device to monitor - evtest will display a nice list on startup you can select from).


    Then, stop kodi, eventlircd, lircd and lircd-uinput: and verify they are really gone (stopping lircd via systemctl doesn't seem to work, therefore killall was needed):

    Code
    1. LibreELEC:~ # systemctl stop kodi
    2. LibreELEC:~ # systemctl stop eventlircd
    3. LibreELEC:~ # systemctl stop [email protected]
    4. LibreELEC:~ # systemctl stop [email protected]
    5. LibreELEC:~ # killall lircd
    6. LibreELEC:~ # ps | grep lirc
    7.   590 root       0:00 grep lirc


    Now start lircd manually. I did this via the following command line (you need to use /etc/lirc/lircd.conf.rpi as a configuration file):

    Code
    1. LibreELEC:~ # /usr/sbin/lircd --loglevel=debug --release=_UP --nodaemon --driver=default --device=/dev/lirc0 --output=/run/lirc/lircd-lirc0 --pidfile=/run/lirc/lircd-lirc0.pid /storage/.config/lircd.conf
    2. Warning: cannot open /etc/lirc/lirc_options.conf
    3. lircd-0.9.4c[592]: Debug: lircd:  Opening log, level: Debug
    4. lircd-0.9.4c[592]: Warning: Running as root
    5. lircd-0.9.4c[592]: Info: Using remote: hauppaugeHias.
    6. lircd-0.9.4c[592]: Notice: lircd(default) ready, using /run/lirc/lircd-lirc0


    In another terminal verify that lircd is running correctly. Start irw, press a few keys and then stop irw with ctrl-c


    The count (second value) should go up if you hold down the key and it's repeating. When releasing the key you should see a "virtual" release key with the KEYNAME_UP event (_UP as configured with --release=_UP)


    If that's working fine, stop irw and run lircd-uinput. Again press some keys:


    Here note that event code at the end: 106:1 means keycode 106, pressed, 106:0 means released.


    If the --release setting doesn't match the one from lircd lircd-uinput won't generate a input release event, resulting in endlessly repeating keys.


    You can verify that using evtest. With lircd and lircd-uinput both set to _UP you should get this:


    value 1 (at the very end) means initial keypress, 2 is repeating keypress, 0 is release.


    In the snipped part evtest reports all the key/eventcodes it'll handle, but doesn't show a symbolic name for keycode 614 decimal / 0x266 hex etc - evtest seems to be too old to know about these.


    Doing the same test with ir-keytable instead of evtest results in this output:

    Code
    1. LibreELEC:~ # ir-keytable -d /dev/input/event1 -t
    2. Testing events. Please, press CTRL-C to abort.
    3. 1486155236.010594: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x0001)
    4. 1486155236.010594: event type EV_SYN(0x00).
    5. 1486155237.015482: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x0001)
    6. 1486155237.015482: event type EV_SYN(0x00).
    7. 1486155237.052144: event type EV_KEY(0x01) key_down: KEY_RIGHT(0x0001)
    8. 1486155237.052144: event type EV_SYN(0x00).
    9. 1486155237.074032: event type EV_KEY(0x01) key_up: KEY_RIGHT(0x0001)
    10. 1486155237.074032: event type EV_SYN(0x00).


    It's basically the same output like with evtest, but the press/hold/release value isn't reported.


    Once we've verified that lircd-uinput is working correctly we can bring eventlircd into play. Let's do that without the --release option first:

    Code
    1. LibreELEC:~ # /usr/sbin/eventlircd -f -vvv --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd
    2. eventlircd[648]: input device /dev/input/event1: events of unsupported event type EV_REP will be discarded
    3. eventlircd[648]: input device /dev/input/event1: grabbed
    4. eventlircd[648]: input device /dev/input/event1: created output event device


    Now let's verify with irw that eventlircd correctly translates the input events into lirc events:


    Here I pressed right two times for a longer period. During repeats the second value counts up, after release the next keypress with start with count 0 (here it counted from 0-8 two times).


    If you start eventlircd with the --release option you should also get the "virtual" lirc up events (here I used _UP_FROM_EVENTLIRCD just to make it clear where they are coming from):

    Code
    1. LibreELEC:~ # /usr/sbin/eventlircd -f -vvv --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd --release=_UP_FROM_EVENTLIRCD
    2. eventlircd[657]: input device /dev/input/event1: events of unsupported event type EV_REP will be discarded
    3. eventlircd[657]: input device /dev/input/event1: grabbed
    4. eventlircd[657]: input device /dev/input/event1: created output event device


    Code
    1. LibreELEC:~ # irw /run/lirc/lircd
    2. 6a 0 KEY_RIGHT devinput
    3. 6a 1 KEY_RIGHT devinput
    4. 6a 2 KEY_RIGHT devinput
    5. 6a 0 KEY_RIGHT_UP_FROM_EVENTLIRCD devinput


    Please repeat these steps and compare the output with mine. Then repeat the test with lircd and lircd-uinput both started with --release=_FAKEUP (or something like that that's not _UP). Please post all the outputs so I can also have a closer look at them.


    so long,


    Hias

  • HiassofT : i will test tomorrow


    I found another problem, which breaks some tests. When start with a new image (over img.gz), the complete remote is not working in first boot. (lircd-uinput is not running, condition file does not exist). after the second boot, all services are up and remote is working.
    This is independent from the LEFT/RIGHT-key problem, but some test, i had to repeat.
    :sick:


    Sascha


  • I found another problem, which breaks some tests. When start with a new image (over img.gz), the complete remote is not working in first boot. (lircd-uinput is not running, condition file does not exist). after the second boot, all services are up and remote is working.
    This is independent from the LEFT/RIGHT-key problem, but some test, i had to repeat.
    :sick:


    This is very interesting info - I've suspected before that the lircd systemd config is racy and could lead to such things.


    If lircd-uinput is scheduled to start before lircd has created the socket the ConditionPathExist (on the socket) will fail and lircd-uinput won't start. The upstream systemd config does this differently, the socket is create via an independent systemd config (lircd.socket): LIRC / Git / [0d26f0] /systemd


    Could you please try to reproduce this and when it happens grab the systemctl status of the services? the boot log would also be interesting:

    Code
    1. systemctl status [email protected]
    2. systemctl status [email protected]
    3. systemctl status eventlircd
    4. journalctl -a | paste


    It could be that we have another race between eventlircd and kodi grabbing the event input device. If kodi grabs it before eventlircd the button presses should show up as keyboard input instead of LIRC input in kodi.log and systemctl status eventlircd will contain an error message that the input device has already been grabbed by another process. So far I haven't seen this in the wild but could provoke it manually by stopping and then starting eventlircd while kodi is running.


    so long,


    Hias
    [hr]
    Please check another thing in addition to the stuff I just posted:


    With lsof and grep we can quickly verify who grabbed which input device. So if there's a race between kodi and eventlircd we should be able to verify it:


    First find out which event device is which physical/virtual device:

    Code
    1. LibreELEC:~ # grep . /sys/class/input/event?/device/name
    2. /sys/class/input/event0/device/name:Logitech K400
    3. /sys/class/input/event1/device/name:lircd-uinput
    4. /sys/class/input/event2/device/name:eventlircd


    Now run lsof to see which process is using which input device:

    Code
    1. LibreELEC:~ # lsof | grep /dev/input/event
    2. 268     /usr/sbin/eventlircd    /dev/input/event1
    3. 436     /usr/lib/kodi/kodi.bin  /dev/input/event0
    4. 436     /usr/lib/kodi/kodi.bin  /dev/input/event2


    Here we see that kodi is using event0 (my logitech keyboard) and event2 (eventlircd, for receiving BTN_events) while eventlircd is reading from lircd-uinput. That's fine so far.


    But if I restart eventlircd while kodi is running kodi will grab the lircd-uinput device, and eventlircd can't grab it and errors out. So eventlircd is bypassed.

    Code
    1. LibreELEC:~ # systemctl stop eventlircd
    2. LibreELEC:~ # systemctl start eventlircd
    3. LibreELEC:~ # lsof | grep /dev/input/event
    4. 436     /usr/lib/kodi/kodi.bin  /dev/input/event1
    5. 436     /usr/lib/kodi/kodi.bin  /dev/input/event0


    And we can see eventlircd status is failed:


    Of course we shouldn't manually restart eventlircd while kodi is running as this will provoke issues - this was just to illustrate the error scenario that could happen when there's a race between eventlircd and kodi grabbing the lircd-uinput device.


    so long,


    Hias

    Edited once, last by HiassofT ().

  • Topic: no starting [email protected] boot


    journalctl: gCYh