Sonoff NSPanel Pro 120: Device Tree
In this article, let's extract the device tree (.dts
) file from the backup. A Device Tree is a data structure that provides a way to describe the hardware components of a system in a hierarchical manner. It allows the Linux kernel to understand the hardware layout without hardcoding this information into the kernel itself.
The extracted .dts
file will give us the opportunity to delve deeper into the connections between device components and also help us create our own Linux/Android firmware for the device.
In the case of the panel, the .dts
is stored in the resource.img
partition. Let's briefly look at it contents:
Ok, so the device tree is in first part of file. and the other ones are the images. Lets extract it with resource_tool
Great! Now that we have extracted the files, we have the rk-kernel.dtb
file and the logo used during the boot-up process:
Since the .dtb
is a binary (compiled) representation of the .dts
file, we should decompile it back to .dts
in order to view and analyze the device tree. The command to perform this decompilation is:
dtc -I dtb -O dts -o rk-kernel.dts rk-kernel.dtb
The .dts
file could found here
The most significant part for us is:
panel @0 {
compatible = "simple-panel-dsi";
reg = < 0x00 > ;
power - supply = < 0x6a > ;
backlight = < 0xa8 > ;
reset - gpios = < 0xa9 0x00 0x01 > ;
id - gpios = < 0xa9 0x0b 0x00 > ;
reset - delay - ms = < 0x78 > ;
init - delay - ms = < 0x78 > ;
enable - delay - ms = < 0x78 > ;
prepare - delay - ms = < 0x78 > ;
disable - delay - ms = < 0x78 > ;
unprepare - delay - ms = < 0x78 > ;
width - mm = < 0x48 > ;
height - mm = < 0x46 > ;
dsi, flags = < 0x803 > ;
dsi, format = < 0x00 > ;
dsi, lanes = < 0x04 > ;
status = "okay";
panel - init - sequence = [15 00 02 e0 00 15 00 02 e1 93 15 00 02 e2 65 15 00 02 e3 f8 15 00 02 80 03 15 00 02 e0 01 15 00 02 00 00 15 00 02 01 a9 15 00 02 03 10 15 00 02 04 a9 15 00 02 0 c 74 15 00 02 17 00 15 00 02 18 d7 15 00 02 19 00 15 00 02 1 a 00 15 00 02 1 b d7 15 00 02 1 c 00 15 00 02 35 26 15 00 02 37 09 15 00 02 38 04 15 00 02 39 08 15 00 02 3 a 0 a 15 00 02 3 c 78 15 00 02 3 d ff 15 00 02 3 e ff 15 00 02 3 f ff 15 00 02 40 71 15 00 02 41 a6 15 00 02 42 5 f 15 00 02 43 ff 15 00 02 44 08 15 00 02 45 01 15 00 02 4 b 04 15 00 02 4 e 0 d 15 00 02 4 f 3 e 15 00 02 50 01 15 00 02 55 0 c 15 00 02 56 01 15 00 02 57 69 15 00 02 58 0 a 15 00 02 59 0 a 15 00 02 5 a 28 15 00 02 5 b 15 15 00 02 5 d 7 f 15 00 02 5 e 66 15 00 02 5 f 56 15 00 02 60 4 a 15 00 02 61 45 15 00 02 62 38 15 00 02 63 3 f 15 00 02 64 2 c 15 00 02 65 46 15 00 02 66 44 15 00 02 67 3 e 15 00 02 68 4 d 15 00 02 69 2 d 15 00 02 6 a 27 15 00 02 6 b 18 15 00 02 6 c 1 b 15 00 02 6 d 12 15 00 02 6 e 0 d 15 00 02 6 f 06 15 00 02 70 7 f 15 00 02 71 66 15 00 02 72 56 15 00 02 73 4 a 15 00 02 74 45 15 00 02 75 38 15 00 02 76 3 f 15 00 02 77 2 c 15 00 02 78 46 15 00 02 79 44 15 00 02 7 a 3 e 15 00 02 7 b 4 d 15 00 02 7 c 2 d 15 00 02 7 d 27 15 00 02 7 e 18 15 00 02 7 f 1 b 15 00 02 80 12 15 00 02 81 0 d 15 00 02 82 06 15 00 02 e0 02 15 00 02 00 5 f 15 00 02 01 5 f 15 00 02 02 53 15 00 02 03 51 15 00 02 04 45 15 00 02 05 47 15 00 02 06 49 15 00 02 07 4 b 15 00 02 08 41 15 00 02 09 55 15 00 02 0 a 55 15 00 02 0b 55 15 00 02 0 c 55 15 00 02 0 d 55 15 00 02 0 e 55 15 00 02 0 f 55 15 00 02 10 55 15 00 02 11 55 15 00 02 12 55 15 00 02 13 55 15 00 02 14 55 15 00 02 15 55 15 00 02 16 5 f 15 00 02 17 5 f 15 00 02 18 52 15 00 02 19 50 15 00 02 1 a 44 15 00 02 1 b 46 15 00 02 1 c 48 15 00 02 1 d 4 a 15 00 02 1 e 40 15 00 02 1 f 55 15 00 02 20 55 15 00 02 21 55 15 00 02 22 55 15 00 02 23 55 15 00 02 24 55 15 00 02 25 55 15 00 02 26 55 15 00 02 27 55 15 00 02 28 55 15 00 02 29 55 15 00 02 2 a 55 15 00 02 2 b 55 15 00 02 2 c 5 f 15 00 02 2 d 5 f 15 00 02 2 e 52 15 00 02 2 f 40 15 00 02 30 44 15 00 02 31 4 a 15 00 02 32 48 15 00 02 33 46 15 00 02 34 50 15 00 02 35 55 15 00 02 36 55 15 00 02 37 55 15 00 02 38 55 15 00 02 39 55 15 00 02 3 a 55 15 00 02 3 b 55 15 00 02 3 c 55 15 00 02 3 d 55 15 00 02 3 e 55 15 00 02 3 f 55 15 00 02 40 55 15 00 02 41 55 15 00 02 42 5 f 15 00 02 43 5 f 15 00 02 44 53 15 00 02 45 41 15 00 02 46 45 15 00 02 47 4 b 15 00 02 48 49 15 00 02 49 47 15 00 02 4 a 51 15 00 02 4 b 55 15 00 02 4 c 55 15 00 02 4 d 55 15 00 02 4 e 55 15 00 02 4 f 55 15 00 02 50 55 15 00 02 51 55 15 00 02 52 55 15 00 02 53 55 15 00 02 54 55 15 00 02 55 55 15 00 02 56 55 15 00 02 57 55 15 00 02 5 b 10 15 00 02 5 c 02 15 00 02 5 d 50 15 00 02 5 e 01 15 00 02 5 f 02 15 00 02 60 50 15 00 02 61 05 15 00 02 62 06 15 00 02 63 00 15 00 02 64 54 15 00 02 65 55 15 00 02 66 3 c 15 00 02 67 73 15 00 02 68 04 15 00 02 69 00 15 00 02 6 a 58 15 00 02 6 b 04 15 00 02 6 c 00 15 00 02 6 d 20 15 00 02 e0 00 05 78 01 11 05 05 01 29];
panel - init - sequence - new = [39 00 06 f0 55 aa 52 08 00 39 00 03 b1 68 51 39 00 04 b2 65 02 00 39 00 03 b5 d5 02 39 00 06 bd a4 be 10 10 01 15 00 02 c8 80 39 00 06 f0 55 aa 52 08 01 15 00 02 b3 26 15 00 02 b4 14 15 00 02 bb 04 15 00 02 bc 68 15 00 02 bd 68 15 00 02 be 3 c 39 00 06 f0 55 aa 52 08 02 15 00 02 ee 01 39 00 11 b0 00 00 00 1 c 00 3 f 00 5 a 00 77 00 8 a 00 9 e 00 af 39 00 11 b1 00 c0 00 f5 01 1 f 01 5 a 01 87 01 c8 01 fb 01 fd 39 00 11 b2 02 2 d 02 65 02 8 a 02 c0 02 e4 03 15 03 24 03 34 39 00 0 d b3 03 48 03 5 f 03 79 03 9 b 03 c6 03 ff 39 00 0b e9 00 00 00 00 00 00 00 00 00 00 39 00 0b ea 00 00 00 00 00 00 00 00 00 00 39 00 0b eb 00 00 00 00 00 00 00 00 00 00 39 00 06 f0 55 aa 52 08 03 39 00 03 b0 0 f 00 39 00 06 b2 00 07 04 0 c 00 39 00 06 b3 00 05 02 0 c 00 39 00 06 b4 00 82 a1 0 c 00 39 00 06 b5 00 a0 a3 0 c 00 39 00 05 ba 35 00 80 0 e 39 00 06 f0 55 aa 52 08 04 39 00 05 c7 a0 0 a 14 00 39 00 06 f0 55 aa 52 08 05 15 00 02 b0 05 39 00 03 b2 05 00 39 00 05 bc 00 00 00 02 39 00 06 bd 01 0 f 03 03 03 39 00 03 c0 04 70 39 00 06 d1 00 15 38 00 00 15 00 02 e3 84 39 00 06 f0 55 aa 52 08 06 39 00 06 b0 07 05 17 15 13 39 00 06 b1 11 31 31 31 31 39 00 06 b2 35 35 35 35 35 39 00 06 b3 35 01 03 35 35 39 00 06 b4 35 35 02 00 35 39 00 06 b5 35 35 35 35 35 39 00 06 b6 31 31 31 31 10 39 00 06 b7 12 14 16 04 06 39 00 06 f0 55 aa 52 00 00 15 00 02 35 00 39 00 05 ff aa 55 25 01 15 00 02 6 f 21 15 00 02 f3 02 39 00 05 ff aa 55 25 00 05 78 01 11 05 00 01 29];
panel - exit - sequence = < 0x5000128 0x5000110 > ;
display - timings {
native - mode = < 0xaa > ;
timing0 {
clock - frequency = < 0x3fe56c0 > ;
hactive = < 0x2ee > ;
vactive = < 0x536 > ;
hback - porch = < 0x28 > ;
hfront - porch = < 0x14 > ;
vback - porch = < 0x08 > ;
vfront - porch = < 0x0c > ;
hsync - len = < 0x14 > ;
vsync - len = < 0x02 > ;
hsync - active = < 0x00 > ;
vsync - active = < 0x00 > ;
de - active = < 0x00 > ;
pixelclk - active = < 0x00 > ;
phandle = < 0xaa > ;
};
};
};
This Device Tree node defines the configuration for a DSI-connected display panel. It specifies essential properties such as the compatible driver (simple-panel-dsi
), power supply and backlight controls, GPIO pins for reset and identification, various initialization and delay parameters, physical dimensions (width and height in millimeters), DSI interface settings (flags, format, and number of lanes), and detailed display timings. Additionally, it includes initialization and exit sequences that dictate the panel's behavior during the boot-up and shutdown processes. The driver for the panel is universal and already exsist at the kernel, so there shoudl be no issues with integration.
i2c @ff190000 {
compatible = "rockchip,rk3399-i2c";
reg = < 0x00 0xff190000 0x00 0x1000 > ;
clocks = < 0x02 0x1e 0x02 0x14f > ;
clock - names = "i2c\0pclk";
interrupts = < 0x00 0x08 0x04 > ;
pinctrl - names = "default";
pinctrl - 0 = < 0x69 > ;
#address - cells = < 0x01 > ;
#size - cells = < 0x00 > ;
status = "okay";
clock - frequency = < 0x61a80 > ;
phandle = < 0x100 > ;
chsc5xxx @2e {
compatible = "chipsemi,chsc_cap_touch";
reg = < 0x2e > ;
chipsemi, int - gpio = < 0x5e 0x0d 0x08 > ;
chipsemi, rst - gpio = < 0x5e 0x0c 0x00 > ;
status = "okay";
};
smatek @3C {
compatible = "smatek,tp";
status = "okay";
reg = < 0x3c > ;
phandle = < 0x101 > ;
};
};
It integrates two touch panel controllers:
- Chipsemi CHSC5448A (
chsc5xxx @2e
):- Compatible Driver:
chipsemi,chsc_cap_touch
- GPIO Configuration: Specifies interrupt and reset GPIO pins.
- Compatible Driver:
- SmaTek Touch Panel (
smatek @3C
):- Compatible Driver:
smatek,tp
- GPIO Configuration: Minimal, primarily defining the register address.
- Compatible Driver:
Both the Chipsemi CHSC5448A and SmaTek touch panel drivers are not present in the current Linux kernel. To support these touch panels, custom drivers will need to be developed and integrated into the kernel.
Lets move next:
i2c @ff1a0000 {
compatible = "rockchip,rk3399-i2c";
reg = < 0x00 0xff1a0000 0x00 0x1000 > ;
clocks = < 0x02 0x1f 0x02 0x150 > ;
clock - names = "i2c\0pclk";
interrupts = < 0x00 0x09 0x04 > ;
pinctrl - names = "default";
pinctrl - 0 = < 0x6b > ;
#address - cells = < 0x01 > ;
#size - cells = < 0x00 > ;
status = "okay";
clock - frequency = < 0x186a0 > ;
i2c - scl - falling - time - ns = < 0x32 > ;
i2c - scl - rising - time - ns = < 0x12c > ;
phandle = < 0x104 > ;
lsensor @46 {
status = "okay";
compatible = "ls_stk3a5x";
reg = < 0x46 > ;
type = < 0x05 > ;
irq_enable = < 0x00 > ;
poll_delay_ms = < 0x32 > ;
phandle = < 0x106 > ;
};
psensor @46 {
status = "okay";
compatible = "ps_stk3a5x";
reg = < 0x46 > ;
type = < 0x06 > ;
irq_enable = < 0x00 > ;
poll_delay_ms = < 0x32 > ;
phandle = < 0x107 > ;
};
};
There is limited information available on the stk3a5x
sensor (light and presence sensor). However, other devices from Sensortech are present in the kernel. To proceed effectively, it is essential to locate the datasheet for the stk3a5x
series to understand its specifications and integration requirements fully.
Other than that, we can observe that the PMIC is the rk809 and is controlled via I²C. Additionally, the speaker amplifier is built into the PMIC chip. The microphone array operates through PDM. The Wi-Fi/Bluetooth module is the RTL8723DS and functions through the SDIO and UART interfaces. Zigbee is connected via the UART interface as well.
In the upcoming articles, let's create our own Debian/Ubuntu firmware using the 5.10 kernel, integrating the LCD, speaker, and array microphone to ensure they function correctly. After that, we'll attempt to add drivers for the touchscreen, light and presence sensors, and Zigbee.