From 9fe1017b2291e6d3c07ab93ff999357842c56685 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 20 Jul 2024 00:09:39 +0200 Subject: [PATCH] feat(hardware): Add support for board Freenove ESP32S3 (and compatible) --- code/include/defines.h | 100 ++++++++++++++++++++++++++++++++++++++--- code/platformio.ini | 91 ++++++++++++++++++++++++++++++++++++- 2 files changed, 184 insertions(+), 7 deletions(-) diff --git a/code/include/defines.h b/code/include/defines.h index 3a4b86bd2..b57d7e710 100644 --- a/code/include/defines.h +++ b/code/include/defines.h @@ -315,11 +315,16 @@ CONFIG_WPA_11R_SUPPORT=n //************************************ #if ENV_BOARD_TYPE == 1 #define BOARD_AITHINKER_ESP32CAM -#define BOARD_TYPE_NAME "ESP32CAM" // Keep Board type equal to main board environment name +#define BOARD_TYPE_NAME "ESP32CAM" // Keep Board type equal to main board environment name // This is used for OTA update package verification (converted to lower case) #elif ENV_BOARD_TYPE == 2 #define BOARD_XIAO_ESP32S3 -#define BOARD_TYPE_NAME "XIAO-ESP32S3-Sense" // Keep Board type equal to main board environment name. +#define BOARD_TYPE_NAME "XIAO-ESP32S3-Sense" // Keep Board type equal to main board environment name. + // This is used for OTA update package verification (converted to lower case) + +#elif ENV_BOARD_TYPE == 3 +#define BOARD_FREENOVE_ESP32S3 +#define BOARD_TYPE_NAME "Freenove-ESP32S3" // Keep Board type equal to main board environment name. // This is used for OTA update package verification (converted to lower case) #else #error "Board type (ENV_BOARD_TYPE) not defined" @@ -331,9 +336,11 @@ CONFIG_WPA_11R_SUPPORT=n // Define ENV_CAMERA_MODEL in platformio.ini //************************************ #if ENV_CAMERA_MODEL == 1 -#define CAMERA_AITHINKER_ESP32CAM_OV2640 +#define CAMERA_AITHINKER_ESP32CAM #elif ENV_CAMERA_MODEL == 2 -#define CAMERA_XIAO_ESP32S3_SENSE_OV2640 +#define CAMERA_XIAO_ESP32S3_SENSE +#elif ENV_CAMERA_MODEL == 3 +#define CAMERA_FREENOVE_ESP32S3 #else #error "Camera model (ENV_CAMERA_MODEL) not defined" #endif @@ -481,6 +488,68 @@ CONFIG_WPA_11R_SUPPORT=n #define GPIO_SPARE_6 GPIO_NUM_6 #define GPIO_SPARE_6_USAGE "spare" +#elif defined(BOARD_FREENOVE_ESP32S3) + #ifndef BOARD_SDCARD_SDMMC_BUS_WIDTH_1 + #define BOARD_SDCARD_SDMMC_BUS_WIDTH_1 // Only 1 line SD card operation is supported (hardware related) + #endif + + // SD card (operated with SDMMC peripheral) + //------------------------------------------------- + #define GPIO_SDCARD_CLK GPIO_NUM_39 + #define GPIO_SDCARD_CMD GPIO_NUM_38 + #define GPIO_SDCARD_D0 GPIO_NUM_40 + + + // LEDs + //------------------------------------------------- + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_2 // Onboard status LED + #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_48 // Onboard flashlight (WS2812) + + #define GPIO_FLASHLIGHT_DEFAULT GPIO_FLASHLIGHT_ONBOARD // Default flashlight GPIO pin (can be modified by activiating GPIO functionality in WebUI) + + //#define GPIO_FLASHLIGHT_DEFAULT_USE_PWM // Default flashlight LED is PWM controlled + #define GPIO_FLASHLIGHT_DEFAULT_USE_SMARTLED // Default flashlight SmartLED (e.g. onboard WS2812X) controlled + + #ifdef GPIO_FLASHLIGHT_DEFAULT_USE_SMARTLED + #define GPIO_FLASHLIGHT_DEFAULT_SMARTLED_TYPE LED_WS2812 // Flashlight default: SmartLED type + #define GPIO_FLASHLIGHT_DEFAULT_SMARTLED_QUANTITY 1 // Flashlight default: SmartLED Quantity + #endif + + + // Spare GPIO + //------------------------------------------------- + // Options for usage defintion: + // - 'spare': Free to use + // - 'restricted: usage': Restricted usable (WebUI expert view) + // - 'flashlight-pwm' or 'flashlight-smartled' or 'flashlight-digital' (ON/OFF) -> Map to 'flashlight-default' + // --> flashlight-default -> flashlight-smartled (Onboard LED, smartled controlled) + //------------------------------------------------- + #define GPIO_SPARE_PIN_COUNT 6 + + #define GPIO_SPARE_1 GPIO_NUM_1 + #define GPIO_SPARE_1_USAGE "spare" + + #define GPIO_SPARE_2 GPIO_NUM_14 + #define GPIO_SPARE_2_USAGE "spare" + + #define GPIO_SPARE_3 GPIO_NUM_21 + #define GPIO_SPARE_3_USAGE "spare" + + #define GPIO_SPARE_4 GPIO_NUM_46 + #define GPIO_SPARE_4_USAGE "spare" + + #define GPIO_SPARE_5 GPIO_NUM_47 + #define GPIO_SPARE_5_USAGE "spare" + + #define GPIO_SPARE_6 GPIO_FLASHLIGHT_DEFAULT // Flashlight default + #if defined(GPIO_FLASHLIGHT_DEFAULT_USE_PWM) + #define GPIO_SPARE6_USAGE FLASHLIGHT_PWM // Define flashlight-default as ... + #elif defined(GPIO_FLASHLIGHT_DEFAULT_USE_SMARTLED) + #define GPIO_SPARE_6_USAGE FLASHLIGHT_SMARTLED // Define flashlight-default as ... + #else + #define GPIO_SPARE_6_USAGE FLASHLIGHT_DIGITAL // Define flashlight-default as ... + #endif + #else #error "define.h: No board type defined or type unknown" #endif //Board types @@ -489,7 +558,7 @@ CONFIG_WPA_11R_SUPPORT=n // Camera models // Further models: https://github.com/Mjrovai/XIAO-ESP32S3-Sense/blob/main/camera_round_display_save_jpeg/camera_pins.h //************************************ -#ifdef CAMERA_AITHINKER_ESP32CAM_OV2640 +#ifdef CAMERA_AITHINKER_ESP32CAM #define PWDN_GPIO_NUM GPIO_NUM_32 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM GPIO_NUM_0 @@ -508,7 +577,7 @@ CONFIG_WPA_11R_SUPPORT=n #define HREF_GPIO_NUM GPIO_NUM_23 #define PCLK_GPIO_NUM GPIO_NUM_22 -#elif defined(CAMERA_XIAO_ESP32S3_SENSE_OV2640) +#elif defined(CAMERA_XIAO_ESP32S3_SENSE) #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM GPIO_NUM_10 @@ -526,6 +595,25 @@ CONFIG_WPA_11R_SUPPORT=n #define VSYNC_GPIO_NUM GPIO_NUM_38 #define HREF_GPIO_NUM GPIO_NUM_47 #define PCLK_GPIO_NUM GPIO_NUM_13 + +#elif defined(CAMERA_FREENOVE_ESP32S3) + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM GPIO_NUM_15 + #define SIOD_GPIO_NUM GPIO_NUM_4 + #define SIOC_GPIO_NUM GPIO_NUM_5 + + #define Y9_GPIO_NUM GPIO_NUM_16 + #define Y8_GPIO_NUM GPIO_NUM_17 + #define Y7_GPIO_NUM GPIO_NUM_18 + #define Y6_GPIO_NUM GPIO_NUM_12 + #define Y5_GPIO_NUM GPIO_NUM_10 + #define Y4_GPIO_NUM GPIO_NUM_8 + #define Y3_GPIO_NUM GPIO_NUM_9 + #define Y2_GPIO_NUM GPIO_NUM_11 + #define VSYNC_GPIO_NUM GPIO_NUM_6 + #define HREF_GPIO_NUM GPIO_NUM_7 + #define PCLK_GPIO_NUM GPIO_NUM_13 #else #error "define.h: No camera model defined or model unknown" #endif //Camera models diff --git a/code/platformio.ini b/code/platformio.ini index 98fba7a30..d43a2d050 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -154,7 +154,6 @@ build_flags = - ; ############################################################################# ; Board ; XIAO ESP32S3 Sense @@ -242,3 +241,93 @@ build_flags = ;-D DEBUG_ENABLE_PERFMON ;-D DEBUG_HIMEM_MEMORY_CHECK lib_ldf_mode = deep+ + + + +; ############################################################################# +; Board +; FREENOVE ESP32S3-WROOM-1-N16R8 (and compatible) +; ############################################################################# +[env:freenove-esp32s3] +extends = common:esp32-idf +board = 4d_systems_esp32s3_gen4_r8n16 +framework = espidf +build_flags = + ; ### common imported : + ${common:esp32-idf.build_flags} + ${flags:runtime.build_flags} + ; ### Hardware: Define board type + camera model + ; ### (see 'include/defines.h' for definitions) + -D ENV_BOARD_TYPE=3 + -D ENV_CAMERA_MODEL=3 + ; ### Software modules: Uncomment to disable + ;-D ENV_DISABLE_MQTT + ;-D ENV_DISABLE_INFLUXDB + ;-D ENV_DISABLE_SOFTAP +board_build.partitions = partitions.csv +monitor_speed = 115200 +monitor_rts = 0 +monitor_dtr = 0 +monitor_filters = default, esp32_exception_decoder + + +; +++++++++++++++++++++++++++++++++++++++++++ +; Use this environment if building locally +; Include parameter tooltips to HTML parameter config file +; and hash to HTML files (caching) +; +++++++++++++++++++++++++++++++++++++++++++ +[env:freenove-esp32s3-localbuild] +extends = env:freenove-esp32s3 +extra_scripts = post:scripts/localbuild.py # Add parameter tooltips to HTML page + # and hashes to all cached HTML files +build_flags = + ; ### common imported : + ${common:esp32-idf.build_flags} + ${flags:runtime.build_flags} + ; ### Hardware: Define board type + camera model + ; ### (see 'include/defines.h' for definitions) + -D ENV_BOARD_TYPE=3 + -D ENV_CAMERA_MODEL=3 + +; +++++++++++++++++++++++++++++++++++++++++++ +; Use this environment for task analysis (PR #1751) +; +++++++++++++++++++++++++++++++++++++++++++ +[env:freenove-esp32s3-task-analysis] +extends = env:freenove-esp32s3 +; sdkconfig.freenove-esp32s3-task-analysis.defaults override some sdkconfig.defaults +; and enable debug analysis options +build_flags = + ; ### Hardware: Define board type + camera model + ; ### (see 'include/defines.h' for definitions) + -D ENV_BOARD_TYPE=3 + -D ENV_CAMERA_MODEL=3 + ; ### Debug options : + -D TASK_ANALYSIS_ON + ;-D DEBUG_DETAIL_ON + ;please use only one HEAP tracing at time. + ;-D HEAP_TRACING_MAIN_WIFI + ;-D HEAP_TRACING_MAIN_START + ;-D HEAP_TRACING_CLASS_FLOW_CNN_GENERAL_DO_ALING_AND_CUT + + +; +++++++++++++++++++++++++++++++++++++++++++ +; Use this environment for detailed and deep debugging +; (default debugging is already possible with default environment) +; +++++++++++++++++++++++++++++++++++++++++++ +[env:freenove-esp32s3-debug] +extends = env:freenove-esp32s3 +; sdkconfig.freenove-esp32s3-debug.defaults override some sdkconfig.defaults +; and enable debug options and clangtidy +build_flags = + ; ### clangtidy build flags: + ${flags:clangtidy.build_flags} + ; ### Hardware: Define board type + camera model + ; ### (see 'include/defines.h' for definitions) + -D ENV_BOARD_TYPE=3 + -D ENV_CAMERA_MODEL=3 + ; ### Debug options : + -D DEBUG_DETAIL_ON + ;-D DEBUG_DISABLE_BROWNOUT_DETECTOR + ;-D DEBUG_ENABLE_PERFMON + ;-D DEBUG_HIMEM_MEMORY_CHECK +lib_ldf_mode = deep+