VIM3 customization

Which Khadas SBC do you use?


Which system do you use? Android, Ubuntu, OOWOW or others?

Android (primary) and Ubuntu

Which version of system do you use? Khadas official images, self built images, or others?

Official image

Please describe your issue below:

I can’t find any documentation about VIM3 customization.
I need to create a custom logo (uboot) and add support about custom IR remote.

For the logo, I found that the uboot logo can be access on /dev/block/logo (I will also know how is mapped this device and I can I find the mmc adress to write the logo.img direct from uboot).
I retrived the logo.img direct from the device and I see that inside there are 3 gzip file that contain the bmp. What I need is how to make the logo.img

For the custom IR remote, I learned that I must modify the mesontxl.dtsi and recompile the rom.
I already able to change the dt from uboot with fdt set /custom_maps/map_0 customcode <...>
and see wich code is sended by my remote.
But I miss how to recompile the rom and how to write it into mmc.

I already developed some boards from other vendors and usually the vendor provide some SDK for make these things, but I can’t find any SDK from Khadas, I follow some document under VIM3/3L Development Guide [Khadas Docs] but I can’t find what I need

can you help me to find the right way to develop my custom Khadas VIM3?



For logo customization, please browse the following link documents

thanks!, this is the documentation I looking for, about the logo customization



For the custom IR remote,please browse the following link documents

Hi @xiong.zhang, thanks for your reply.
In this guide I found usefull infos but is not what I looking for.
I will explain what I what to do, I wish to use the integrated IR receiver of the VIM3 (not a custom IR receiver on GPIO) with a custom IR remote commander.
I already able to use my custom IR Commander changing the fdt via u-boot cli with the following commands:

fdt addr ${dtb_mem_addr}
fdt set /custom_maps/map_0 customcode <0x000087ee>
fdt set /custom_maps/map_0 keymap <0x00000074 0x0003008b 0x00110067 0x0015006c 0x00120069 0x0014006a 0x001300e8 0x00400072 0x0003003f 0x0005003f 0x001f0073 0x0009009e 0x000e0066>

After changing the fdt via u-boot I’m able to use my custom IR remote commander according my mappings.
Anyway this modification is temporary and don’t survive across reboot and of course I’m not able to power-on the device after I shutdown it.

What I learned is that I must modify /common/arch/arm64/boot/dts/amlogic/mesongxl.dtsi, add my custom_maps with my customcode and keymap, then recompile the rom.

Everything is clear but I not understand the meaning of these custom_maps parameters:

  • fn_key_scancode
  • fn_key_scancode_other
  • cursor_left_scancode
  • cursor_right_scancode
  • cursor_up_scancode
  • cursor_down_scancode
  • cursor_ok_scancode

If I setup these parameters via u-boot cli the IR remote commander stop working.

Also I miss how to recompile the rom for Android, which source to download and how to write it in the mmc.
Under the Khadas’s git source I founded only the khadas-linux repo that contain the file mesongxl.dtsi but this source should be for recompile the linux kernel, this is the correct source to download?

I started to follow also this guide to download and compile the android source: VIM3/3L Download Android Source Code [Khadas Docs]

But I don’t know if I’m following the right guide because the procedure download a large amount o files (more than 250GB).
There is an smart way to modify the dt without lose days downloading source and recompiling all? maybe just recompile the dts…

thanks in advance for the support


These parameters are the definitions of the up, down, left, right and function keys of the remote control

If you want to fix these changes in the firmware you can only download the source code and compile it, the source code size of VIM3 is more than 300GB

If you don’t download the source code to compile, then the underlying environment can’t be consistent. You know repo, you need to be familiar with it, because if you only need to modify dts, there is a way that is feasible, that is, after pulling the repo, you can change the default Remove all except the kernel branch in .xml, and then use repo sync to synchronize only the kernel part
Execute the following compilation command, it will only compile the part where you modify dts

source build/ && lunch kvim3-userdebug
make dtboimage

Then use the adb command to push the dtbo.img file in the out directory into the device. The premise is that you are quite proficient in using repo

@xiong.zhang, thanks for the infos.

I’m not familiar with repo so I downoaded all source.
After I try to make only the dtbo but the compilation finish with errors:

[  4% 22/501] Yacc: dtc <= external/dtc/dtc-parser.y
external/dtc/dtc-parser.y: conflicts: 3 shift/reduce
[ 99% 499/501] Instaled out/target/product/kvim3/dt.img
FAILED: out/target/product/kvim3/dt.img 
/bin/bash -c "(sed -i 's/^#include \\\"partition_.*/#include \\\"partition_mbox_normal_P_64.dtsi\\\"/' common/arch/arm64/boot/dts/amlogic//kvim3.dts; sed -i 's/^#include \\\"firmware_.*/#include \\\"firmware_system.dtsi\\\"/' common/arch/arm64/boot/dts/amlogic//partition_mbox_normal_P_64.dtsi; if [ -f \"common/arch/arm64/boot/dts/amlogic//kvim3.dtd\" ]; then make -j4 -C common O=../out/target/product/kvim3/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=/opt/toolchains/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- kvim3.dtd; fi; make -j4 -C common O=../out/target/product/kvim3/obj/KERNEL_OBJ ARCH=arm64 CROSS_COMPILE=/opt/toolchains/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- kvim3.dtb ) && (cp device/khadas/common/common_partition.xml out/target/product/kvim3/emmc_burn.xml ) && (./device/khadas/common/ common/arch/arm64/boot/dts/amlogic//partition_mbox_normal_P_64.dtsi  out/target/product/kvim3/emmc_burn.xml ) && (cp -f out/target/product/kvim3/obj/KERNEL_OBJ/arch/arm64/boot/dts/amlogic/kvim3.dtb out/target/product/kvim3/dt.img ) && (if [ -n \"\$(find out/target/product/kvim3/dt.img -size +200k)\" ]; then 		echo \"out/target/product/kvim3/dt.img > 200k will be gziped\"; 		mv out/target/product/kvim3/dt.img out/target/product/kvim3/dt.img.orig && out/host/linux-x86/bin/minigzip -c out/target/product/kvim3/dt.img.orig > out/target/product/kvim3/dt.img; 	fi )"
make: Entering directory '/home/user/.local/src/KHADAS_VIM3_ANDROID/common'
make[1]: Entering directory '/home/user/.local/src/KHADAS_VIM3_ANDROID/out/target/product/kvim3/obj/KERNEL_OBJ'
  GEN     ./Makefile
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --silentoldconfig Kconfig
*** Configuration file ".config" not found!
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
make[3]: *** [/home/user/.local/src/KHADAS_VIM3_ANDROID/common/scripts/kconfig/Makefile:39: silentoldconfig] Error 1
make[2]: *** [/home/user/.local/src/KHADAS_VIM3_ANDROID/common/Makefile:556: silentoldconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'scripts'.  Stop.
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/user/.local/src/KHADAS_VIM3_ANDROID/out/target/product/kvim3/obj/KERNEL_OBJ'
make: *** [Makefile:152: sub-make] Error 2
make: Leaving directory '/home/user/.local/src/KHADAS_VIM3_ANDROID/common'
ninja: build stopped: subcommand failed.
17:46:11 ninja failed with: exit status 1

#### failed to build some targets (01:14 (mm:ss)) ####

So I try to compile first all with command

make -j`nproc` otapackage

The make command made errors again on multiple definition of `yylloc’ but I founded how to fix it.
After if I run again make dtboimage and the command completed without error.
I saw that the make create two files:

  • dt.img
  • dtbo.img

But now I’m little confused about the dtbo and I need some help.
From many forum, about custom IR remote commander, all peoples said that is needed to modify the file _ /common/arch/arm64/boot/dts/amlogic/mesongxl.dtsi.
These are my custom parameters added on the file:

custom_maps:custom_maps {
-               mapnum = <3>;
+               mapnum = <4>;
                map0 = <&map_0>;
                map1 = <&map_1>;
                map2 = <&map_2>;
+               map3 = <&map_3>;
              map_0: map_0{
                mapname = "amlogic-remote-1";
                customcode = <0xfb04>;
@@ -XXX,X +XXX,XX @@
+           map_3: map_3{
+           mapname = "my-remote";
+			customcode = <0xcb04>;
+			release_delay = <80>;
+			size  = <34>;
+			keymap = <REMOTE_KEY(0x41, KEY_1)
+				REMOTE_KEY(0x03, KEY_2)
+				REMOTE_KEY(0x42, KEY_3)
+				REMOTE_KEY(0x45, KEY_4)
+				REMOTE_KEY(0x07, KEY_5)
+				REMOTE_KEY(0x46, KEY_6)
+				REMOTE_KEY(0x55, KEY_7)
+				REMOTE_KEY(0x17, KEY_8)
+				REMOTE_KEY(0x56, KEY_9)
+				REMOTE_KEY(0x1B, KEY_0)
+				REMOTE_KEY(0x06, KEY_UP)
+				REMOTE_KEY(0x05, KEY_FN)
+				REMOTE_KEY(0x5f, KEY_RED)
+		};

Anyway I notice that under dt.img and dtbo.img there isn’t my modifications (I inspected the files with hexdump).
From the inspection of the two files, I notice that dt.img is the file that contain the custom_maps but has only the map_0 with mapname=khadas-ir so I search the source file that contain that string and I find that is in these files:

  • mesonsm1.dtsi
  • mesong12b.dtsi

I modified the two file according my custom settings and then I recompile the dtbo image.
Now the dt.img contain my customization but now I don’t understand this:

Under android there is a block device mapped on the dtbo partition on the mmc but seem that contain the same data of dtbo.img, but from my inspection of the images created the dtbo.img not contain the custom_map of IR but is in the dt.img.
Anyway I tried to upload the dtbo.img, given that I’m not able to use adb to upload the image because I don’t have the board connected via usb but I have only serial access, I tried two method:

  • 1 - directly via android using dd (dd if=dtbo.img of=/dev/block/dtbo) but after restart my IR commander still not working and I noticed that running these command on uboot the custom_maps are not changed:
kvim3#fdt addr ${dtb_mem_addr}
kvim3#fdt print /custom_maps/map_0
map_0 {
        mapname = "khadas-ir";
        customcode = <0x0000ff00>;
        release_delay = <0x00000050>;
        fn_key_scancode = <0x0000005b>;
        cursor_left_scancode = <0x0000000e>;
        cursor_right_scancode = <0x0000001a>;
        cursor_up_scancode = <0x00000003>;
        cursor_down_scancode = <0x00000002>;
        cursor_ok_scancode = <0x00000007>;
        size = <0x0000000d>;
        keymap = <0x00140074 0x0013008b 0x00030067 0x0002006c 0x000e0069 0x001a006a 0x000700e8 0x00580072 0x005c003f 0x005b003f 0x000b0073 0x0001009e 0x00480066>;
        phandle = <0x00000046>;
  • 2 - update the dtbo.img via uboot with usb_upgrade dtbo dtbo.img
    This method fails:
usb_update dtbo dtbo.img
usb_start_count 0
(Re)start USB...
fat]Filesize is 0x1b6B[0M]
[FAT_ERR]L1212,offset(0x0) + wantsz(0x2000) > filesize(0x1b6)
Fail to read file(dtbo.img), readSz=0
ERR(../drivers/usb/gadget/v2_burning/v2_usb_burn/optimus_usb_update.c)L99:Fail when parse file format

The above command work if I use the dt.img instead dtbo.img but the IR commander still don’t work and under uboot if I run the command fdt print ... the parameters of custom_maps still have the factory values.
So I’m confused, I think I must update on the board the dt.img file but I don’t understand how.

thank you in advance for the support…

ninja: build stopped: subcommand failed.

The reason for the error here is that the subcommand is wrong. Please send me the command you compiled.

If you want to compile dtbo.img use the following command

source build/ && lunch kvim3-userdebug
make dtboimage

You should modify the value of custom_maps:custom_maps in the dtsi of mesong12b.dtsi, because this mapname = “khadas-ir” is the part used by our khadas
Modify this and see if fdt has changed

If you are DIY, you can directly replace the original value you need to modify

I modified the mesong12b.dtsi, then I compiled successfully the dtbo.img
the command make dtboimage produce two files: dt.img and dtbo.img
But now I’m confused which file I must upload to the board.
Inspecting the current content of the partition dtbo on the board seem it is equal of the content of dtbo.img
So I tried to upgrade the partition dtbo with dtbo.img, but when I restart the board my remote IR commander still don’t work.

I have examined the content of dt.img and I see that the mapname = “khadas-ir” (also other parameter s defined in the file mesong12b.dtsi) is in the dt.img and not in the dtbo.img

So I tried to upload the dt.img to the board but I don’t know where to write it, I tried to write dt.img in the partition dtbo but the remote ir still not work.

I also compiled the the boot.img and bootloader.img and I saw that inside the boot.img there is concatenated the dt.img, I upload the boot.img to the board but when I bootup the board on the uboot if I run the commands:

fdt addr ${dtb_mem_addr}
fdt print /custom_maps/map_0 

the content of the output not contain my customization.
Another strange thing is that after I upload the boot.img and reset the board, if I run the command version the output not reflect the boot.img I compiled

I write all the image files from uboot whit the command usb_update

what I miss?


The image you push into the device should be dt.img,

The command is used as follows

usb_update_aml_dtb dt.img

Hi @xiong.zhang, thanks for the reply.
From uboot I don’t have the command usb_update_aml_dtb.
There is only the command usb_update or usb_burn.
I tried usb_update aml_dtb dt.img but don’t exist an partition named aml_dtb so the command fail.
These are the partitions list:

kvim3#amlmmc part 1

Partition Map for MMC device 1  --   Partition Type: AML

Part   Start     Sect x Size Type  name
 00 0 8192    512 U-Boot bootloader
 01 73728 131072    512 U-Boot reserved
 02 221184 2293760    512 U-Boot cache
 03 2531328 16384    512 U-Boot env
 04 2564096 16384    512 U-Boot logo
 05 2596864 49152    512 U-Boot recovery
 06 2662400 16384    512 U-Boot misc
 07 2695168 16384    512 U-Boot dtbo
 08 2727936 16384    512 U-Boot cri_data
 09 2760704 32768    512 U-Boot param
 10 2809856 32768    512 U-Boot boot
 11 2859008 32768    512 U-Boot rsv
 12 2908160 32768    512 U-Boot metadata
 13 2957312 4096    512 U-Boot vbmeta
 14 2977792 65536    512 U-Boot tee
 15 3059712 1015808    512 U-Boot vendor
 16 4091904 262144    512 U-Boot odm
 17 4370432 3948544    512 U-Boot system
 18 8335360 262144    512 U-Boot product
 19 8613888 21921792    512 U-Boot data
** Partition 20 not found on device 1 **



Sorry, My spaces are missing because of my translation software

usb_update _aml_dtb dt.img

The following is a screenshot of my successful upgrade of a single image file using uboot, you can use it for comparison

In addition, you put the file into the U disk or SD card, then insert it in the shutdown state, and then enter the Enter key in the serial port continuously to enter the uboot upgrade mode, and then enter the command

Thanks @xiong.zhang, I successfully update the dt.img and now the IR customization work!!

many thanks for the support


You’re welcome

@xiong.zhang I have another doubt.
According to my IR customization I can Power off the board but during the shutdown the board on the console print this warning when completed the poweroff: customer pwrkeys for IR is NULL, use defaults!
And I not able to power on the board with IR commander.

I must define something else on the file mesong12b.dtsi ?
I defined the KEY_POWER, and this key work for power off but don’t work for power the board.

I miss something?

Another question, there is a way to emulate mouse move and scroll with IR commander?
I look on the file ./common/include/uapi/linux/input-event-codes.h but I found only the code for emulate mouse button right|left|middle.
I try to use also BTN_GEAR_DOWN|BTN_GEAR_UP but don’t work.



The size here is the same, can you show me the git diff where you modified

Hi @xiong.zhang , below my custom map:

custom_maps:custom_maps {
		mapnum = <1>;
		map0 = <&map_0>;
		map_0: map_0{
			mapname = "custom-ir";
			customcode = <0xcb04>;
			release_delay = <80>;
			fn_key_scancode = <0x05>;
			ursor_left_scancode = <0x43>;
			cursor_right_scancode = <0x01>;
			cursor_up_scancode = <0x06>;
			cursor_down_scancode = <0x0a>;
			cursor_ok_scancode = <0x02>;
			size  = <34>;
			keymap = <REMOTE_KEY(0x41,KEY_1)

You are a new “custom-ir”, you can try our original “khadas-ir”

I thought that mapname is just an label, anyway I changed it to khadas-ir but I still not able to power-on the board and this message appear to console: customer pwrkeys for IR is NULL, use defaults!

When I’m on Android I can power-off the board using the IR commander.

Hi @xiong.zhang, I find a solution!

From uboot I must define the ircode with this command:
kbi ircode customer1 w <ircode>

thanks for the support

1 Like