Support Custom Remote Controller with Ubuntu 18.04
- [step 1] Install LIRC Package
- [step 2] Configuring LIRC and driver module
- [step 3 (1)] Case 1 : Registering Hardkernel remote controller
- [step 3 (2)] Case 2 : Registering custom remote controller
- [step 4] restart lircd service
Install LIRC Package
- target
$ sudo apt-get install lirc
Configuring LIRC and driver module
Now you need to set up lirc_options.conf to specify the configuration to run as a daemon.
- target
$ sudo vi /etc/lirc/lirc_options.conf
lirc_options.conf is generated by default when lirc is installed
and the following parts are needed to modified.
(1) driver and device
driver = default device = /dev/lirc0
(2) module init
[modinit] code = /sbin/modprobe meson-ir
(3) input event
[lircd-uinput] add-release-events = True release-timeout = 50 release-suffix = _EVUP
All necessary configuration is done, you can simply start the service lirc by command line or reboot the device.
- target
$ sudo service lircd restart $ sudo systemctl enable lircd-uinput
Then, you can find lirc0 node under /dev/.
- target
$ ls /dev/lirc* /dev/lirc0
Please note that some parts in lirc_options.conf depend on the toolchain version,
so select the correct conf file among the following references based on your board.
lirc_options.conf
ODROID-C2/N2/C4/HC4
- lirc_options.conf
[lircd] nodaemon = False driver = default device = /dev/lirc0 output = /var/run/lirc/lircd pidfile = /var/run/lirc/lircd.pid plugindir = /usr/lib/aarch64-linux-gnu/lirc/plugins permission = 666 allow-simulate = No repeat-max = 600 #effective-user = #listen = [address:]port #connect = host[:port] #loglevel = 6 #release = true #release_suffix = _EVUP #logfile = ... #driver-options = ... [lircmd] uinput = False nodaemon = False [modinit] code = /sbin/modprobe meson-ir [lircd-uinput] add-release-events = True release-timeout = 50 release-suffix = _EVUP
ODROID-C1
- lirc_options.conf
[lircd] nodaemon = False driver = default device = /dev/lirc0 output = /var/run/lirc/lircd pidfile = /var/run/lirc/lircd.pid plugindir = /usr/lib/arm-linux-gnueabihf/lirc/plugins permission = 666 allow-simulate = No repeat-max = 600 #effective-user = #listen = [address:]port #connect = host[:port] #loglevel = 6 #release = true #release_suffix = _EVUP #logfile = ... #driver-options = ... [lircmd] uinput = False nodaemon = False [modinit] code = /sbin/modprobe meson-ir [lircd-uinput] add-release-events = True release-timeout = 50 release-suffix = _EVUP
If you want to adjust a key release time, please change the value, release-timeout under [lircd-uinput] category.
Registering Hardkernel remote controller
If you use a Hardkernel remote controller, you can use the following lircd.conf.
Or please refer to the next section if you use other remote controllers.
- target
$ sudo vi /etc/lirc/lircd.conf.d/hk.lircd.conf
- hk.lircd.conf
begin remote name odroid bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9000 4500 one 563 1688 zero 563 564 ptrail 563 pre_data_bits 16 pre_data 0x4DB2 repeat 9000 2250 repeat_gap 96187 toggle_bit_mask 0x0 begin codes KEY_LEFT 0x9966 KEY_RIGHT 0x837C KEY_UP 0x53AC KEY_DOWN 0x4BB4 KEY_ENTER 0x738C KEY_HOME 0x41BE KEY_MUTE 0x11EE KEY_MENU 0xA35C KEY_BACK 0x59A6 KEY_VOLUMEDOWN 0x817E KEY_VOLUMEUP 0x01FE KEY_POWER 0x3BC4 end codes end remote
Registering custom remote controller
Before starting irrecord, please check if lircd service is running and stop the service first.
- target
$ sudo service lircd stop
If lircd service is loaded, you will have the following error message from irrecord.
- target
Warning: Running as root. Using driver default on device /dev/lirc0 Could not init hardware (lircd running ? --> close it, check permissions)
Lirc package provide a tool, irrecord, to help registering the buttons of own remote controller. Once the tool is started, for example, you will be asked to press the buttons and it will analyse the signals of your remote controller like protocol type or headers. After this analysis you can start register the buttons one by one.
- target
$ sudo irrecord --device /dev/lirc0 lircd.conf
Once signal analysis is done, you will be asked with the message below to enter the button name to register and press the applicable button. In this step, you can register many buttons as much as you expect to register. If you done, just press enter key on the prompt.
Please enter the name for the next button (press <ENTER> to finish recording)
The tool would ask you more steps to finalize and store the configuration file with the below message.
Successfully written config file.
For example, if you have done whole steps successfully with Hardkernel's stock remote controller, your will have the configuration file like below very similiary.
Now you must copy the configuration file, lircd.conf, to /etc/lirc/ so that lirc service can recognize the button.
- target
$ sudo cp lircd.conf /etc/lirc/lircd.conf.d/hk.lircd.conf
Restart lirc services
Then, you need to restart lircd and lircd-uinput.
- target
$ sudo service lircd restart $ sudo systemctl enable lircd-uinput $ sudo service lircd-uinput restart
How to test
Now, you can run irw to confirm your ODROID-C2 is ready.
- target
odroid@odroid64:~# irw 000000004db29966 00 KEY_LEFT lircd.conf 000000004db2837c 00 KEY_RIGHT lircd.conf 000000004db253ac 00 KEY_UP lircd.conf 000000004db24bb4 00 KEY_DOWN lircd.conf 000000004db2738c 00 KEY_ENTER lircd.conf
You can check if the daemon is running properly.
- target
$ ps -ax | grep lirc root 536 0.0 0.0 4804 1400 ? Ss 09:39 0:00 /usr/sbin/lircmd --nodaemon root 580 0.0 0.0 4720 1296 ? Ss 09:39 0:00 /usr/bin/irexec /etc/lirc/irexec.lircrc root 727 0.1 0.2 7456 4056 ? Ss 09:39 0:00 /usr/sbin/lircd --nodaemon root 728 0.0 0.0 4808 1376 ? Ss 09:39 0:00 /usr/sbin/lircd-uinput odroid 1216 0.0 0.0 2704 664 ttyS0 S+ 09:40 0:00 grep --color=auto lirc
As well as necessary drivers are loaded.
- target
$ lsmod Module Size Used by ir_lirc_codec 4934 3 lirc_dev 10879 1 ir_lirc_codec ir_mce_kbd_decoder 3402 0 ir_jvc_decoder 1725 0 ir_sanyo_decoder 1657 0 ir_sony_decoder 1663 0 ir_rc6_decoder 2010 0 ir_nec_decoder 1789 0 ir_rc5_decoder 1586 0 meson_ir 3356 0