Tuesday, March 5, 2019

Install font to LibreELEC or OpenELEC

How to install new font to LibreELEC or OpenELEC

Login with root to LibreELEC or OpenELEC.

# mkdir -p /storage/.xbmc/media/Fonts
or
# mkdir -p /storage/.kodi/media/Fonts

Upload truetype font to this path.

Reboot again.


Monday, February 11, 2019

Control a cooling fan with gpio-fan (Device Tree Overlays)

I want to setup a cooling fan and enable it at temperature greater then 55 °C.
I found gpio-fan on device tree overlays.

Name:   gpio-fan
Info:   Configure a GPIO pin to control a cooling fan.
Load:   dtoverlay=gpio-fan,<param>=<val>
Params: gpiopin                 GPIO used to control the fan (default 12)
        temp                    Temperature at which the fan switches on, in
                                millicelcius (default 55000)
Reference: https://github.com/raspberrypi/firmware/tree/master/boot/overlays

Step to Setup

1. Setup a cooling fan and NPN transistor (S8050).

Reference:



2. Add config device tree overlays on /boot/config.txt.

dtoverlay=gpio-fan,gpiopin=12,temp=55000
 temp = 55000 is millicelcius

3. Restart Raspberry PI

After reboot success.

Hope you enjoy with it.



If you don't want to use gpio-fan overlay.

Create file on /home/pi/bin/temp_montior

#!/bin/bash

GPIO_PIN=12

HIGH_TEMP=50000
SAVE_TEMP=45000

function get_temp() {
  cat /sys/class/thermal/thermal_zone0/temp
}

function gpio_enable() {
  echo $1 > /sys/class/gpio/export
}

function gpio_disable() {
  echo $1 > /sys/class/gpio/unexport
}

function gpio_set_output() {
  echo out > /sys/class/gpio/gpio$1/direction
}

function gpio_set_input() {
  echo in > /sys/class/gpio/gpio$1/direction
}

function gpio_set_on() {
  echo 1  > /sys/class/gpio/gpio$1/value
}

function gpio_set_off() {
  echo 0 > /sys/class/gpio/gpio$1/value
}

function cleanup() {
  QUIT=1
}

QUIT=0

#echo "Enable GPIO ${GPIO_PIN}"
gpio_enable $GPIO_PIN

#echo "Set GPIO ${GPIO_PIN} Output"
gpio_set_output $GPIO_PIN

#echo "set GPIO ${GPIO_PIN} on"
#gpio_set_on $GPIO_PIN

LASTSTATUS=0


trap cleanup SIGINT SIGTERM

while [ 1 ]; do
  cputemp=$(get_temp)
  #echo "CPU TEMP = $cputemp"
  if [ $LASTSTATUS = 0 ]; then
    if [ $cputemp -gt $HIGH_TEMP ]; then
      echo "FAN ON"
      echo "CPU TEMP = $cputemp"
      gpio_set_on $GPIO_PIN
      LASTSTATUS=1
    fi
  else
    if [ $cputemp -lt $SAVE_TEMP ]; then
      echo "FAN OFF"
      echo "CPU TEMP = $cputemp"
      gpio_set_off $GPIO_PIN
      LASTSTATUS=0
    fi
  fi
  if [ "$QUIT" = "1" ]; then break; fi
  sleep 1
done

#echo "set GPIO ${GPIO_PIN} off"
gpio_set_off $GPIO_PIN

#echo "Disable GPIO ${GPIO_PIN}"
gpio_disable $GPIO_PIN


Change mode for execute file

$ chmod 755 /home/pi/bin/temp_montior

Add this script to startup.
Edit /etc/rc.local and add line before exit 0

$ sudo nano /etc/rc.local

...
/home/pi/bin/temp_monitor &
...
exit0

You can change GPIO_PIN, HIGH_TEMP and SAVE_TEMP for gpio pin, start and stop fan





Tuesday, September 25, 2018

Shutdown Button with Device Tree Overlays

I want to create shutdown button for raspberry pi.
I found gpio-shutdown parameter for enable Device Tree Overlays on new firmware.

Name:   gpio-shutdown
Info:   Initiates a shutdown when GPIO pin changes. The given GPIO pin
        is configured as an input key that generates KEY_POWER events.
        This event is handled by systemd-logind by initiating a
        shutdown. Systemd versions older than 225 need an udev rule
        enable listening to the input device:

                ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \
                        SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \
                        ATTRS{keys}=="116", TAG+="power-switch"

        This overlay only handles shutdown. After shutdown, the system
        can be powered up again by driving GPIO3 low. The default
        configuration uses GPIO3 with a pullup, so if you connect a
        button between GPIO3 and GND (pin 5 and 6 on the 40-pin header),
        you get a shutdown and power-up button.
Load:   dtoverlay=gpio-shutdown,<param>=<val>
Params: gpio_pin                GPIO pin to trigger on (default 3)

        active_low              When this is 1 (active low), a falling
                                edge generates a key down event and a
                                rising edge generates a key up event.
                                When this is 0 (active high), this is
                                reversed. The default is 1 (active low).

        gpio_pull               Desired pull-up/down state (off, down, up)
                                Default is "up".

                                Note that the default pin (GPIO3) has an
                                external pullup.
Reference: https://github.com/raspberrypi/firmware/tree/master/boot/overlays


Step to create shutdown switch

  • Connect switch to GPIO3.





  • Add config device tree overlays on /boot/config.txt.


dtoverlay=gpio-shutdown,gpio_pin=3,active_low=1,gpio_pull=up


  •  Create file /etc/udev/rules.d/99-gpio-power.rules


ACTION!="REMOVE", SUBSYSTEM=="input", KERNEL=="event*", \
                        SUBSYSTEMS=="platform", DRIVERS=="gpio-keys", \
                        ATTRS{keys}=="116", TAG+="power-switch"


  • And restart raspberry pi.


After reboot success. I try to push switch.
It works ;). My raspberry pi is shutdown.

Hope to help you.

*** I2C must be deactivated if you use pin 3. (Thank you @Irmoreno007)

Wednesday, July 25, 2018

Mantistek WA150 (WIFI+Bluetooth) RTL8723BU

I buy Mantistek WA150 to use on Raspberry PI. It has both WIFI and Bluetooth.




The raspbian kernel version 4.14.52+ #1123. It hasn't driver to use it.

I use command.

dmesg

I found. Raspbian can detect bluetooth device but it isn't have firmware. (rtl8723b_fw.bin)

[   14.665558] bluetooth hci0: Direct firmware load for rtl_bt/rtl8723b_config.bin failed with error -2
[   14.665824] bluetooth hci0: Direct firmware load for rtl_bt/rtl8723b_fw.bin failed with error -2
[   14.665842] Bluetooth: hci0: Failed to load rtl_bt/rtl8723b_fw.bin

I use command for check usb device id.

lsusb
I found.
Bus 001 Device 004: ID 0bda:b720 Realtek Semiconductor Corp.

The USB Device ID is 0bda:b720.

I search device id for identify device. I found RTL8723BU (not RTL8723AU).

I found driver and firmware.

 WIFI Driver (Source code)


Bluetooth Firmware



Install Step
First step. Install linux kernel header package and other package for raspbian.
$ sudo apt-get install raspberrypi-kernel-headers git build-essential

Create directory for build source and download source code

$ mkdir drivers
$ cd drivers

Install RTL8723BU WIFI Driver
$ git clone https://github.com/lwfinger/rtl8723bu.git
$ cd rtl8723bu

Disable Concurrent Mode
$ sed -i "s/^EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE/#EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE/g" Makefile

Build and Install
$ make
$ sudo make install

Disable power save
$ echo "options 8723bu rtw_power_mgnt=0 rtw_enusbss=0" | sudo tee /etc/modprobe.d/8723bu.conf

Install RTL8723B Bluetooth Driver

$ git clone https://github.com/lwfinger/rtl8723au_bt.git
$ cd rtl8723au_bt/Linux_BT_USB_2.11.20140423_8723BE/8723B
sudo cp rtl8723b_config /lib/firmware/rtl_bt/rtl8723b_config.bin
sudo cp rtl8723b_fw /lib/firmware/rtl_bt/rtl8723b_fw.bin

And restart raspberry pi

Test bluetooth scan with command.

$ hcitool scan
Scanning ...
          XX:XX:XX:XX:XX:XX       xxxxxx
          XX:XX:XX:XX:XX:XX       xxxxxx

It work.

And check WIFI interface with command.

$ ifconfig

It work. I found wlan0 interface.

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 17  bytes 0 (0.0 B)
        RX errors 0  dropped 80  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

And try to config wpa_supplicant-wlan0.conf for wlan0 interface

$ echo -e "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\ncountry=TH\n\n" | sudo tee /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
 Add SSID and Password of Accesspoint to wpa_supplicant config file
wpa_passphrase test 12345678 | sudo tee -a /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

And restart raspbian. Finish step.

Have a good day everyone. 😎



Reference:
WIFI Driver (Source code)
Bluetooth Firmware
Realtek RTL8723BU


Wednesday, October 11, 2017

motionEyeOS (Raspberry PI) push video and image to dropbox

motionEyeOS can send video and image to cloud storage (Google Drive and Dropbox)

This topic will storage them to Dropbox.


  • Login to motionEyeOS

  • Select File Storage Section
  • Enable Upload Media Files, Upload Pictures and Upload Movies
  • On Upload Service. Select Dropbox.
  • On Location. Select Folder on Dropbox for save video and image. (If don't have folder, go to dropbox create new folder before config motionEyeOS)

  • Click on Obtain Key. It will go to Dropbox for generate Authorization key.

  • Allow Authorization. and copy Authorization key.
  • Enter Authorization key on Authorization key form and click Test service button
  • After success. click on apply for save all config. 


If you enable Motion Detection for record video or save images, after record finish or save images finish. It will push video and image push to Dropbox automatic.

Hope you enjoy with it. 😊

Tuesday, October 10, 2017

motionEyeOS (Raspberry PI) notification via LINE Notify

motionEyeOS (CCTV Software)

motionEyeOS is A Video Surveillance OS For Single-board Computers



motionEyeOS Source: https://github.com/ccrisan/motioneyeos
motionEye Source: https://github.com/ccrisan/motioneye

Download motionEyeOS Image: https://github.com/ccrisan/motioneyeos/releases

motionEyeOS Wiki: https://github.com/ccrisan/motioneyeos/wiki

How to install can see at Raspberry PI Spy (https://www.raspberrypi-spy.co.uk/2017/04/raspberry-pi-zero-w-cctv-camera-with-motioneyeos/)


LINE Instant Messager

LINE Notify Service: https://notify-bot.line.me/en/


  • Login with LINE Account

  • Select menu My page




  • Select Generate Token button

  • Enter token name and select 1-on-1 chat with LINE Notify or Group for send notification
  • Select Generate Token button

  • I will show token for send notification. copy it. and select close button

  • In LINE Instant Messenger will have LINE Notify Account add to you.  


Test send notify with curl
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F 'message=hello' https://  
notify-api.line.me/api/notify
After run this curl command. You will receive message 'Hello' to LINE Instant Messenger via LINE Notify



If you want to send Message and Image to LINE Instant Messager, you can curl with this command.

curl -k -X POST -H 'Authorization: Bearer [access_token]' -F 'message=hello' -F 'imageFile=@[**file path to image]' https://  
notify-api.line.me/api/notify
**file path to image = Image file Supported image format is png and jpeg
Image will upload to server for send notification.



More Information
LINE Notify API Document: https://notify-bot.line.me/doc/en/
LINE Engineer Blog: https://engineering.linecorp.com/en/blog/detail/88


Create script for send notification on motionEyeOS

  • create directory /data/script with command
mkdir /data/script
  • create shell script
File: /data/script/linenotify_push.sh

#!/bin/bash
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F "message=$1" https://
notify-api.line.me/api/notify

File: /data/script/linenotify_pushimage.sh

#!/bin/bash
curl -k -X POST -H 'Authorization: Bearer [access_token]' -F "message=$1" -F "imageFile=@$2" https://
notify-api.line.me/api/notify

  • change mode of file to executable file.

chmod 755 linenotify_push.sh
chmod 755 linenotify_pushimage.sh

Test script file


/data/script/linenotify_push.sh "Good world"

It will receive "Good world" message at LINE Instant Message

/data/script/linenotify_pushimage.sh "Good Job" "/data/output/Camera1/test.jpg"

It will receive "Good Job" message and test.jpg image at LINE Instant Message.

Now. You can run script for sent notification.


Use notification script at motionEyeOS

  • Login on motionEyeOS

  • Go to Motion Notifications section

  • Enable Run A Command (Send notification if motionEyeOS detect motion on camera)
  • On command box enter command

/data/script/linenotify_push.sh "Motion Detect at %Y-%m-%d %H-%M-%S"


  • (Option) If you want to send notification after finish motion detect, Enable Run An End Command and  enter command.

/data/script/linenotify_push.sh "Motion Detect End at %Y-%m-%d %H-%M-%S"


  • If you want to send image of motion detect, go to Still Images section.
  • Select capture mode to Motion Triggered or Motion Triggered (One Picture).

  • go to File storage.
  • Enter command on Run An Command 
/data/script/linenotify_push.sh "Motion Detect at %Y-%m-%d %H-%M-%S" %f

  • go to Motion Detection Section. Enable Motion Detection


  • Select Apply button on top to apply all config.


If motion detect of motionEyeOS detected, I will send "Motion Detect at [Date and Time]" message to LINE Instant Message.

After finish with motion detect (nothing movement) Send "Motion Detect End at [Date and Time]" message to LINE Instant Message.

and Send "Motion Detect at [Date and Time]" message " and image file to send to LINE Instant Message



Wednesday, May 25, 2016

Waveshare 7inch HDMI LCD (C) and 5inch HDMI LCD (B) on NOOBS

HDMI LCD

Waveshare 7 inch HDMI LCD (C)

Waveshare 5 inch HDMI LCD (B)


NOOBS (Raspberrry PI)


First write NOOBS Image to SD Card.
After finished.

Create file config.txt on NOOBS SDCard. (It don't have config.txt on NOOBS image)

config.txt  (for 7 inch HDMI LCD (C))

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
# 1024 x 600
hdmi_cvt 1024 600 60 6 0 0 0
max_usb_current=1
If you use the LCD with Raspberry Pi 4 B, you need to remove the line dtoverlay=vc4-fkms-V3D from config.txt file

Wiki for 7 inch HDMI LCD (C)
http://www.waveshare.com/wiki/7inch_HDMI_LCD_%28C%29

config.txt (for 5 inch HDMI LCD (B))

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
#800x480
hdmi_cvt 800 480 60 6 0 0 0
max_usb_current=1
Save it. and eject from computer.
Try to boot with Raspberry PI to test it.




All image on NOOBS should change config.txt for support this HDMI LCD Device.

Enjoy ;)


Reference:
NOOBS (Raspberrry PI)

Friday, March 25, 2016

Live TV DVB-T2 with VDR Addons on OpenELEC

I have Geniatech DVB-T2 Stick T220.
I use OpenELEC to play Live TV with it.



Current version of OpenELEC is 6.0.3.

First install services add-ons VDR PVR Backend.
Goto: System -> Settings -> Add-ons -> Install from repository -> OpenELEC Add-ons (offical) -> Services -> VDR PVR Backend



Install VDR PVR Backend

After Installed. Go back to PVR clients.

Install VDR VNSI Client (If VDR VNSI Client is not installed)

Select Configure of VDR VNSI Client.

Enable create channel groups automatically on the server And OK.

Next Goto Home -> Programs -> VDR Configuration


Select Channel scanner Configuration


Start scanning TV channel.
Select 
  • Tuner Type: DVB-T
  • Country: <your location>
  • Cleanup all
And Start


After scan completed. Select Close.

Enable TV menu on OpenELEC
Goto: Home -> System -> Settings -> TV

Select Enable:  General -> Enabled and Synchronis channel groups with backend(s)


Go back to Home and Select TV

Now already to watch Live TV from DVB-T2 Device and recording.

Have a good day. :)


Addition:

VDR PVR Backend has other plugins to use.
You can enable on configure menu.

Goto: Home -> System -> Settings -> Add-ons -> Install from repository -> OpenELEC Add-ons (offical) -> Services -> VDR PVR Backend

Select Configure.

You can enable other plugins if you want to use.



Reference:
VDR - The Video Disk Recorder

VDR Wiki

Monday, October 5, 2015

How to compile nginx with nginx-rtmp-module

Prepare environment for compile.
$ sudo apt-get update
$ sudo apt-get install libpcre3-dev libatomic-ops-dev libgeoip-dev geoip-bin geoip-database geoip-database-extra libperl-dev libssl-dev libxml2-dev libxslt1-dev

Create directory src

$ mkdir src

Download Nginx (last version)

$ cd src
$ wget http://nginx.org/download/nginx-1.9.5.tar.gz
$ tar -xvzf nginx-1.9.5.tar.gz

Git Clone nginx-rtmp-module

$ git clone https://github.com/arut/nginx-rtmp-module.git


Change current to nginx-1.9.5

$ cd nginx-1.9.5

Run configure

$ ./configure --prefix=/usr/local/nginx --user=www-data --group=www-data --with-select_module --with-poll_module --with-threads --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module  --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-md5-asm --with-sha1-asm --with-libatomic --with-pcre --with-stream --with-stream_ssl_module --with-http_v2_module --add-module=../nginx-rtmp-module

Run make to compile

$ make

Install nginx to /usr/local/nginx

$ sudo make install

Config Nginx on /usr/local/nginx/conf/nginx.conf

$ sudo nano /usr/local/nginx/conf/nginx.conf


Config for streaming server see on nginx-rtmp-module wiki

Web path /usr/local/nginx/html

Start nginx service

$ sudo /usr/local/nginx/sbin/nginx

Stop nginx service

$ sudo /usr/local/nginx/sbin/nginx -s stop


Reference
Nginx

nginx-rtmp-module (source code)

nginx-rtmp-module (wiki)

Streaming with nginx-rtmp-module


Wednesday, September 30, 2015

How to Disable Power Management of rtl8192cu

Fix problem wireless disconnect and go to save mode.

Create file /etc/modprobe.d/8192cu.conf

$ sudo nano /etc/modprobe.d/8192cu.conf

add this line

options 8192cu rtw_power_mgnt=0 rtw_enusbss=0


Restart raspberry pi



Reference :

https://github.com/xbianonpi/xbian/issues/217

https://github.com/pvaret/rtl8192cu-fixes/blob/master/8192cu-disable-power-management.conf

DLNA/UPnP with MiniDLNA

How to build DLNA/UPnP Server on Raspberry PI for use at Home device.
(Example TV, Media player, PS3, Xbox etc.)


Install minidlna package

$ sudo apt-get install minidlna


Add pi user to minidlna group

$ sudo usermod -a -G minidlna pi

Create Directory for store media file

Example:

$ mkdir -p /home/pi/minidlna/music
$ mkdir -p /home/pi/minidlna/pictures
$ mkdir -p /home/pi/minidlna/videos
$ mkdir -p /home/pi/.minidlna

Change Mode of /home/pi/minidlna and /home/pi/.minidlna
$ sudo chmod 777 /home/pi/minidlna
$ sudo chmod 777 /home/pi/.minidlna

Config MiniDLNA

$ sudo nano /etc/minidlna.conf

Modify this file
...
db_dir=/home/pi/.minidlna/data
log_dir=/home/pi/.minidlna/data/log
# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos)
media_dir=A,/home/pi/minidlna/music
media_dir=P,/home/pi/minidlna/pictures
media_dir=V,/home/pi/minidlna/videos
# Name that the DLNA server presents to clients.
friendly_name=RASPBERRY DLNA
# Automatic discovery of new files in the media_dir directory.
inotify=yes
# Notify interval, in seconds.notify_interval=895...

Restart MiniDLNA Service

$ sudo /etc/init.d/minidlna restart

Or re-indexing all of media files

$ sudo /etc/init.d/minidlan force-reload



Test on Device supported with DLNA/UPnP to play media.




Reference:

Digital Living Network Alliance
https://en.wikipedia.org/wiki/Digital_Living_Network_Alliance

ReadyMedia (MiniDLNA Source Code)
http://sourceforge.net/projects/minidlna/

ReadyMedia (Wiki of Archlinux)
https://wiki.archlinux.org/index.php/ReadyMedia

Tuesday, August 11, 2015

How to use own remote control for LibreELEC or OpenELEC

IR Receiver (TSOP44.., TSOP48.., TSOP38238, ...)


Connect IR Receiver to Raspberry Pi

Vcc -> 3V
GND -> GND
Vout -> GPIO 18









Load LIRC module on boot.
Edit /boot/config.txt
Add line

dtoverlay=lirc-rpi
***For new kernel***
dtoverlay=gpio-ir


or (change GPIO pin in for IR Receiver)
dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=18
*** For new kernel ***
dtoverlay=gpio-ir,gpio_pin=18,gpio_pull=up
See on :


Learning own remote control

Kill Process of LIRCD

# killall lircd

Start learning remote control button.

# irrecord /storage/.config/lircd.conf

irrecord -  application for recording IR-codes for usage with lirc

Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)

This program will record the signals from your remote control
and create a config file for lircd.


A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION of this package, especially section "Adding new remote
controls" for how to get help.

If there already is a remote control of the same brand available at
http://www.lirc.org/remotes/ you might also want to try using such a
remote as a template. The config files already contain all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available in the remotes/generic/ directory of the source
distribution of this package. You can use a template files by
providing the path of the file as command line parameter.

Please send the finished config files to  so that I
can make them available to others. Don't forget to put all information
that you can get about the remote control in the header of the file.

Press RETURN to continue.


Now start pressing buttons on your remote control.

It is very important that you press many different buttons and hold them
down for approximately one second. Each button should generate at least one
dot but in no case more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have been
generated.

Press RETURN now to start recording.

................................................................................
Found const length: 107201
Please keep on pressing buttons like described above.
................................................................................
Space/pulse encoded remote control found.
Signal length is 67.
Found possible header: 8951 4451
Found trail pulse: 572
Found repeat code: 8961 2214
Signals are space encoded.
Signal length is 32
Now enter the names for the buttons.

Please enter the name for the next button (press  to finish recording)
KEY_POWER

Now hold down button "KEY_POWER".

Please enter the name for the next button (press  to finish recording)
KEY_1

Now hold down button "KEY_1".

Please enter the name for the next button (press  to finish recording)
KEY_2

Now hold down button "KEY_2".

Please enter the name for the next button (press  to finish recording)
KEY_3

Now hold down button "KEY_3".

Please enter the name for the next button (press  to finish recording)
...


If you want to know irrecord key and button name list, use this command.

# irrecord --list

It will display list of key and button name.

IR Remote Key on Raspberry PI (See on file /etc/lirc/lircd.conf.rpi)

KEY_POWER
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_0
KEY_VOLUMEUP
KEY_VOLUMEDOWN
KEY_MUTE
KEY_EXIT
KEY_CHANNELUP
KEY_CHANNELDOWN
KEY_INFO
KEY_UP
KEY_LEFT
KEY_RIGHT
KEY_DOWN
KEY_OK
KEY_MENU
KEY_AUDIO
KEY_VIDEO
KEY_BACKSPACE
KEY_PLAY
KEY_PAUSE
KEY_FORWARD
KEY_STOP
KEY_RADIO
KEY_TEXT
KEY_TITLE
After finish all key. Press Enter for finished.

(If you type incorrect or some problem about step, delete file /storage/.config/lircd.conf and run irrecord command)

Reboot.

# shutdown -r now

Test IR Remote for control menu.



Reference :

Device Tree overlays
https://github.com/raspberrypi/firmware/tree/master/boot/overlays

Guide To lirc rpi GPIO Receiver
http://wiki.openelec.tv/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver

Guide to add your own remote
http://wiki.openelec.tv/index.php/Guide_to_add_your_own_remote