Repository: espressif/esp-bsp
Pull request #535: bsp(esp-box-3): Add support for noglib.
Author: login: espzav
Created: 2025-03-06T12:50:38Z | Merged: 2025-03-21T06:37:08Z

# ESP-BSP Pull Request checklist

- [ ] Version of modified component bumped
- [ ] CI passing

# Change description

Related to #534 (Cannot be closed, it is related to another board)


Diff:
diff --git a/.github/workflows/upload_component_noglib.yml b/.github/workflows/upload_component_noglib.yml
index c643391b0..07b750447 100644
--- a/.github/workflows/upload_component_noglib.yml
+++ b/.github/workflows/upload_component_noglib.yml
@@ -16,7 +16,7 @@ jobs:
       - name: Upload noglib version of BSPs
         # TODO: Extend this part to all BSPs
         env:
-          BSPs: "bsp/esp_wrover_kit bsp/esp32_s3_eye bsp/esp32_p4_function_ev_board bsp/m5stack_core_s3 bsp/m5stack_core_2 bsp/m5dial bsp/m5_atom_s3"
+          BSPs: "bsp/esp_wrover_kit bsp/esp32_s3_eye bsp/esp32_p4_function_ev_board bsp/m5stack_core_s3 bsp/m5stack_core_2 bsp/m5dial bsp/m5_atom_s3 bsp/esp-box-3"
         run: |
           pip install idf-component-manager==1.* py-markdown-table --upgrade
           python .github/ci/bsp_noglib.py ${BSPs}
@@ -29,6 +29,7 @@ jobs:
             bsp/m5dial_noglib;
             bsp/esp_wrover_kit_noglib;
             bsp/m5_atom_s3_noglib;
+            bsp/esp-box-3_noglib;
           namespace: "espressif"
           api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
           dry_run: ${{ github.ref_name != 'master' || github.repository_owner != 'espressif' }}
diff --git a/bsp/esp-box-3/esp-box-3.c b/bsp/esp-box-3/esp-box-3.c
index 50c0ceaee..94f16424e 100644
--- a/bsp/esp-box-3/esp-box-3.c
+++ b/bsp/esp-box-3/esp-box-3.c
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -23,7 +23,6 @@
 #include "esp_lcd_touch_tt21100.h"
 #include "esp_lcd_touch_gt911.h"
 #include "esp_lcd_ili9341.h"
-#include "esp_lvgl_port.h"
 #include "bsp_err_check.h"
 #include "esp_codec_dev_defaults.h"
 
@@ -53,10 +52,13 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
     {0, (uint8_t []){0}, 0xff, 0},
 };
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static lv_display_t *disp;
 static lv_indev_t *disp_indev = NULL;
-static esp_lcd_touch_handle_t tp;   // LCD touch handle
 static esp_lcd_panel_handle_t panel_handle = NULL;
+#endif // (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
+
+static esp_lcd_touch_handle_t tp;   // LCD touch handle
 sdmmc_card_t *bsp_sdcard = NULL;    // Global SD card handler
 
 /**
@@ -347,6 +349,7 @@ esp_err_t bsp_display_backlight_on(void)
     return bsp_display_brightness_set(100);
 }
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static esp_err_t bsp_lcd_enter_sleep(void)
 {
     assert(panel_handle);
@@ -358,6 +361,7 @@ static esp_err_t bsp_lcd_exit_sleep(void)
     assert(panel_handle);
     return esp_lcd_panel_disp_on_off(panel_handle, true);
 }
+#endif // (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 
 esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io)
 {
@@ -428,6 +432,7 @@ esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_hand
     return ret;
 }
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static lv_display_t *bsp_display_lcd_init(const bsp_display_cfg_t *cfg)
 {
     assert(cfg != NULL);
@@ -623,6 +628,7 @@ esp_err_t bsp_display_exit_sleep(void)
     BSP_ERROR_CHECK_RETURN_ERR(bsp_touch_exit_sleep());
     return ESP_OK;
 }
+#endif // (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 
 static uint8_t bsp_get_main_button(void *param)
 {
diff --git a/bsp/esp-box-3/include/bsp/config.h b/bsp/esp-box-3/include/bsp/config.h
new file mode 100644
index 000000000..0855a9763
--- /dev/null
+++ b/bsp/esp-box-3/include/bsp/config.h
@@ -0,0 +1,16 @@
+/*
+ * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#pragma once
+
+/**************************************************************************************************
+ * BSP configuration
+ **************************************************************************************************/
+// By default, this BSP is shipped with LVGL graphical library. Enabling this option will exclude it.
+// If you want to use BSP without LVGL, select BSP version with 'noglib' suffix.
+#if !defined(BSP_CONFIG_NO_GRAPHIC_LIB) // Check if the symbol is not coming from compiler definitions (-D...)
+#define BSP_CONFIG_NO_GRAPHIC_LIB (0)
+#endif
diff --git a/bsp/esp-box-3/include/bsp/esp-box-3.h b/bsp/esp-box-3/include/bsp/esp-box-3.h
index 1db4c6056..ce651f6c3 100644
--- a/bsp/esp-box-3/include/bsp/esp-box-3.h
+++ b/bsp/esp-box-3/include/bsp/esp-box-3.h
@@ -16,12 +16,16 @@
 #include "driver/i2s_std.h"
 #include "driver/i2c_master.h"
 #include "driver/sdmmc_host.h"
-#include "lvgl.h"
-#include "esp_lvgl_port.h"
 #include "esp_codec_dev.h"
 #include "iot_button.h"
+#include "bsp/config.h"
 #include "bsp/display.h"
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
+#include "lvgl.h"
+#include "esp_lvgl_port.h"
+#endif // BSP_CONFIG_NO_GRAPHIC_LIB == 0
+
 /**************************************************************************************************
  *  BSP Capabilities
  **************************************************************************************************/
@@ -128,20 +132,6 @@ typedef enum {
 extern "C" {
 #endif
 
-/**
- * @brief BSP display configuration structure
- *
- */
-typedef struct {
-    lvgl_port_cfg_t lvgl_port_cfg;  /*!< LVGL port configuration */
-    uint32_t        buffer_size;    /*!< Size of the buffer for the screen in pixels */
-    bool            double_buffer;  /*!< True, if should be allocated two buffers */
-    struct {
-        unsigned int buff_dma: 1;    /*!< Allocated LVGL buffer will be DMA capable */
-        unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */
-    } flags;
-} bsp_display_cfg_t;
-
 /**************************************************************************************************
  *
  * I2S audio interface
@@ -337,6 +327,22 @@ esp_err_t bsp_sdcard_unmount(void);
 #define BSP_LCD_PIXEL_CLOCK_HZ     (40 * 1000 * 1000)
 #define BSP_LCD_SPI_NUM            (SPI3_HOST)
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
+
+/**
+ * @brief BSP display configuration structure
+ *
+ */
+typedef struct {
+    lvgl_port_cfg_t lvgl_port_cfg;  /*!< LVGL port configuration */
+    uint32_t        buffer_size;    /*!< Size of the buffer for the screen in pixels */
+    bool            double_buffer;  /*!< True, if should be allocated two buffers */
+    struct {
+        unsigned int buff_dma: 1;    /*!< Allocated LVGL buffer will be DMA capable */
+        unsigned int buff_spiram: 1; /*!< Allocated LVGL buffer will be in PSRAM */
+    } flags;
+} bsp_display_cfg_t;
+
 /**
  * @brief Initialize display
  *
@@ -414,6 +420,7 @@ esp_err_t bsp_display_exit_sleep(void);
  * @param[in] rotation Angle of the display rotation
  */
 void bsp_display_rotate(lv_display_t *disp, lv_disp_rotation_t rotation);
+#endif // BSP_CONFIG_NO_GRAPHIC_LIB == 0
 /**************************************************************************************************
  *
  * Button


Reviews:
user: login: tore-espressif
body: Thank you @espzav ! Few details missing
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-03-19T07:19:00Z
user: login: tore-espressif
body: @espzav Thank you for the update, there is one more problem remaining

Sorry, I'll think about how can we test the noglib version before release...
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-03-20T14:05:10Z
user: login: espzav
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-20T14:18:16Z
user: login: tore-espressif
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-20T14:31:27Z

Review comments:
diff_hunk: @@ -16,12 +16,15 @@
 #include "driver/i2s_std.h"
 #include "driver/i2c_master.h"
 #include "driver/sdmmc_host.h"
-#include "lvgl.h"
-#include "esp_lvgl_port.h"
 #include "esp_codec_dev.h"
 #include "iot_button.h"
 #include "bsp/display.h"
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
path: bsp/esp-box-3/include/bsp/esp-box-3.h
user: login: tore-espressif
body: Missing `#include "bsp/config.h"` for `BSP_CONFIG_NO_GRAPHIC_LIB` symbol
created_at: 2025-03-19T07:13:54Z
author_association: COLLABORATOR
diff_hunk: @@ -16,12 +16,15 @@
 #include "driver/i2s_std.h"
 #include "driver/i2c_master.h"
 #include "driver/sdmmc_host.h"
-#include "lvgl.h"
-#include "esp_lvgl_port.h"
 #include "esp_codec_dev.h"
 #include "iot_button.h"
 #include "bsp/display.h"
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
+#include "lvgl.h"
+#include "esp_lvgl_port.h"
+#endif // BSP_CONFIG_NO_GRAPHIC_LIB == 0
path: bsp/esp-box-3/include/bsp/esp-box-3.h
user: login: tore-espressif
body: Definition of `bsp_display_cfg_t` must be moved into this section too
created_at: 2025-03-19T07:15:14Z
author_association: COLLABORATOR
diff_hunk: @@ -53,8 +53,11 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
     {0, (uint8_t []){0}, 0xff, 0},
 };
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static lv_display_t *disp;
 static lv_indev_t *disp_indev = NULL;
+#endif // (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
+
 static esp_lcd_touch_handle_t tp;   // LCD touch handle
 static esp_lcd_panel_handle_t panel_handle = NULL;
path: bsp/esp-box-3/esp-box-3.c
user: login: tore-espressif
body: Relevant only when LVGL is used. Please move to `#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)` section
created_at: 2025-03-19T07:15:53Z
author_association: COLLABORATOR
path: bsp/esp-box-3/esp-box-3.c
user: login: tore-espressif
body: Other changes that I cannot comment on in Github:

Line 26: Please remove `#include "esp_lvgl_port.h"`. It will be conditionally included from `bsp/esp-box-3.h` depending on `BSP_CONFIG_NO_GRAPHIC_LIB` value

 
created_at: 2025-03-19T07:18:39Z
author_association: COLLABORATOR
diff_hunk: @@ -53,10 +52,13 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
     {0, (uint8_t []){0}, 0xff, 0},
 };
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static lv_display_t *disp;
 static lv_indev_t *disp_indev = NULL;
 static esp_lcd_touch_handle_t tp;   // LCD touch handle
path: bsp/esp-box-3/esp-box-3.c
user: login: tore-espressif
body: `tp` is used in noglib version :(

only `panel_handle` is not
created_at: 2025-03-20T14:03:14Z
author_association: COLLABORATOR
diff_hunk: @@ -53,10 +52,13 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
     {0, (uint8_t []){0}, 0xff, 0},
 };
 
+#if (BSP_CONFIG_NO_GRAPHIC_LIB == 0)
 static lv_display_t *disp;
 static lv_indev_t *disp_indev = NULL;
 static esp_lcd_touch_handle_t tp;   // LCD touch handle
path: bsp/esp-box-3/esp-box-3.c
user: login: espzav
body: You mean used in main button? Sure, I am sorry, I overlooked it.
created_at: 2025-03-20T14:18:16Z
author_association: COLLABORATOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-03-06T13:58:46Z
body: ## Test Results
 19 files  19 suites   6m 17s ⏱️
 76 tests 26 ✅  50 💤 0 ❌
494 runs  26 ✅ 468 💤 0 ❌

Results for commit c223da07.

[test-results]:data:application/gzip;base64,H4sIABA/3GcC/1XMSw7CIBSF4a00jB20gBdwMwYvkBD7MBRGjXv31rYWh/93krOwEHs/s1vTmUvD5hLzWa4km+M0UgulCGjL66rgiPtcEEl4Jc/4Irm2Pwk29iQn+JSmtEsq43opjdzj73KD7VGCPqR6/HZ9iNMwxEzBkHPhbKtUAIAAAjspW80779B69TAcuUMNgr0/8gZKEwcBAAA=

:recycle: This comment has been updated with latest results.
author_association: NONE
user: login: espzav
created_at: 2025-03-06T14:27:03Z
body: @tore-espressif PTAL
author_association: COLLABORATOR
user: login: espzav
created_at: 2025-03-19T13:26:28Z
body: @tore-espressif Thank you for review. Updated.
author_association: COLLABORATOR
user: login: espzav
created_at: 2025-03-20T14:15:03Z
body: > @espzav Thank you for the update, there is one more problem remaining
> 
> Sorry, I'll think about how can we test the noglib version before release...

Oh sorry, I didn't test it. I agrre, we should make some tests for noglib. I wanted to add new example for noglib and some script, which will make noglib before merge for testing. 

author_association: COLLABORATOR