Solution for Separating LCD Parameters from Kernel into U-Boot on AM335X
1. Principle
By default, LCD parameters are configured separately in both U-Boot and the Linux kernel. However, this approach lacks flexibility, as any change in the LCD configuration requires recompilation of U-Boot and the kernel. The solution involves separating LCD parameters and storing them as U-Boot environment variables in flash memory. During the initialization of the LCD in both U-Boot and the kernel, parameters are read from these environment variables. This eliminates the need for recompilation when changing LCD screens—only the U-Boot environment variables need to be updated.
Figure 1 LCD display parameters
2. Steps to Separate LCD Parameters in U-Boot
LCD Environment Variable Configuration
The configuration for LCD environment variables is stored in the file config-lcd-env-RecordedScript.vbs.
LCD Parameter | Environment Variable Name | Value Range |
Name | ename | (string) !NULL |
Refresh | erefresh | (u32) > 1 |
Pixels Per Line | ewidth | (u32) > 1 |
Lines Per Panel | eheight | (u32) > 1 |
Horizontal Sync Pulse Width | ehsw | (u32) > 1 |
Horizontal Front Porch | ehfp | (u32) > 1 |
Horizontal Back Porch | ehbp | (u32) > 1 |
Vertical Sync Pulse Width | evsw | (u32) > 1 |
Vertical Front Porch | evfp | (u32) > 1 |
Vertical Back Porch | evbp | (u32) > 1 |
Invert Pixel Clock | eipc | (bool) 0,1 |
Invert Hsync | eihs | (bool) 0,1 |
Invert Vsync | eivs | (bool) 0,1 |
Program HSYNC/VSYNC Rise or Fall | esync | (bool) 0,1 |
For detailed register settings, refer to RASTER_TIMING_0, RASTER_TIMING_1, and RASTER_TIMING_2.
3. LCD Initialization Code in U-Boot
The LCD initialization code is located in 0001-sm-uboot-lcd-logo.patch.
3.1 Add CONFIG_SHOW_LOGO option,Refer to include/configs/am335x_evm.h.
3.2 Modify LCD pin configurations,Refer to board/ti/am335x/mux.c.
3.3 Add LCD section during clock initialization,Refer to arch/arm/include/asm/arch-ti81xx/cpu.h.
3.4 Retrieve LCD parameters,Refer to the get_fb_param() function in common/show_logo.c.
3.5 Initialize LCD,Refer to the fb_init() and dma_init() functions in common/show_logo.c.
4. Steps to Separate LCD Parameters in the Kernel
4.1 LCD Environment Variable Configuration in the Kernel
●Configure the lcdcfg environment variable. Refer to config-lcd-env-RecordedScript.vbs.
●Add the lcdcfg variable to the kernel boot arguments. Refer to boot-from-nand-RecordedScript.vbs.
4.2 LCD Initialization Code in the Kernel
The LCD initialization code is located in 0001-sm-kernel-lcd-logo.patch.
●Add the CONFIG_FB_USE_ENV configuration option.Refer to drivers/video/Kconfig.
●Retrieve LCD parameters and initialize the LCD.Refer to drivers/video/da8xx-fb.c.
Conclusion
Separating the LCD parameters into U-Boot environment variables adds significant flexibility to the AM335X system. It allows developers to change the LCD configuration without recompiling U-Boot or the kernel, streamlining the development process and simplifying screen replacement.
Weathink Electronics, as an official TI partner, specializes in TI MPU processors and provides industrial-grade AM335X core boards widely used in serial servers, multi-port gateways, and other applications. For more information or inquiries, feel free to contact us.