Skip to content

Adding new screen support

Wenting Zhang edited this page Mar 25, 2022 · 3 revisions

This steps requires you to access U-Boot prompt, build and run Linux kernel, and modify the initrd. It's recommended to use the USB boot mode for this and later deploy things to an SD card.

Updating kernel

The first step is to add the timing parameters to the kernel source. Ideally these things should be brought to the device tree, but NXP decided to keep them directly in the kernel source.

The timings are defined in drivers/video/fbdev/mxc/mxc_epdc_v2_fb.c. It includes the resolution information. Usually the timing could be found from the screen specification, but it might not match the waveform. There are 3 important parameters in the timing: resolution, refresh rate, and duty cycle. The other parameters could be chose freely (within certain ranges) without affecting the image quality.

NOTE: In the mxc_epdc_v2_fb.c, the pixel clock is the DDR clock, in SDR mode it needs to be doubled. For example, setting it to 66MHz actually generates a 33MHz pixel clock. The applies to data rate only, the timing is still calculated at double frequency.

For example, the example configuration for ED060XH2C1:

CLK: 40 MHz XRES: 1024 YRES: 758 Left Margin (Line Begin, LB): 12 Right Margin (Line End, LE): 76 Upper Margin (Frame Begin, FB): 4 Lower Margin (Frame End, FE): 5 Hsync Width (Line Sync, LS): 12 Vsync Width (Frame Sync, FS), 2 GDCLK_HP: 524

It is a 8 bit screen, so it transfer 4 pixels per clock, but because the clock is doubled, it only transfers 2 pixels. The total line time is 1024/2 + 12 + 76 + 12 = 612 clocks, and the frame rate is 40000000 / (612 * (758 + 4 + 5 + 2)) = 84.99 Hz. So it would work with a 85 Hz waveform. The GDCLK_HP controls the duty cycle, 524 / 612 ~= 85% duty cycle.

Here for example, to add support for ED103TC2. The first step is to determine the desired framerate. This should match the waveform, let's start with 85Hz. Once that's decided, choose an appropriate clock frequency. The clock frequency offered by EPDC driver is in fairly large steps:

32MHz\ 40MHz\ 60MHz\ 80MHz\ 96MHz\ 132MHz\ 160MHz

The ED103TC2 specifies a maximum clock frequency of 83.33MHz, so the maximum value could be used at EPDC side is 166MHz.

Generally the process is to choose the lowest possible clock frequency that gives the target framerate, and fine tune the blanking to get the desired framerate. You could use this spreadsheet file to play with the numbers: https://github.com/zephray/NekoInk/blob/master/utils/epd_timing.ods

If your screen uses an 8-bit interface, remember to update the spreadsheet. In the driver, also specify the bit width to 8-bit (looking for EPDC_TCE_CTRL_SDDO_WIDTH_16BIT, change that to 8BIT).

See https://github.com/zephray/linux-imx/commit/01257120d3c502bd457c9b8eed09c725903c0355 for examples about updating the driver.

Setting the timing to invalid values (such as zero sync width, over one period sync location etc.) could cause screen to not refresh at all (Mode0 init failed), or timeout during refresh.

Setting the timing to inappropriate values (too high or too low refresh rate, too short blanking, etc.) could cause screen to not display greyscales properly, having strange bars on screen, showing image with offset, etc. But generally it should display recognizable image in these cases.

Updating initrd

The Eink/ DES screen needs an accompanying waveform file to work properly. Updating the kernel without supplying waveform file at all could cause irreversible damage to the screen. It's required to at least provide something for the kernel to use. To get started, simply rename the waveform file for GDEW101C01 to the model number of your screen and put in the target folder. The name should be like epdc_MODEL.fw.

If you are using buildroot to run Linux from USB, put the file into target/output/lib/firmware/imx/epdc folder.

If you are using some other linux distribution, refers to the distribution documentation about how to update the initrd.

Updating u-boot

The screen model used by the kernel is passed in the kernel command line. This needs to be modified in u-boot.

When sideloading from USB, this could be simply changed in the uuu script.

In a normal boot, U-boot reads the cmdline from SPI Flash, and the easiest way of changing that is to go into the U-boot prompt:

Use setenv bootargs epdc video=mxcepdcfb:GDEW101C01,bpp=8 to set new environment

Use printenv to view the current variables.

Use saveenv to save the updated variables to the SPI Flash.