1. Adding a New MIPI Panel#
This document demonstrates how to add a new 368(H) x 552(V) MIPI panel.
1.1 Using the Panel Debugging Assistant#
In the CanMV-K230 project, a panel debugging assistant has been added to the mpp sub-repository. Users can enable this feature and quickly debug panel timing and initialization sequences by modifying the configuration file stored on the SD card, eliminating the need for frequent code modifications and firmware recompilation.
1.1.1 Enabling DSI Debugger
#
In the project root directory, execute make menuconfig
and enable the option Enable DSI Debugger
.
After saving the configuration, compile and generate the new firmware, then flash it.
1.1.2 Generating display_debugger_config.txt
#
The project includes a template configuration file located at src/rtsmart/mpp/userapps/src/connector/display_debugger_config.txt
. The parameters in this file are explained as follows:
[config]
pclk_hz=33000000 # pclk in hz
fps=60 # target fps
lane_num=2 # mipi dsi lane number, choice in 1, 2, 4
hactive=480
hsync=8
hbp=32
hfp=32
vactive=800
vsync=10
vbp=150
vfp=140
# !!! every line length should < 256
# cmd_type:
# 0x05 Command type: Single byte data (DCS Short Write, no parameters)
# 0x15 Command type: Two byte data (DCS Short Write, 1 parameter)
# 0x39 Command type: Multi byte data (DCS Long Write, n parameters n >= 2)
# format: cmd_type, delay_ms, cmd_data_length, cmd_data0 ... cmd_dataN
# The initialization sequence format is: cmd_type, delay_ms, cmd_data_length, cmd_data0 ... cmd_dataN
#
# Currently, three command types are supported:
# 0x05: Write one byte, no parameters
# 0x15: Write two bytes, one parameter
# 0x39: Write multiple bytes, two or more parameters
#
# Example: 0x39,10,3,0xE8,0x00,0x0C
# 0x39 Command type: 0x39, meaning we are writing multiple bytes of data
# 10 Decimal value, indicating a delay of 10 milliseconds after executing this command before proceeding to the next
# 3 Decimal value, indicating that this 0x39 command will write 3 bytes of data
# 0xE8,0x00,0x0C The 3 bytes of data, where 0xE8 is the command and 0x00,0x0C are the parameters, meaning this is a command with two parameters
#
# Note: 0x39 and 0xE8 are both commands, but they are different. The former is a command type in the MIPI display interface protocol, while the latter is a specific command byte in the panel initialization sequence, typically used to enable or disable certain functions (e.g., display mode, contrast, color configuration, etc.).
[init-sequence]
0x05,0,1,0x01
0x05,10,1,0x11
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x11
0x15,0,2,0xD1,0x11
0x15,0,2,0x55,0xB0
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x10
0x39,0,3,0xC0,0x63,0x00
0x39,0,3,0xC1,0x04,0x02
0x39,0,3,0xC2,0x37,0x08
0x15,0,2,0xC7,0x00
0x15,0,2,0xCC,0x38
0x39,0,17,0xB0,0x00,0x11,0x19,0x0C,0x10,0x06,0x07,0x0A,0x09,0x22,0x04,0x10,0x0E,0x28,0x30,0x1C
0x39,0,17,0xB1,0x00,0x12,0x19,0x0D,0x10,0x04,0x06,0x07,0x08,0x23,0x04,0x12,0x11,0x28,0x30,0x1C
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x11
0x15,0,2,0xB0,0x4D
0x15,0,2,0xB1,0x60
0x15,0,2,0xB2,0x07
0x15,0,2,0xB3,0x80
0x15,0,2,0xB5,0x47
0x15,0,2,0xB7,0x8A
0x15,0,2,0xB8,0x21
0x15,0,2,0xC1,0x78
0x15,0,2,0xC2,0x78
0x15,0,2,0xD0,0x88
0x39,0,4,0xE0,0x00,0x00,0x02
0x39,0,12,0xE1,0x01,0xA0,0x03,0xA0,0x02,0xA0,0x04,0xA0,0x00,0x44,0x44
0x39,0,12,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x39,0,5,0xE3,0x00,0x00,0x33,0x33
0x39,0,3,0xE4,0x44,0x44
0x39,0,17,0xE5,0x01,0x26,0xA0,0xA0,0x03,0x28,0xA0,0xA0,0x05,0x2A,0xA0,0xA0,0x07,0x2C,0xA0,0xA0
0x39,0,5,0xE6,0x00,0x00,0x33,0x33
0x39,0,3,0xE7,0x44,0x44
0x39,0,17,0xE8,0x02,0x26,0xA0,0xA0,0x04,0x28,0xA0,0xA0,0x06,0x2A,0xA0,0xA0,0x08,0x2C,0xA0,0xA0
0x39,0,8,0xEB,0x00,0x01,0xE4,0xE4,0x44,0x00,0x40
0x39,0,17,0xED,0xFF,0xF7,0x65,0x4F,0x0B,0xA1,0xCF,0xFF,0xFF,0xFC,0x1A,0xB0,0xF4,0x56,0x7F,0xFF
0x15,0,2,0xEE,0x42
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x00
0x15,0,2,0x36,0x00
0x15,0,2,0x3A,0x55
0x05,10,1,0x11
0x05,0,1,0x29
Next, we modify the corresponding panel timing and initialization sequence according to our panel, and generate the display_debugger_config.txt
file for our panel. Using the panel in this document as an example, we will eventually adjust to a file like this. (Remember to remove the comments from the configuration file.)
[config]
pclk_hz=27000000
fps=60
lane_num=2
hactive=368
hsync=8
hbp=16
hfp=16
vactive=552
vsync=48
vbp=250
vfp=250
[init-sequence]
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x13
0x15,0,2,0xEF,0x08
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x10
0x39,0,3,0xC0,0x44,0x00
0x39,0,3,0xC1,0x0B,0x02
0x39,0,3,0xC2,0x07,0x1F
0x15,0,2,0xCC,0x10
0x39,0,17,0xB0,0x0F,0x1E,0x25,0x0D,0x11,0x06,0x12,0x08,0x08,0x2A,0x05,0x12,0x10,0x2B,0x32,0x1F
0x39,0,17,0xB1,0x0F,0x1E,0x25,0x0D,0x11,0x05,0x12,0x08,0x08,0x2B,0x05,0x12,0x10,0x2B,0x32,0x1F
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x11
0x15,0,2,0xB0,0x35
0x15,0,2,0xB1,0x45
0x15,0,2,0xB2,0x87
0x15,0,2,0xB3,0x80
0x15,0,2,0xB5,0x49
0x15,0,2,0xB7,0x85
0x15,0,2,0xB8,0x11
0x15,0,2,0xBB,0x03
0x15,0,2,0xC0,0x07
0x15,0,2,0xC1,0x78
0x15,0,2,0xC2,0x78
0x15,100,2,0xD0,0x88
0x39,0,4,0xE0,0x00,0x00,0x02
0x39,0,12,0xE1,0x03,0x30,0x07,0x30,0x02,0x30,0x06,0x30,0x00,0x44,0x44
0x39,0,12,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x39,0,5,0xE3,0x00,0x00,0x22,0x00
0x39,0,3,0xE4,0x22,0x00
0x39,0,17,0xE5,0x0A,0x34,0x30,0xE0,0x08,0x32,0x30,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x39,0,5,0xE6,0x00,0x00,0x22,0x00
0x39,0,3,0xE7,0x22,0x00
0x39,0,17,0xE8,0x09,0x33,0x30,0xE0,0x07,0x31,0x30,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
0x39,0,8,0xEB,0x00,0x01,0x10,0x10,0x11,0x00,0x00
0x39,0,17,0xED,0xFF,0xFF,0xF0,0x45,0xBA,0x2F,0xFF,0xFF,0xFF,0xFF,0xF2,0xAB,0x54,0x0F,0xFF,0xFF
0x39,0,7,0xEF,0x08,0x08,0x08,0x45,0x3F,0x54
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x13
0x39,0,3,0xE8,0x00,0x0E
0x15,120,2,0x11,0x00
0x39,10,3,0xE8,0x00,0x0C
0x39,0,3,0xE8,0x00,0x00
0x39,0,6,0xFF,0x77,0x01,0x00,0x00,0x00
0x15,50,2,0x29,0x00
1.1.3 Placing the Configuration File on the SD Card#
After booting, place the configuration file in the root directory of the SD card.
1.1.4 Verifying and Adjusting the Configuration#
1.1.4.1 Open the Display
Sample in CanMV IDE K230
#
1.1.4.2 Modify the Sample Code to Use DSI Debugger
#
1.1.4.3 Run the Sample and Check the Results#
Since the parameters provided in this document are adapted for the corresponding panel, the panel will output the image correctly. If the reader does not get the expected result, they need to modify the configuration file on the SD card, adjust the parameters, and repeat running the sample until the correct parameters are found.
1.2 Adjusting Configuration File Parameters#
The parameters in the configuration file on the SD card are divided into two parts: the first part is related to panel timing, and the second part is the initialization sequence provided by the panel manufacturer. Let’s take a closer look at the specific meanings of these two parts.
1.2.1 Panel Timing#
[config]
pclk_hz=27000000 # This value is calculated based on the parameters below using a calculation tool
fps=60 # Assuming we want this frame rate, we will input it into the calculation tool
lane_num=2
# htotal = hactive + hsync + hbp + hfp
hactive=368 # This corresponds to the width of the resolution
hsync=8 # hsync, hbp, hfp are estimated based on the corresponding panel and adjusted
hbp=16
hfp=16
# vtotal = vactive + vsync + vbp +vfp
# For vtotal, there is a limitation: the main controller will only trigger an interrupt at 2^N lines, so when vtotal > 512, vtotal should be aligned to 1024, and then some margin should be added
# for the interrupt handler, so the estimated vtotal should be 1100, meaning vactive + vsync + vbp +vfp should equal 1100. Under this constraint, adjust vsync, vbp, vfp.
vactive=552 # This corresponds to the height of the resolution
vsync=48 # vsync, vbp, vfp are estimated based on the corresponding panel and adjusted
vbp=250
vfp=250
We provide a tool to assist in calculating the timing: K230 MIPI DSI Connector Info Generator. Below is a demonstration of how to use this tool to calculate the values above.
1.2.2 Initialization Sequence#
The panel manufacturer provided the following initialization sequence for the panel in this document