Forum > Openelec
bir8339e 看全部
2016-10-12 23:02:46
The only thing missing for me on OE on a NanoPI-M1 (identical to the OPi One) was being able to wake up the board with the IR remote (a brandless one I bought on Ebay). The procedure I used to set it up was as follows:

1. Setup lirc as indicated on the FAQ. Make sure you set up the POWER button on your remote to the KEY_SLEEP code.
2. At this point you should be able to put the board to sleep using the POWER button on the remote, but will need to press the K1 button on the board to wake it up.
3. Power off the board and put the SD card on your work computer. I'm using Kubuntu on it but anything Linux will do (not sure the FEX tools needed are available for Windows).
4. The SD card has two partitions on it; one 512 MB (system) and another larger one (OE data). Mount both on your system; on mine they show up under /media/<username>/<id>.
5. Open your lircd.conf file at /media/<username>/<id of larger partition>/.config. This is an excerpt of mime:


  1. begin remote

  2.   name  /storage/.config/lircd.conf
  3.   bits           16
  5.   eps            30
  6.   aeps          100

  7.   header       9032  4520
  8.   one           546  1709
  9.   zero          546   583
  10.   ptrail        546
  11.   repeat       9032  2266
  12.   pre_data_bits   16
  13.   pre_data       0x205D
  14.   gap          141638
  15.   toggle_bit_mask 0x0

  16.       begin codes
  17.           KEY_SLEEP                0x38C7

6. It was reported that the ARISC firmware only recognizes NEC encoding from the remote. Assuming that, you must generate the correct values, as expressed in NEC encoding, to put on the script.bin file so that the POWER key can be decoded by the ARISC processor built-in to the H3. A NEC-encoded button press has the following format:

  • a 9ms leading pulse burst (16 times the pulse burst length used for a logical data bit)
  • a 4.5ms space
  • the 8-bit address for the receiving device (A1)
  • the 8-bit logical inverse of the address (A2)
  • the 8-bit command (B1)
  • the 8-bit logical inverse of the command (B2)
  • a final 562.5µs pulse burst to signify the end of message transmission.

  • Logical '0' – a 562.5µs pulse burst followed by a 562.5µs space, with a total transmit time of 1.125ms
  • Logical '1' – a 562.5µs pulse burst followed by a 1.6875ms space, with a total transmit time of 2.25ms

The values A2 and B2 should be the logical inversion (0->1, 1->0) of A1 and B1, respectively, but most remotes use both A1 and A2 to differentiate model and make.
7. Looking at the values on lircd.conf you may notice that the 'header', 'one' and 'zero' keys have values that approximately match the NEC encoding; 'header' is the 9ms leading pulse + the 4.5ms space and 'one' and 'zero' also match the symbols for 0 and 1. If that's the case the remote is compatible enough to the NEC encoding to use.
8. Now convert your 'script.bin' file to textual representation with this:


  1. bin2fex /media/<username>/<id of 512MB partition>/script.bin ~/script.fex

9. Open the 'script.fex' file and look for a line with '[s_cir0]'. Below it you'll find several pairs 'ir_power_key_code<order> = X' and 'ir_addr_code<order> = Y', being 'order' consecutive numbers starting from 0 and X/Y being the codes as seen by the ARISC firmware. But those codes are bit-reversed in regards to the lirc definitions. So Y is the same as 'pre_data' but bit-reversed' like this:

pre_data = 0x205D = 0010 0000 0101 1101 => (bit-reversed) => 1011 1010 0000 0100 = 0xBA04 = Y

Given that the key code is sent as a code and its logical inversion you'll notice that the code for the POWER key is composed of one byte (0x38) and its inverse (0xC7). So X should be the bit-reversal of the top 8 bits of the word like this:

KEY_SLEEP = 0x38C7 => code = 0x38 = 0011 1000 => (bit-reversed) => 0001 1100 = 0x1C = X

10. Add those codes to the [s_cir0] section, either by adding a new pair (make sure the order is consecutive and without duplicate numbers) or by just removing all existing pairs and adding this new one. I did it the second way and ended up with a section like this:


  1. [s_cir0]
  2. ir_used = 1
  3. ir_rx = port:PL11<2><1><default><default>
  4. ir_power_key_code0  = 0x1C
  5. ir_addr_code0       = 0xBA04

11. Now convert the FEX file back using this:


  1. fex2bin ~/script.fex /media/<username>/<id of 512MB partition>/script.bin

12. Un-mount the partitions, put the SD card back on the board and enjoy.

NOTE: If your lircd.conf file has the same values as mine on the 'bits' and  'pre_data_bits' you can follow the procedure above. If not you'll have to adapt it knowing that lirc records the bitstream frame from the remote like this:

<header> <plead> <pre_data> <pre> <data> <post> <post_data> <ptrail> <foot> <gap>

The default value (if missing from lircd.conf) for these keys is 0 and while 'pre_data' and 'post_data' are actual values from the bitstream the rest of the keys are durations in uS. As long as the values for 'header', 'one' and 'zero' are similar to mine it should be just question of finding out how to map the actual frame from the remote as detailed on lircd.conf into a NEC encoding as explained above.

c0013r 看全部
2018-1-22 19:27:46


Levitsky86 replied at 2018-1-19 01:22
Can someone answer me, please???

You read forum?
LibreElec 03/2017 - power off
LibreElec 02/2017 - suspend
OpenElec 02/2017 - suspend
PS: yes, have problem with wi-fi(MT7601) after wake up, use wired LAN port - work correct after wake up.
jernej 看全部
2017-1-10 05:14:37
Your conversion is ok, except one slight detail. pre_data_bits is 16, which meanst you have to take into account 16 bit value not 8 bit.
Try with this conversion:
0x00BF => 0xFD00


  1. [s_cir0]
  2. ir_used = 1
  3. ir_power_key_code0  = 0x12
  4. ir_addr_code0       = 0xFD00
jernej 看全部
2016-10-20 13:26:56


andreq replied at 2016-10-19 23:29
I'd be interested in knowning those other ways as I just installed everything on the build-in emmc ...

First make flash folder writable:


  1. mount -o remount,rw /flash
and then copy script.bin with scp, for which you have to have ssh enabled. For example, on host PC for command line tool on Linux:


  1. scp script.bin root@
For Windows, there is graphical tool WinSCP.

jernej 看全部
2016-10-15 18:23:24

although I didn't try your HOWTO yet, I'm glad that you figure it out. I spent quiet some time on this issue without any success. I will link your post in FAQ.
c0013r 看全部
2016-10-15 21:24:08
Yes, this work, thank you.
Dima 看全部
2016-10-15 23:47:00
Thank you for the awesome guide. I'll try to check if I can get this working on Windows 10 with bash.
jernej 看全部
2016-10-16 20:57:42
I also confirm that it is working. Small addition: it is not required to set power button to "KEY_SLEEP", for me it also works set to "KEY_POWER".  fex2bin and bin2fex are now also inside OE, but there is no image yet released with those tools. It will be in next release.
1234.. 12NextPage

OrangePi En

Powered by Discuz! X3.4

homepage|Simple edition|Touch edition|PC