Skip to content

Commit

Permalink
doc: recommend turn on psram xip feature for bounbe buffer mode
Browse files Browse the repository at this point in the history
  • Loading branch information
suda-morris committed Dec 16, 2022
1 parent 07d6533 commit 6d22959
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
4 changes: 0 additions & 4 deletions components/esp_lcd/src/esp_lcd_panel_rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_conf
ESP_ERR_INVALID_ARG, err, TAG, "must set bounce buffer if there's no frame buffer");
ESP_GOTO_ON_FALSE(!(rgb_panel_config->flags.refresh_on_demand && rgb_panel_config->bounce_buffer_size_px),
ESP_ERR_INVALID_ARG, err, TAG, "refresh on demand is not supported under bounce buffer mode");
#if CONFIG_LCD_RGB_ISR_IRAM_SAFE
ESP_GOTO_ON_FALSE(rgb_panel_config->bounce_buffer_size_px == 0,
ESP_ERR_INVALID_ARG, err, TAG, "bounce buffer mode is not IRAM Safe");
#endif

// determine number of framebuffers
size_t num_fbs = 1;
Expand Down
3 changes: 0 additions & 3 deletions components/esp_lcd/test_apps/rgb_lcd/main/test_rgb_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ TEST_CASE("lcd_rgb_panel_refresh_on_demand", "[lcd]")
free(img);
}

#if !CONFIG_LCD_RGB_ISR_IRAM_SAFE
// bounce buffer mode is not IRAM safe, so we don't test it
TEST_CASE("lcd_rgb_panel_bounce_buffer", "[lcd]")
{
uint8_t *img = malloc(TEST_IMG_SIZE);
Expand All @@ -184,7 +182,6 @@ TEST_CASE("lcd_rgb_panel_bounce_buffer", "[lcd]")
TEST_ESP_OK(esp_lcd_panel_del(panel_handle));
free(img);
}
#endif

TEST_CASE("lcd_rgb_panel_update_pclk", "[lcd]")
{
Expand Down
2 changes: 2 additions & 0 deletions components/esp_lcd/test_apps/rgb_lcd/sdkconfig.ci.iram_safe
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
CONFIG_COMPILER_DUMP_RTL_FILES=y
CONFIG_LCD_RGB_ISR_IRAM_SAFE=y
CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y
# bounce buffer mode relies on GDMA EOF interrupt to be service-able
CONFIG_GDMA_ISR_IRAM_SAFE=y
CONFIG_COMPILER_OPTIMIZATION_NONE=y
# silent the error check, as the error string are stored in rodata, causing RTL check failure
CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_80M=y

# Enable the XIP-PSRAM feature, so the ext-mem cache won't be disabled when SPI1 is operating the main flash
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
6 changes: 5 additions & 1 deletion docs/en/api-reference/peripherals/lcd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ More LCD panel drivers and touch drivers are available in `IDF Component Registr
Bounce Buffer with Single PSRAM Frame Buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This mode allocates two so-called ``bounce buffers`` from the internal memory, and a main frame buffer that is still in PSRAM. This mode is selected by setting the :cpp:member:`esp_lcd_rgb_panel_config_t::fb_in_psram` flag and additionally specifying a non-zero :cpp:member:`esp_lcd_rgb_panel_config_t::bounce_buffer_size_px` value. The bounce buffers only need to be large enough to hold a few lines of display data, which is significantly less than the main frame buffer. The LCD peripheral will use DMA to read data from one of the bounce buffers, and meanwhile an interrupt routine will use the CPU DCache to copy data from the main PSRAM frame buffer into the other bounce buffer. Once the LCD peripheral has finished reading the bounce buffer, the two buffers change place and the CPU can fill the others. The advantage of this mode is that, you can achieve higher pixel clock frequency. As the bounce buffers are larger than the FIFOs in the EDMA path, this method is also more robust against short bandwidth spikes. The downside is a major increase in CPU use and the LCD **CAN'T** work if the cache is disabled by flash operations, e.g. OTA or NVS write.
This mode allocates two so-called ``bounce buffers`` from the internal memory, and a main frame buffer that is still in PSRAM. This mode is selected by setting the :cpp:member:`esp_lcd_rgb_panel_config_t::fb_in_psram` flag and additionally specifying a non-zero :cpp:member:`esp_lcd_rgb_panel_config_t::bounce_buffer_size_px` value. The bounce buffers only need to be large enough to hold a few lines of display data, which is significantly less than the main frame buffer. The LCD peripheral will use DMA to read data from one of the bounce buffers, and meanwhile an interrupt routine will use the CPU DCache to copy data from the main PSRAM frame buffer into the other bounce buffer. Once the LCD peripheral has finished reading the bounce buffer, the two buffers change place and the CPU can fill the others. The advantage of this mode is that, you can achieve higher pixel clock frequency. As the bounce buffers are larger than the FIFOs in the EDMA path, this method is also more robust against short bandwidth spikes. The downside is a major increase in CPU use and the LCD **CAN'T** work if we disable the cache of the external memory, via e.g. OTA or NVS write to the main flash.

.. note::

It's highly recommended to turn on the "PSRAM XIP (Execute In Place)" feature in this mode by enabling the Kconfig options: :ref:`CONFIG_SPIRAM_FETCH_INSTRUCTIONS` and :ref:`CONFIG_SPIRAM_RODATA`, which allows the CPU to fetch instructions and readonly data from the PSRAM instead of the main flash. What's more, the external memory cache won't be disabled even if you attempt to write to the main flash through SPI1. This makes it possible to display an OTA progress bar for your application.

.. code:: c
Expand Down

0 comments on commit 6d22959

Please sign in to comment.