feat(core): add LX200B4501CTP03x panels' support
What changed, and why it matters
This commit adds support for a new LCD touchscreen module used on the T3T2 hardware development kit. It is a routine hardware-enablement change: new display initialization commands, a new DMA copy path for 16-bit or byte-swapped pixel transfers, runtime tracking of pixel byte order, and placeholder touch calibration. There is no indication in the commit that this fixes a security vulnerability or introduces a known dangerous pattern. The most notable code-quality observation is that the new touch-panel correction function currently uses unverified placeholder constants copied from another panel, which could make touch coordinates inaccurate on the devkit until hardware calibration is performed.
Treat as normal hardware-enablement review. Verify the new DMA byte-exchange path against the FMC/i8080 bus-width configuration, ensure devkit.h does not allow both DISPLAY_I8080_8BIT_DW and DISPLAY_I8080_16BIT_DW to be defined simultaneously, and replace the placeholder touch correction constants with hardware-calibrated values before shipping the devkit configuration in production.
Security signals we found
New DMA helper operates on memory-mapped display data address with optional byte exchange; correctness depends on bus-width and endianness defines being mutually exclusive as documented in devkit.h.
GC9307C controller cannot switch RGB565 byte order; driver now records actual endianness and propagates it to pixel-issuing macros to avoid color-swap bugs.
Touch correction for the new panel is a TODO placeholder using identity mapping copied from another panel; may cause inaccurate touch mapping until calibrated.
Display power enable polarity changed to active-low for this board; incorrect polarity could prevent display power-up but is a hardware-bringup concern, not an exploit vector.
No input validation changes, no buffer size changes, no privilege-boundary changes, no cryptographic changes.
Evidence from the diff
The patch introduces the LX200B4501CTP03A/B panel (GC9307C controller, 240x320, FT6x36 touch) for the T3T2 devkit. Key changes: (1) new panel init/rotation sequence in panels/lx200b4501ctp03.c; (2) a runtime display_pixel_endian_t field because GC9307C cannot change RGB565 byte order and is always big-endian; (3) ISSUE_PIXEL_DATA now takes the endianness parameter and emits high-then-low bytes on 8-bit buses for big-endian panels; (4) new bg_copy_start_const_out_16() GPDMA helper with optional byte exchange for 8-bit big-endian or native 16-bit bus copies; (5) board-level IM0-IM2 interface-mode pin control and active-low display power enable; (6) placeholder touch coordinate correction copied from LX154A2422CPT23. The commit message and diff contain no security framing, CVE references, or researcher attribution.
Changed components
core/embed/io/display/i8080 driver and panel filescore/embed/io/display/bg_copy GPDMA helpercore/embed/io/touch/ft6x36 driver and panel filesT3T2 devkit board configuration (devkit.h, devkit.toml)Inspect captured patch +516 / −37
### core/embed/io/Cargo.toml
@@ -95,6 +95,7 @@ touch_sitronix = ["sys/i2c_bus"]
# board TOML, mirroring the display driver/panel split below.
touch_panel_t2t1 = []
touch_panel_lx154a2422cpt23 = []
+touch_panel_lx200b4501ctp03 = []
touch_panel_lx250a2410a = []
# Drivers below that always need framebuffer pull it in implicitly,
@@ -113,6 +114,7 @@ display_panel_stm32u5a9j_dk = []
display_panel_t2t1 = []
display_panel_lx154a2482 = []
display_panel_dem240320b1 = []
+display_panel_lx200b4501ctp03 = []
display_panel_vg2864 = []
# --------------------------------------------------------------------------
### core/embed/io/display/bg_copy/bg_copy.h
@@ -25,6 +25,28 @@ typedef void (*bg_copy_callback_t)(void);
void bg_copy_start_const_out_8(const uint8_t *src, uint8_t *dst, size_t size,
bg_copy_callback_t callback);
+/**
+ * Performs data copy from src to dst in the background, 16 bits at a time.
+ * The destination is constant, meaning the address is not incremented.
+ * Ensure the transfer completion by calling bg_copy_wait.
+ *
+ * Without byte swapping, it is used for a native 16-bit-wide i8080 bus, where
+ * each pixel is written to the panel in a single bus cycle.
+ *
+ * With byte swapping, it is used for an 8-bit-wide i8080 bus with a panel
+ * expecting the high byte of each pixel first. The DMA swaps the bytes of
+ * each halfword and the FMC splits every 16-bit write into two 8-bit bus
+ * cycles (lower address first), so the high byte goes out first.
+ *
+ * @param src source data address (16-bit aligned)
+ * @param dst destination data address (16-bit aligned)
+ * @param size size of data to be transferred in bytes
+ * @param swap_bytes swap the two bytes of each halfword before writing
+ * @param callback optional callback to be called when the transfer is complete
+ */
+void bg_copy_start_const_out_16(const uint16_t *src, uint16_t *dst, size_t size,
+ bool swap_bytes, bg_copy_callback_t callback);
+
/**
* Waits for the data transfer completion
*/
### core/embed/io/display/bg_copy/stm32u5/bg_copy.c
@@ -116,6 +116,56 @@ void bg_copy_start_const_out_8(const uint8_t *src, uint8_t *dst, size_t size,
HAL_DMA_Start_IT(&DMA_Handle, (uint32_t)src, (uint32_t)dst, data_to_send);
}
+void bg_copy_start_const_out_16(const uint16_t *src, uint16_t *dst, size_t size,
+ bool swap_bytes, bg_copy_callback_t callback) {
+ uint32_t data_to_send = size > MAX_DATA_SIZE ? MAX_DATA_SIZE : size;
+ dma_transfer_remaining = size;
+ dma_data_transferred = 0;
+ data_src = (void *)src;
+ data_dst = (void *)dst;
+ bg_copy_callback = callback;
+
+ // setup DMA for data copy to constant output address, 16 bits at a time
+
+ __HAL_RCC_GPDMA1_CLK_ENABLE();
+
+ DMA_Handle.Instance = GPDMA1_Channel0;
+ DMA_Handle.XferCpltCallback = HAL_DMA_XferCpltCallback;
+ DMA_Handle.Init.Request = GPDMA1_REQUEST_HASH_IN;
+ DMA_Handle.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
+ DMA_Handle.Init.Direction = DMA_MEMORY_TO_MEMORY;
+ DMA_Handle.Init.SrcInc = DMA_SINC_INCREMENTED;
+ DMA_Handle.Init.DestInc = DMA_DINC_FIXED;
+ DMA_Handle.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_HALFWORD;
+ DMA_Handle.Init.DestDataWidth = DMA_DEST_DATAWIDTH_HALFWORD;
+ DMA_Handle.Init.Priority = DMA_LOW_PRIORITY_HIGH_WEIGHT;
+ DMA_Handle.Init.SrcBurstLength = 1;
+ DMA_Handle.Init.DestBurstLength = 1;
+ DMA_Handle.Init.TransferAllocatedPort =
+ DMA_SRC_ALLOCATED_PORT1 | DMA_DEST_ALLOCATED_PORT0;
+ DMA_Handle.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
+ DMA_Handle.Init.Mode = DMA_NORMAL;
+ HAL_DMA_Init(&DMA_Handle);
+
+ // Optionally swap the bytes of each halfword. On an 8-bit FMC bus, the FMC
+ // splits each 16-bit write into two byte cycles (lower address first), so
+ // swapping makes the high byte of each pixel go out first.
+ DMA_DataHandlingConfTypeDef data_handling = {0};
+ data_handling.DataExchange =
+ swap_bytes ? DMA_EXCHANGE_DEST_BYTE : DMA_EXCHANGE_NONE;
+ data_handling.DataAlignment = DMA_DATA_RIGHTALIGN_ZEROPADDED;
+ HAL_DMAEx_ConfigDataHandling(&DMA_Handle, &data_handling);
+
+ HAL_DMA_ConfigChannelAttributes(
+ &DMA_Handle, DMA_CHANNEL_PRIV | DMA_CHANNEL_SEC | DMA_CHANNEL_SRC_SEC |
+ DMA_CHANNEL_DEST_SEC);
+
+ NVIC_SetPriority(GPDMA1_Channel0_IRQn, IRQ_PRI_NORMAL);
+ NVIC_EnableIRQ(GPDMA1_Channel0_IRQn);
+
+ HAL_DMA_Start_IT(&DMA_Handle, (uint32_t)src, (uint32_t)dst, data_to_send);
+}
+
void bg_copy_abort(void) {
dma_transfer_remaining = 0;
dma_data_transferred = 0;
### core/embed/io/display/build.rs
@@ -75,6 +75,14 @@ fn set_panel_dem240320b1(lib: &mut CLibrary) {
]);
}
+fn set_panel_lx200b4501ctp03(lib: &mut CLibrary) {
+ lib.add_defines([
+ ("DISPLAY_PANEL_LX200B4501CTP03", Some("1")),
+ ("DISPLAY_RESX", Some("240")),
+ ("DISPLAY_RESY", Some("320")),
+ ]);
+}
+
fn set_panel_lx154a2482(lib: &mut CLibrary) {
lib.add_defines([
("DISPLAY_PANEL_LX154A2482", Some("1")),
@@ -111,6 +119,8 @@ fn add_driver_unix(lib: &mut CLibrary) -> Result<()> {
set_panel_lx154a2482(lib);
} else if cfg!(feature = "display_panel_dem240320b1") {
set_panel_dem240320b1(lib);
+ } else if cfg!(feature = "display_panel_lx200b4501ctp03") {
+ set_panel_lx200b4501ctp03(lib);
} else if cfg!(feature = "display_panel_t2t1") {
set_panel_t2t1(lib);
} else if cfg!(feature = "display_panel_vg2864") {
@@ -173,6 +183,9 @@ fn add_driver_i8080(lib: &mut CLibrary) -> Result<()> {
} else if cfg!(feature = "display_panel_dem240320b1") {
set_panel_dem240320b1(lib);
lib.add_source("display/i8080/panels/dem240320b1.c");
+ } else if cfg!(feature = "display_panel_lx200b4501ctp03") {
+ set_panel_lx200b4501ctp03(lib);
+ lib.add_source("display/i8080/panels/lx200b4501ctp03.c");
} else {
bail_unsupported!();
}
### core/embed/io/display/i8080/display_driver.c
@@ -69,15 +69,15 @@ bool display_init(display_content_mode_t mode) {
display_io_init_gpio();
display_io_init_fmc();
display_panel_init();
- display_panel_set_little_endian();
+ drv->pixel_endian = display_panel_set_little_endian();
backlight_init(BACKLIGHT_RESET, GAMMA_EXP);
} else {
// Reinitialize FMC to set correct timing
// We have to do this in reinit because boardloader is fixed.
display_io_init_fmc();
// Important for model T as this is not set in boardloader
- display_panel_set_little_endian();
+ drv->pixel_endian = display_panel_set_little_endian();
display_panel_reinit();
backlight_init(BACKLIGHT_RETAIN, GAMMA_EXP);
}
@@ -124,7 +124,7 @@ void display_deinit(display_content_mode_t mode) {
if (mode == DISPLAY_RESET_CONTENT) {
display_set_orientation(0);
}
- display_panel_set_big_endian();
+ drv->pixel_endian = display_panel_set_big_endian();
#endif
drv->initialized = false;
@@ -166,9 +166,12 @@ int display_set_orientation(int angle) {
display_panel_set_window(0, 0, INTERNAL_FB_WIDTH - 1,
INTERNAL_FB_HEIGHT - 1);
+ // Local copy: the display write pointer could alias the driver struct,
+ // which would force a reload of pixel_endian after every pixel write
+ display_pixel_endian_t endian = drv->pixel_endian;
for (uint32_t i = 0; i < INTERNAL_FB_WIDTH * INTERNAL_FB_HEIGHT; i++) {
// 2 bytes per pixel because we're using RGB 5-6-5 format
- ISSUE_PIXEL_DATA(0x0000);
+ ISSUE_PIXEL_DATA(endian, 0x0000);
}
display_panel_rotate(angle);
### core/embed/io/display/i8080/display_fb.c
@@ -127,9 +127,26 @@ static void start_fb_copy(void) {
if (fb_idx >= 0) {
display_panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1);
- bg_copy_start_const_out_8(get_fb_ptr(fb_idx),
- (uint8_t *)DISPLAY_DATA_ADDRESS,
- PHYSICAL_FRAME_BUFFER_SIZE, bg_copy_callback);
+#if defined(DISPLAY_I8080_16BIT_DW)
+ bg_copy_start_const_out_16((const uint16_t *)get_fb_ptr(fb_idx),
+ (uint16_t *)DISPLAY_DATA_ADDRESS,
+ PHYSICAL_FRAME_BUFFER_SIZE, false,
+ bg_copy_callback);
+#else
+ if (drv->pixel_endian == DISPLAY_PIXEL_BIG_ENDIAN) {
+ // 16-bit DMA writes with byte exchange; the 8-bit FMC splits each
+ // halfword into two bus cycles (lower address first), so the high
+ // byte of each pixel goes out first.
+ bg_copy_start_const_out_16((const uint16_t *)get_fb_ptr(fb_idx),
+ (uint16_t *)DISPLAY_DATA_ADDRESS,
+ PHYSICAL_FRAME_BUFFER_SIZE, true,
+ bg_copy_callback);
+ } else {
+ bg_copy_start_const_out_8(get_fb_ptr(fb_idx),
+ (uint8_t *)DISPLAY_DATA_ADDRESS,
+ PHYSICAL_FRAME_BUFFER_SIZE, bg_copy_callback);
+ }
+#endif
}
}
}
@@ -198,14 +215,18 @@ bool display_get_frame_buffer(display_fb_info_t *fb) {
#ifdef BOARDLOADER
// Copies the frame buffer with the given index to the display
static void copy_fb_to_display(uint8_t index) {
+ display_driver_t *drv = &g_display_driver;
uint16_t *fb = (uint16_t *)get_fb_ptr(index);
if (fb != NULL) {
mpu_set_active_fb(fb, PHYSICAL_FRAME_BUFFER_SIZE);
display_panel_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1);
+ // Local copy: the display write pointer could alias the driver struct,
+ // which would force a reload of pixel_endian after every pixel write
+ display_pixel_endian_t endian = drv->pixel_endian;
for (int i = 0; i < DISPLAY_RESX * DISPLAY_RESY; i++) {
// 2 bytes per pixel because we're using RGB 5-6-5 format
- ISSUE_PIXEL_DATA(fb[i]);
+ ISSUE_PIXEL_DATA(endian, fb[i]);
}
}
### core/embed/io/display/i8080/display_internal.h
@@ -4,6 +4,9 @@
#include <trezor_bsp.h>
#include <trezor_types.h>
+#include "display_io.h"
+#include "display_panel.h"
+
#ifdef FRAMEBUFFER
#include "../fb_queue/fb_queue.h"
@@ -33,11 +36,33 @@ typedef struct {
int orientation_angle;
int update_pending;
+ // Byte order of pixel data expected by the panel
+ display_pixel_endian_t pixel_endian;
+
} display_driver_t;
// Display driver instance
extern display_driver_t g_display_driver;
+// Writes one RGB565 pixel in the given byte order. The byte order only
+// matters on the 8-bit bus; on the 16-bit bus the pixel is written in a
+// single bus cycle.
+#ifdef DISPLAY_I8080_16BIT_DW
+#define ISSUE_PIXEL_DATA(E, X) ((void)(E), ISSUE_DATA_BYTE(X))
+#elif defined(DISPLAY_I8080_8BIT_DW)
+#define ISSUE_PIXEL_DATA(E, X) \
+ do { \
+ uint16_t _px = (X); \
+ if ((E) == DISPLAY_PIXEL_BIG_ENDIAN) { \
+ ISSUE_DATA_BYTE(_px >> 8); \
+ ISSUE_DATA_BYTE(_px & 0xFF); \
+ } else { \
+ ISSUE_DATA_BYTE(_px & 0xFF); \
+ ISSUE_DATA_BYTE(_px >> 8); \
+ } \
+ } while (0)
+#endif // DISPLAY_I8080_16BIT_DW
+
static inline uint32_t is_mode_exception(void) {
uint32_t isr_number = __get_IPSR() & IPSR_ISR_Msk;
// Check if the ISR number is not 0 (thread mode) or 11 (SVCall)
### core/embed/io/display/i8080/display_io.c
@@ -32,6 +32,19 @@ __IO DISP_MEM_TYPE *const DISPLAY_DATA_ADDRESS =
#ifdef KERNEL_MODE
+static inline void display_io_IM_init(GPIO_TypeDef *port, uint16_t pin,
+ GPIO_PinState val) {
+ GPIO_InitTypeDef GPIO_InitStructure;
+ GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStructure.Pull = GPIO_NOPULL;
+ GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStructure.Alternate = 0;
+
+ GPIO_InitStructure.Pin = pin;
+ HAL_GPIO_WritePin(port, pin, val);
+ HAL_GPIO_Init(port, &GPIO_InitStructure);
+}
+
void display_io_init_gpio(void) {
// init peripherals
__HAL_RCC_GPIOE_CLK_ENABLE();
@@ -50,10 +63,22 @@ void display_io_init_gpio(void) {
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStructure.Alternate = 0;
GPIO_InitStructure.Pin = DISPLAY_PWR_PIN;
- HAL_GPIO_WritePin(DISPLAY_PWR_PORT, DISPLAY_PWR_PIN, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(DISPLAY_PWR_PORT, DISPLAY_PWR_PIN, GPIO_PIN_RESET);
HAL_GPIO_Init(DISPLAY_PWR_PORT, &GPIO_InitStructure);
#endif
+#ifdef DISPLAY_IM0_PIN
+ display_io_IM_init(DISPLAY_IM0_PORT, DISPLAY_IM0_PIN, DISPLAY_IM0_VAL);
+#endif // DISPLAY_IM0_PIN
+
+#ifdef DISPLAY_IM1_PIN
+ display_io_IM_init(DISPLAY_IM1_PORT, DISPLAY_IM1_PIN, DISPLAY_IM1_VAL);
+#endif // DISPLAY_IM1_PIN
+
+#ifdef DISPLAY_IM2_PIN
+ display_io_IM_init(DISPLAY_IM2_PORT, DISPLAY_IM2_PIN, DISPLAY_IM2_VAL);
+#endif // DISPLAY_IM2_PIN
+
// LCD_RST
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;
@@ -118,7 +143,7 @@ void display_io_init_fmc(void) {
#ifdef DISPLAY_I8080_16BIT_DW
external_display_data_sram.Init.MemoryDataWidth =
FMC_NORSRAM_MEM_BUS_WIDTH_16;
-#elif DISPLAY_I8080_8BIT_DW
+#elif defined(DISPLAY_I8080_8BIT_DW)
external_display_data_sram.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8;
#endif
external_display_data_sram.Init.BurstAccessMode =
### core/embed/io/display/i8080/display_io.h
@@ -46,31 +46,17 @@ void display_io_init_te_interrupt(void);
#ifdef DISPLAY_I8080_16BIT_DW
#define DISPLAY_ADDR_SHIFT 2
#define DISP_MEM_TYPE uint16_t
-#elif DISPLAY_I8080_8BIT_DW
+#elif defined(DISPLAY_I8080_8BIT_DW)
#define DISPLAY_ADDR_SHIFT 1
#define DISP_MEM_TYPE uint8_t
#else
#error "Unsupported display interface"
#endif
-/*#define DISPLAY_CMD_ADDRESS ((__IO DISP_MEM_TYPE *)(DISPLAY_MEMORY_BASE))
-#define DISPLAY_DATA_ADDRESS \
- ((__IO DISP_MEM_TYPE *)(DISPLAY_MEMORY_BASE | \
- (DISPLAY_ADDR_SHIFT << DISPLAY_MEMORY_PIN)))
-*/
-
extern __IO DISP_MEM_TYPE *const DISPLAY_CMD_ADDRESS;
extern __IO DISP_MEM_TYPE *const DISPLAY_DATA_ADDRESS;
#define ISSUE_CMD_BYTE(X) (*(DISPLAY_CMD_ADDRESS) = (X))
#define ISSUE_DATA_BYTE(X) (*(DISPLAY_DATA_ADDRESS) = (X))
-#ifdef DISPLAY_I8080_16BIT_DW
-#define ISSUE_PIXEL_DATA(X) ISSUE_DATA_BYTE(X)
-#elif DISPLAY_I8080_8BIT_DW
-#define ISSUE_PIXEL_DATA(X) \
- ISSUE_DATA_BYTE((X) & 0xFF); \
- ISSUE_DATA_BYTE((X) >> 8)
-#endif
-
#endif // TREZORHAL_DISPLAY_IO_H
### core/embed/io/display/i8080/display_nofb.c
@@ -107,6 +107,11 @@ static inline bool gfx_bitblt_check_dst_xy(const gfx_bitblt_t* bb) {
// to one with DMA2D while copying the other to the display with DMA.
void display_fill(const gfx_bitblt_t* bb) {
+ display_driver_t* drv = &g_display_driver;
+ // Local copy: the display write pointer could alias the driver struct,
+ // which would force a reload of pixel_endian after every pixel write
+ display_pixel_endian_t endian = drv->pixel_endian;
+
if (!gfx_bitblt_check_dst_xy(bb)) {
return;
}
@@ -117,12 +122,17 @@ void display_fill(const gfx_bitblt_t* bb) {
while (height-- > 0) {
for (int x = 0; x < bb->width; x++) {
- ISSUE_PIXEL_DATA(bb->src_fg);
+ ISSUE_PIXEL_DATA(endian, bb->src_fg);
}
}
}
void display_copy_rgb565(const gfx_bitblt_t* bb) {
+ display_driver_t* drv = &g_display_driver;
+ // Local copy: the display write pointer could alias the driver struct,
+ // which would force a reload of pixel_endian after every pixel write
+ display_pixel_endian_t endian = drv->pixel_endian;
+
if (!gfx_bitblt_check_dst_xy(bb) || !gfx_bitblt_check_src_x(bb, 16)) {
return;
}
@@ -134,13 +144,18 @@ void display_copy_rgb565(const gfx_bitblt_t* bb) {
while (height-- > 0) {
for (int x = 0; x < bb->width; x++) {
- ISSUE_PIXEL_DATA(src_ptr[x]);
+ ISSUE_PIXEL_DATA(endian, src_ptr[x]);
}
src_ptr += bb->src_stride / sizeof(*src_ptr);
}
}
void display_copy_mono1p(const gfx_bitblt_t* bb) {
+ display_driver_t* drv = &g_display_driver;
+ // Local copy: the display write pointer could alias the driver struct,
+ // which would force a reload of pixel_endian after every pixel write
+ display_pixel_endian_t endian = drv->pixel_endian;
+
if (!gfx_bitblt_check_dst_xy(bb) || !gfx_bitblt_check_src_x(bb, 1)) {
return;
}
@@ -155,7 +170,7 @@ void display_copy_mono1p(const gfx_bitblt_t* bb) {
for (int x = 0; x < bb->width; x++) {
uint8_t mask = 1 << (7 - ((src_ofs + x) & 7));
uint8_t data = src[(src_ofs + x) / 8];
- ISSUE_PIXEL_DATA((data & mask) ? bb->src_fg : bb->src_bg);
+ ISSUE_PIXEL_DATA(endian, (data & mask) ? bb->src_fg : bb->src_bg);
}
src_ofs += bb->src_stride;
}
### core/embed/io/display/i8080/display_panel.c
@@ -37,6 +37,11 @@
#define PANEL_INIT_SEQ dem240320b1_init_seq
#define PANEL_ROTATE dem240320b1_rotate
#define PANEL_REINIT dem240320b1_init_seq
+#elif defined(DISPLAY_PANEL_LX200B4501CTP03)
+#include "panels/lx200b4501ctp03.h"
+#define PANEL_INIT_SEQ lx200b4501ctp03_init_seq
+#define PANEL_ROTATE lx200b4501ctp03_rotate
+#define PANEL_REINIT lx200b4501ctp03_init_seq
#elif defined(DISPLAY_PANEL_LHS200KB_IF21)
#include "panels/lhs200kb-if21.h"
#define PANEL_INIT_SEQ lhs200kb_if21_init_seq
@@ -158,10 +163,11 @@ void display_panel_set_window(uint16_t x0, uint16_t y0, uint16_t x1,
}
}
-void display_panel_set_little_endian(void) {
+display_pixel_endian_t display_panel_set_little_endian(void) {
uint32_t id = display_panel_identify();
if (id == DISPLAY_ID_GC9307) {
- // CANNOT SET ENDIAN FOR GC9307
+ // CANNOT SET ENDIAN FOR GC9307, it expects the high byte first
+ return DISPLAY_PIXEL_BIG_ENDIAN;
} else if (id == DISPLAY_ID_ST7789V) {
ISSUE_CMD_BYTE(0xB0);
ISSUE_DATA_BYTE(0x00);
@@ -173,12 +179,13 @@ void display_panel_set_little_endian(void) {
ISSUE_DATA_BYTE(0x30);
ISSUE_DATA_BYTE(0x20);
}
+ return DISPLAY_PIXEL_LITTLE_ENDIAN;
}
-void display_panel_set_big_endian(void) {
+display_pixel_endian_t display_panel_set_big_endian(void) {
uint32_t id = display_panel_identify();
if (id == DISPLAY_ID_GC9307) {
- // CANNOT SET ENDIAN FOR GC9307
+ // CANNOT SET ENDIAN FOR GC9307, it is natively big-endian
} else if (id == DISPLAY_ID_ST7789V) {
ISSUE_CMD_BYTE(0xB0);
ISSUE_DATA_BYTE(0x00);
@@ -190,6 +197,7 @@ void display_panel_set_big_endian(void) {
ISSUE_DATA_BYTE(0x30);
ISSUE_DATA_BYTE(0x00);
}
+ return DISPLAY_PIXEL_BIG_ENDIAN;
}
#if defined(DISPLAY_PANEL_T2T1) && !defined(BOARDLOADER)
### core/embed/io/display/i8080/display_panel.h
@@ -31,6 +31,12 @@
// of ILI9341V datasheet
#define DISPLAY_ID_ILI9341V 0x009341U
+// Byte order of RGB565 pixel data expected by the panel
+typedef enum {
+ DISPLAY_PIXEL_LITTLE_ENDIAN, // low byte of each pixel first
+ DISPLAY_PIXEL_BIG_ENDIAN, // high byte of each pixel first
+} display_pixel_endian_t;
+
typedef struct {
uint16_t x;
uint16_t y;
@@ -45,8 +51,12 @@ void display_panel_init(void);
// Due to inability to change display setting in boardlaoder,
// we need to reinitialize the display when bootloader or firmware runs
void display_panel_reinit(void);
-void display_panel_set_little_endian(void);
-void display_panel_set_big_endian(void);
+// Configures the panel for little-endian pixel data where supported.
+// Returns the byte order the panel actually uses (GC9307: big-endian).
+display_pixel_endian_t display_panel_set_little_endian(void);
+// Configures the panel for big-endian pixel data.
+// Returns the byte order the panel actually uses (always big-endian).
+display_pixel_endian_t display_panel_set_big_endian(void);
void display_panel_sleep(void);
void display_panel_unsleep(void);
### core/embed/io/display/i8080/panels/lx200b4501ctp03.c
@@ -0,0 +1,185 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <trezor_model.h>
+
+#include "../display_io.h"
+#include "lx200b4501ctp03.h"
+
+#define MADCTL_MY (1U << 7U) // Row Address Order
+#define MADCTL_MX (1U << 6U) // Column Address Order
+#define MADCTL_MV (1U << 5U) // Row / Column Exchange
+#define MADCTL_ML (1U << 4U) // Vertical Refresh Order
+#define MADCTL_BGR (1U << 3U) // RGB-BGR Order
+#define MADCTL_MH (1U << 2U) // Horizontal Refresh Order
+
+#define MADCTL_DEFAULT (MADCTL_MX | MADCTL_BGR | MADCTL_MH)
+
+void lx200b4501ctp03_init_seq(void) {
+ // Inter Register Enable1 / Enable2
+ ISSUE_CMD_BYTE(0xFE);
+ ISSUE_CMD_BYTE(0xEF);
+
+ ISSUE_CMD_BYTE(0x36);
+ ISSUE_DATA_BYTE(MADCTL_DEFAULT);
+
+ // COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits
+ // input)
+ ISSUE_CMD_BYTE(0x3A);
+ ISSUE_DATA_BYTE(0x05);
+
+ ISSUE_CMD_BYTE(0x86);
+ ISSUE_DATA_BYTE(0x98);
+
+ ISSUE_CMD_BYTE(0x89);
+ ISSUE_DATA_BYTE(0x13);
+
+ ISSUE_CMD_BYTE(0x8B);
+ ISSUE_DATA_BYTE(0x80);
+
+ ISSUE_CMD_BYTE(0x8D);
+ ISSUE_DATA_BYTE(0x33);
+
+ ISSUE_CMD_BYTE(0x8E);
+ ISSUE_DATA_BYTE(0x0F);
+
+ // Frame Rate
+ ISSUE_CMD_BYTE(0xE8);
+ ISSUE_DATA_BYTE(0x13);
+ ISSUE_DATA_BYTE(0x00);
+
+ ISSUE_CMD_BYTE(0xEC);
+ ISSUE_DATA_BYTE(0x33);
+ ISSUE_DATA_BYTE(0x07);
+ ISSUE_DATA_BYTE(0x00);
+
+ ISSUE_CMD_BYTE(0xFF);
+ ISSUE_DATA_BYTE(0x62);
+
+ ISSUE_CMD_BYTE(0x99);
+ ISSUE_DATA_BYTE(0x3E);
+
+ ISSUE_CMD_BYTE(0x9D);
+ ISSUE_DATA_BYTE(0x4B);
+
+ ISSUE_CMD_BYTE(0x98);
+ ISSUE_DATA_BYTE(0x3E);
+
+ ISSUE_CMD_BYTE(0x9C);
+ ISSUE_DATA_BYTE(0x4B);
+
+ // Power Control 2
+ ISSUE_CMD_BYTE(0xC3);
+ ISSUE_DATA_BYTE(0x1A);
+
+ // Power Control 3
+ ISSUE_CMD_BYTE(0xC4);
+ ISSUE_DATA_BYTE(0x30);
+
+ // Power Control 4
+ ISSUE_CMD_BYTE(0xC9);
+ ISSUE_DATA_BYTE(0x2F);
+
+ // Column Address Set: 0 .. 239
+ ISSUE_CMD_BYTE(0x2A);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0xEF);
+
+ // Row Address Set: 0 .. 319
+ ISSUE_CMD_BYTE(0x2B);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0x01);
+ ISSUE_DATA_BYTE(0x3F);
+
+ ISSUE_CMD_BYTE(0x2C);
+
+ // SET_GAMMA1
+ ISSUE_CMD_BYTE(0xF0);
+ ISSUE_DATA_BYTE(0x15);
+ ISSUE_DATA_BYTE(0x17);
+ ISSUE_DATA_BYTE(0x07);
+ ISSUE_DATA_BYTE(0x09);
+ ISSUE_DATA_BYTE(0x07);
+ ISSUE_DATA_BYTE(0x32);
+
+ // SET_GAMMA3
+ ISSUE_CMD_BYTE(0xF2);
+ ISSUE_DATA_BYTE(0x15);
+ ISSUE_DATA_BYTE(0x17);
+ ISSUE_DATA_BYTE(0x07);
+ ISSUE_DATA_BYTE(0x09);
+ ISSUE_DATA_BYTE(0x07);
+ ISSUE_DATA_BYTE(0x3B);
+
+ // SET_GAMMA2
+ ISSUE_CMD_BYTE(0xF1);
+ ISSUE_DATA_BYTE(0x45);
+ ISSUE_DATA_BYTE(0x8E);
+ ISSUE_DATA_BYTE(0x95);
+ ISSUE_DATA_BYTE(0x28);
+ ISSUE_DATA_BYTE(0x2A);
+ ISSUE_DATA_BYTE(0x7F);
+
+ // SET_GAMMA4
+ ISSUE_CMD_BYTE(0xF3);
+ ISSUE_DATA_BYTE(0x4E);
+ ISSUE_DATA_BYTE(0x8E);
+ ISSUE_DATA_BYTE(0x95);
+ ISSUE_DATA_BYTE(0x28);
+ ISSUE_DATA_BYTE(0x2A);
+ ISSUE_DATA_BYTE(0x7F);
+
+ // TEON: Tearing Effect Line On; V-blanking only
+ ISSUE_CMD_BYTE(0x35);
+ ISSUE_DATA_BYTE(0x00);
+
+ // Tearing scanline
+ ISSUE_CMD_BYTE(0x44);
+ ISSUE_DATA_BYTE(0x00);
+ ISSUE_DATA_BYTE(0x0A);
+}
+
+void lx200b4501ctp03_rotate(int degrees, display_padding_t* padding) {
+ uint8_t madctl_val = MADCTL_DEFAULT;
+
+ switch (degrees) {
+ case 0:
+ // Nothing to change.
+ break;
+ case 90:
+ madctl_val ^= (MADCTL_MV | (MADCTL_MX | MADCTL_MH));
+ break;
+ case 180:
+ madctl_val ^= ((MADCTL_MY | MADCTL_ML) | (MADCTL_MX | MADCTL_MH));
+ break;
+ case 270:
+ madctl_val ^= (MADCTL_MV | (MADCTL_MY | MADCTL_ML));
+ break;
+ }
+
+ ISSUE_CMD_BYTE(0x36);
+ ISSUE_DATA_BYTE(madctl_val);
+
+ // Full 240x320 panel - no window offset in any orientation.
+ padding->x = 0;
+ padding->y = 0;
+}
### core/embed/io/display/i8080/panels/lx200b4501ctp03.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "../display_panel.h"
+
+void lx200b4501ctp03_init_seq(void);
+void lx200b4501ctp03_rotate(int degrees, display_padding_t* padding);
### core/embed/io/touch/build.rs
@@ -58,6 +58,10 @@ fn set_panel_lx154a2422cpt23(lib: &mut CLibrary) {
lib.add_define("TOUCH_PANEL_LX154A2422CPT23", Some("1"));
}
+fn set_panel_lx200b4501ctp03(lib: &mut CLibrary) {
+ lib.add_define("TOUCH_PANEL_LX200B4501CTP03", Some("1"));
+}
+
fn set_panel_lx250a2410a(lib: &mut CLibrary) {
lib.add_define("TOUCH_PANEL_LX250A2410A", Some("1"));
}
@@ -74,6 +78,9 @@ fn add_driver_ft6x36(lib: &mut CLibrary) -> Result<()> {
} else if cfg!(feature = "touch_panel_lx154a2422cpt23") {
set_panel_lx154a2422cpt23(lib);
lib.add_source("touch/ft6x36/panels/lx154a2422cpt23.c");
+ } else if cfg!(feature = "touch_panel_lx200b4501ctp03") {
+ set_panel_lx200b4501ctp03(lib);
+ lib.add_source("touch/ft6x36/panels/lx200b4501ctp03.c");
} else {
bail_unsupported!();
}
### core/embed/io/touch/ft6x36/ft6x36.c
@@ -30,6 +30,8 @@
#ifdef TOUCH_PANEL_LX154A2422CPT23
#include "panels/lx154a2422cpt23.h"
+#elif defined TOUCH_PANEL_LX200B4501CTP03
+#include "panels/lx200b4501ctp03.h"
#elif defined TOUCH_PANEL_LHS200KB_IF21
#include "panels/lhs200kb-if21.h"
#endif
@@ -255,6 +257,8 @@ static void ft6x36_panel_correction(uint16_t x, uint16_t y, uint16_t* x_new,
uint16_t* y_new) {
#ifdef TOUCH_PANEL_LX154A2422CPT23
lx154a2422cpt23_touch_correction(x, y, x_new, y_new);
+#elif defined TOUCH_PANEL_LX200B4501CTP03
+ lx200b4501ctp03_touch_correction(x, y, x_new, y_new);
#elif defined TOUCH_PANEL_LHS200KB_IF21
lhs200kb_if21_touch_correction(x, y, x_new, y_new);
#else
### core/embed/io/touch/ft6x36/panels/lx200b4501ctp03.c
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// TODO: Calibrate the touch panel (i.e. correction function, etc.).
+
+#include "lx200b4501ctp03.h"
+
+void lx200b4501ctp03_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new,
+ uint16_t *y_new) {
+ *x_new = x;
+ *y_new = y;
+}
### core/embed/io/touch/ft6x36/panels/lx200b4501ctp03.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <trezor_types.h>
+
+// Performs touch coordinates correction needed for a specific panel.
+// Input parameters x, y represent the original touch coordinates.
+// Output parameters x_new, y_new represent the corrected touch coordinates.
+void lx200b4501ctp03_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new,
+ uint16_t *y_new);
### core/embed/models/T3T2/boards/devkit.h
@@ -2,8 +2,13 @@
#define VDD_3V3 1
-// ST7789 (Display Elektronik DEM240320B1) over 16-bit i8080 FMC bus.
+// GC9307C (LX200B4501CTP03A/B) over i8080 FMC bus.
// The module has no tearing-effect (TE) output, so no DISPLAY_TE_* defines.
+// The following macros for bus widths are mutually exclusive. Only one at
+// a time shall be defined.
+// For 8-bit mode, use:
+// #define DISPLAY_I8080_8BIT_DW 1
+// For 16-bit mode, use:
#define DISPLAY_I8080_16BIT_DW 1
// Use a single framebuffer on this project (lower RAM use; there is no TE
@@ -25,6 +30,21 @@
#define DISPLAY_PWR_PORT GPIOF
#define DISPLAY_PWR_PIN GPIO_PIN_15
+// Display interface-mode select pins (IM0-IM2).
+#define DISPLAY_IM0_PORT GPIOF
+#define DISPLAY_IM0_PIN GPIO_PIN_11
+#ifdef DISPLAY_I8080_16BIT_DW
+#define DISPLAY_IM0_VAL GPIO_PIN_SET
+#else
+#define DISPLAY_IM0_VAL GPIO_PIN_RESET
+#endif
+#define DISPLAY_IM1_PORT GPIOF
+#define DISPLAY_IM1_PIN GPIO_PIN_14
+#define DISPLAY_IM1_VAL GPIO_PIN_RESET
+#define DISPLAY_IM2_PORT GPIOG
+#define DISPLAY_IM2_PIN GPIO_PIN_1
+#define DISPLAY_IM2_VAL GPIO_PIN_RESET
+
// Backlight: four LED strings driven as synchronized active-low PWM by
// TIM3 CH1-CH4 on PE3-PE6 (cathodes via 33R), with a common boost supply.
#define BACKLIGHT_PWM_TIM TIM3
@@ -97,6 +117,8 @@
#define TOUCH_SENSITIVITY 0x40
#define TOUCH_I2C_INSTANCE 0
+#define TOUCH_RST_PORT GPIOC
+#define TOUCH_RST_PIN GPIO_PIN_2 // DISPL_MISO in schematic rev. A
#define TOUCH_INT_PORT GPIOB
#define TOUCH_INT_PIN GPIO_PIN_11
#define TOUCH_ON_PORT GPIOG
### core/embed/models/T3T2/boards/devkit.toml
@@ -3,14 +3,14 @@ emulator_header = "T3T2/boards/unix.h"
[display]
driver = "io/display_i8080"
-panel = "io/display_panel_dem240320b1"
+panel = "io/display_panel_lx200b4501ctp03"
[backlight]
driver = "io/backlight_pwm"
[touch]
driver = "io/touch_ft6x36"
-panel = "io/touch_panel_lx154a2422cpt23"
+panel = "io/touch_panel_lx200b4501ctp03"
[optiga]
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.