Add support for a new IR remote controller


Thanks Terry,

After ordering my Khadas VIM yesterday I was wondering about IR.

Now it will be fine.


@terry thank you for the steps how this can be achieved.

But will this be also included in official Rom?


I don’t know the IR scancode of user , It need the user to build the rom by himself
It isn’t included in official Rom.


But can at least the new ROM have option from steps 1) and 2), so an user can provide you scancode for each key and then provided to you so you can include it in next build?

  1. and 2)
    where the record of scancode can be captured? Is it written in log file (which)?


The type of IR is different for each of user , It is too hard to support the all IR .
I’m sorry for it, please understanding.

You need to type below command on Terminal

$ adb connect  IP
$ adb shell 
$ dmesg 


  1. The IP is the ip addr of Vim
  2. Before type the ‘dmesg’ , You need to click your IR



But the debug code have nothing to do with remote, if you include these debug code in the official ROM then everyone can contribute his scancode. Right now even ti get scancode one need ti compile his own ROM and flash.


@terry and all:
I git clone kernel source code form khadas github , and modify this file: arch/arm64/boot/dts/amlogic/mesongxl.dtsi, my question is how can I compile for this modify???

I have try :1. make clean ARCH=arm64 && make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- , but it cannot compiled mesongxl.dtsi(I add some error in this file)
2. run this command: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- kvim.dtb , it can generate arch/arm64/boot/dts/amlogic/kvim.dtb, but I have no idea about how to package it to kernel image(Image)


What kind of system do you want to test? Ubuntu or Andoird7.1?
You can download the kvim.dtb to your device Load Images with U-Boot via TFTP


Hi @terry:
It works!
I try it with ubuntu mate
But I wondering if there have any method to package it to kernel image? because this is only for debug mode, thanks!


It hasn’t the method to pack dtb to kernel image because the dtb and kernel is two different partitions. But you can pack the dtb and kernel into final update image.


Hi @terry:
beacuse dts file is in kernel path, I used to think it would be package into kernel image.
But how can I do this? and I have no ubuntu source code for khadas vim.


About How to build and pack Ubuntu image,you can refer to the post


@terry help me add wake up key in uboot .
My remote : factory_code = 0xef10 , and scancode power key = 0x5d


here will change this value 0xeb5def10 ? , how to make it work?


Firstly, You need to know the 16bit scancode and not 8bit.
What’s the version of your system? Nougat or Mmallow?

  • On Nougat:
    You need to remove your Remote configs in mesongxm.dts(VIM2) or mesongxl.dts(VIM)file.
  • On Mmallow
    You need to remove your Remote configs in remote.conf file

Now, you can see the kernel log when you click your Remote power key.

kvim2:/ $ [  379.901297@1] meson-remote c8100580.rc: invalid custom:0xeb14ff00


khadas IR power key: factory_code = 0xFF00, scancode = 0xEB14


Hey I know this is not really related but your post was the best I found to fix my problem. I have a dtb file that I decompiled so I can add my remote and then recompile but I need to know the result of the macro REMOTE_KEY because it doesnt let me compile when I have “keymap = <REMOTE_KEY(0x18,116)>;” I think I need the actual hex value. Can you help me?


You can look at this

You can define your remote key like this
"keymap = <REMOTE_KEY(0x18,KEY_POWER)>;"


Hello, terry. I am trying this on my VIM2 but cannot make the IR work. I use dmesg to get the IR scancode. I got something like this. I flashed the VIM2_Nougat_V180209 firmware. Any help?
meson-remote c8100580.rc: invalid custom:0xbb44fb04
My IR remote keys show below.
0xe619fb04 V-
0xba45fb04 V+
0xa25dfb04 Menu
0xe01ffb04 Home
0xf50afb04 Return
0xe41bfb04 Mouse
0xbb44fb04 UP
0xe21dfb04 DOWN
0xe31cfb04 LEFT
0xb748fb04 RIGHT
0xa35cfb04 OK
0xec13fb04 1
0xef10fb04 2
0xee11fb04 3
0xf00ffb04 4
0xf30cfb04 5
0xf20dfb04 6
0xf40bfb04 7
0xf708fb04 8
0xf609fb04 9
0xb847fb04 0
0xac53fb04 SETTING
0xe51afb04 POWER


The dts file for VIM is ‘PROJECT/common/arch/arm64/boot/dts/amlogic/mesongxl.dtsi’, but VIM2 is 'PROJECT/common/arch/arm64/boot/dts/amlogic/mesongxm.dtsi’
Have a try again. Thanks.


Hi @terry . Can we use remote.conf file on nougat? I think that has more options than device-tree. For example defining (repeat-key) is a nice option which I don’t know how to configure via device-tree.

(my device now has no repeat function so a bad UX. When you hold right key it only moves one step!)


Everyone can easily derive 16 bit scancode by logic inverting the 8 bit and prepend to it. Note 0xEB is inverse of 0x14 !
See amlogic doc for remote at :