diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 6dde83a02..bb4b4cf35 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -41,7 +41,7 @@ jobs: plat: - esp32cam - xiao-esp32s3-sense - + - freenove-esp32s3-n16r8 steps: - name: Checkout branch if: ${{ ! needs.prepare-release.outputs.release_created }} @@ -182,6 +182,7 @@ jobs: plat: - esp32cam - xiao-esp32s3-sense + - freenove-esp32s3-n16r8 # Sets permissions of the GITHUB_TOKEN to allow downloading artifacts permissions: diff --git a/README.md b/README.md index 05a189e2f..66d3597c4 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ As a result, you get the digitized value of your meter. There are several option |:--- |:--- |:--- |:--- | [ESP32-CAM](http://www.ai-thinker.com/pro_view-24.html) | ESP32 | All |⚠️ Only boards with >4MB RAM are supported
⚠️ Beware of inferior quality Chinese clones | [XIAO ESP32 Sense](https://www.seeedstudio.com/XIAO-ESP32S3-Sense-p-5639.html) | ESP32S3 | $\ge$ v17.0.0 |⚠️ Running quite hot, a small heat sink is recommended
ℹ️ No onboard illumination: Separate illumination (PWM controlable LED / Intelligent LED) required +| [ESP32S3-WROOM](https://github.com/Freenove/Freenove_ESP32_S3_WROOM_Board) | ESP32S3-WROOM-1-N16R8 | $\ge$ v17.0.0 |ℹ️ SOC and pin compatible borads of Freenove ESP32S3-WROOM with 16MB flash and 8MB RAM supported ### Camera | Camera Type | Sensor Resolution | Digital Zoom | Firmware Release | Remarks diff --git a/code/.gitignore b/code/.gitignore index cbee1008c..911e8c9e0 100644 --- a/code/.gitignore +++ b/code/.gitignore @@ -9,4 +9,6 @@ dependencies.lock sdkconfig.esp32cam sdkconfig.esp32cam-localbuild sdkconfig.xiao-esp32s3-sense -sdkconfig.xiao-esp32s3-sense-localbuild \ No newline at end of file +sdkconfig.xiao-esp32s3-sense-localbuild +sdkconfig.freenove-esp32s3-n16r8 +sdkconfig.freenove-esp32s3-n16r8-localbuild \ No newline at end of file diff --git a/code/components/camera_ctrl/ClassControlCamera.cpp b/code/components/camera_ctrl/ClassControlCamera.cpp index 786d19988..4f1dd2e5b 100644 --- a/code/components/camera_ctrl/ClassControlCamera.cpp +++ b/code/components/camera_ctrl/ClassControlCamera.cpp @@ -1054,12 +1054,21 @@ void ClassControlCamera::setStatusLed(bool _status) /* Set the GPIO as a push/pull output */ gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE if (!_status) { gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); } else { gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); } +#else + if (_status) { + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); + } + else { + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); + } +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE } } diff --git a/code/components/gpio_ctrl/gpioControl.cpp b/code/components/gpio_ctrl/gpioControl.cpp index 2f641c9c1..b6a67a1af 100644 --- a/code/components/gpio_ctrl/gpioControl.cpp +++ b/code/components/gpio_ctrl/gpioControl.cpp @@ -249,7 +249,7 @@ esp_err_t GpioHandler::loadParameter() for (int i = 0; i < GPIO_SPARE_PIN_COUNT; ++i) { if (strcmp(gpio_spare_usage[i], FLASHLIGHT_SMARTLED) == 0) { GpioPin *gpioPin = new GpioPin((gpio_num_t)gpio_spare[i], ("gpio" + std::to_string((int)gpio_spare[i])).c_str(), - GPIO_PIN_MODE_FLASHLIGHT_SMARTLED, GPIO_INTR_DISABLE, 200, 5000, false, false, "", + GPIO_PIN_MODE_FLASHLIGHT_SMARTLED, GPIO_INTR_DISABLE, 200, 5000, false, false, false, "", GPIO_FLASHLIGHT_DEFAULT_SMARTLED_TYPE, GPIO_FLASHLIGHT_DEFAULT_SMARTLED_QUANTITY, Rgb{255, 255, 255}, 100); (*gpioMap)[(gpio_num_t)gpio_spare[i]] = gpioPin; diff --git a/code/components/mainprocess_ctrl/MainFlowControl.cpp b/code/components/mainprocess_ctrl/MainFlowControl.cpp index 93fb73839..a0ad90e80 100644 --- a/code/components/mainprocess_ctrl/MainFlowControl.cpp +++ b/code/components/mainprocess_ctrl/MainFlowControl.cpp @@ -72,21 +72,20 @@ bool doInit(void) cameraCtrl.printCamInfo(); } - // Init main flow components - // ******************************************** - if (!flowctrl.initFlow()) { - flowctrl.deinitFlow(); - return false; - } - // Init GPIO handler // Note: It has to be initialized before MQTT (topic subscription) - // and after flow init (MQTT main topic parameter) // ******************************************** if (!gpio_handler_init()) { bRetVal = false; } + // Init main flow components + // ******************************************** + if (!flowctrl.initFlow()) { + flowctrl.deinitFlow(); + return false; + } + // Init MQTT service // ******************************************** #ifdef ENABLE_MQTT @@ -937,6 +936,8 @@ void task_autodoFlow(void *pvParameter) publishMqttData(mqttServer_getMainTopic() + "/process/status/process_state", flowctrl.getActualProcessState(), 1, false); #endif // ENABLE_MQTT + gpio_handler_init(); // Init GPIO handler to handle flashlight requests during setup + while (true) { // Waiting for a REQUEST vTaskDelay(1000 / portTICK_PERIOD_MS); if (reloadConfig) { diff --git a/code/components/misc_helper/statusled.cpp b/code/components/misc_helper/statusled.cpp index e698db7f1..66d214972 100644 --- a/code/components/misc_helper/statusled.cpp +++ b/code/components/misc_helper/statusled.cpp @@ -24,27 +24,53 @@ void task_StatusLED(void *pvParameter) esp_rom_gpio_pad_select_gpio(GPIO_STATUS_LED_ONBOARD); // Init the GPIO gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); // Set the GPIO as a push/pull output - gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); // LED off - for (int i = 0; i < 2;) // Default: repeat 2 times - { +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); // LED off +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); // LED off +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE + + for (int i = 0; i < 2;) { // Default: repeat 2 times if (!StatusLEDDataInt.bInfinite) { ++i; } for (int j = 0; j < StatusLEDDataInt.iSourceBlinkCnt; ++j) { +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE + vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); + +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE + vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); } vTaskDelay(500 / portTICK_PERIOD_MS); // Delay between module code and error code for (int j = 0; j < StatusLEDDataInt.iCodeBlinkCnt; ++j) { +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE + vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); + +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE + vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS); } vTaskDelay(1500 / portTICK_PERIOD_MS); // Delay to signal new round @@ -146,5 +172,9 @@ void setStatusLedOff(void) esp_rom_gpio_pad_select_gpio(GPIO_STATUS_LED_ONBOARD); // Init the GPIO gpio_set_direction(GPIO_STATUS_LED_ONBOARD, GPIO_MODE_OUTPUT); // Set the GPIO as a push/pull output - gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); // LED off +#ifdef GPIO_STATUS_LED_ONBOARD_LOWACTIVE + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 1); // LED off +#else + gpio_set_level(GPIO_STATUS_LED_ONBOARD, 0); // LED off +#endif // GPIO_STATUS_LED_ONBOARD_LOWACTIVE } diff --git a/code/include/defines.h b/code/include/defines.h index 96e3fc45a..0a8bfb82b 100644 --- a/code/include/defines.h +++ b/code/include/defines.h @@ -293,33 +293,23 @@ CONFIG_WPA_11R_SUPPORT=n //************************************************************************* // Define BOARD type -// Define ENV_BOARD_TYPE in platformio.ini +// Define in platformio.ini //************************************ -#if ENV_BOARD_TYPE == 1 -#define BOARD_AITHINKER_ESP32CAM -#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. +#if defined(BOARD_AITHINKER_ESP32CAM) +#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) -#else -#error "Board type (ENV_BOARD_TYPE) not defined" -#define BOARD_AITHINKER_ESP32CAM -#define BOARD_TYPE_NAME "Board unknown" -#endif +#elif defined(BOARD_XIAO_ESP32S3) +#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) -// Define CAMERA model -// Define ENV_CAMERA_MODEL in platformio.ini -//************************************ -#if ENV_CAMERA_MODEL == 1 -#define CAMERA_AITHINKER_ESP32CAM_OV2640 -#elif ENV_CAMERA_MODEL == 2 -#define CAMERA_XIAO_ESP32S3_SENSE_OV2640 +#elif defined(BOARD_FREENOVE_ESP32S3_N16R8) +#define BOARD_TYPE_NAME "Freenove-ESP32S3-N16R8"// Keep Board type equal to main board environment name. + // This is used for OTA update package verification (converted to lower case) #else -#define CAMERA_AITHINKER_ESP32CAM_OV2640 -#error "Camera model (ENV_CAMERA_MODEL) not defined" +#error "Board type not defined" +#define BOARD_AITHINKER_ESP32CAM +#define BOARD_TYPE_NAME "Board unknown" #endif @@ -340,9 +330,33 @@ CONFIG_WPA_11R_SUPPORT=n #define GPIO_SDCARD_D3 GPIO_NUM_13 // Needs to be high to init SD in MMC mode. After init GPIO can be used as spare GPIO + // Camera pin config + // Further models: https://github.com/Mjrovai/XIAO-ESP32S3-Sense/blob/main/camera_round_display_save_jpeg/camera_pins.h + //------------------------------------------------- + #define PWDN_GPIO_NUM GPIO_NUM_32 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM GPIO_NUM_0 + #define SIOD_GPIO_NUM GPIO_NUM_26 + #define SIOC_GPIO_NUM GPIO_NUM_27 + + #define Y9_GPIO_NUM GPIO_NUM_35 + #define Y8_GPIO_NUM GPIO_NUM_34 + #define Y7_GPIO_NUM GPIO_NUM_39 + #define Y6_GPIO_NUM GPIO_NUM_36 + #define Y5_GPIO_NUM GPIO_NUM_21 + #define Y4_GPIO_NUM GPIO_NUM_19 + #define Y3_GPIO_NUM GPIO_NUM_18 + #define Y2_GPIO_NUM GPIO_NUM_5 + #define VSYNC_GPIO_NUM GPIO_NUM_25 + #define HREF_GPIO_NUM GPIO_NUM_23 + #define PCLK_GPIO_NUM GPIO_NUM_22 + + // LEDs //------------------------------------------------- - #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_33 // Onboard red status LED + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_33 // Onboard status LED (red, active low) + #define GPIO_STATUS_LED_ONBOARD_LOWACTIVE // Enable if status LED is low active + #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_4 // Onboard flashlight LED #ifdef BOARD_SDCARD_SDMMC_BUS_WIDTH_1 @@ -419,14 +433,39 @@ CONFIG_WPA_11R_SUPPORT=n #define GPIO_SDCARD_CLK GPIO_NUM_7 #define GPIO_SDCARD_CMD GPIO_NUM_9 #define GPIO_SDCARD_D0 GPIO_NUM_8 + #define GPIO_SDCARD_D1 GPIO_NUM_NC + #define GPIO_SDCARD_D2 GPIO_NUM_NC #define GPIO_SDCARD_D3 GPIO_NUM_21 // Needs to be high to init with MMC mode. After init GPIO can be used as status LED + // Camera pin config + // Further models: https://github.com/Mjrovai/XIAO-ESP32S3-Sense/blob/main/camera_round_display_save_jpeg/camera_pins.h + //------------------------------------------------- + #define PWDN_GPIO_NUM -1 + #define RESET_GPIO_NUM -1 + #define XCLK_GPIO_NUM GPIO_NUM_10 + #define SIOD_GPIO_NUM GPIO_NUM_40 + #define SIOC_GPIO_NUM GPIO_NUM_39 + + #define Y9_GPIO_NUM GPIO_NUM_48 + #define Y8_GPIO_NUM GPIO_NUM_11 + #define Y7_GPIO_NUM GPIO_NUM_12 + #define Y6_GPIO_NUM GPIO_NUM_14 + #define Y5_GPIO_NUM GPIO_NUM_16 + #define Y4_GPIO_NUM GPIO_NUM_18 + #define Y3_GPIO_NUM GPIO_NUM_17 + #define Y2_GPIO_NUM GPIO_NUM_15 + #define VSYNC_GPIO_NUM GPIO_NUM_38 + #define HREF_GPIO_NUM GPIO_NUM_47 + #define PCLK_GPIO_NUM GPIO_NUM_13 + + // LEDs //------------------------------------------------- - #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_21 // Onboard yellow status LED (USER LED) - #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_NC // No onboard flashlight available + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_21 // Onboard yellow status LED (USER LED, yellow, active low) + #define GPIO_STATUS_LED_ONBOARD_LOWACTIVE // Enable if status LED is low active + #define GPIO_FLASHLIGHT_ONBOARD GPIO_NUM_NC // No onboard flashlight available #define GPIO_FLASHLIGHT_DEFAULT GPIO_NUM_1 // 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 @@ -477,53 +516,101 @@ CONFIG_WPA_11R_SUPPORT=n #define GPIO_SPARE_6 GPIO_NUM_6 #define GPIO_SPARE_6_USAGE "spare" -#else - #error "define.h: No board type defined or type unknown" -#endif //Board types - +#elif defined(BOARD_FREENOVE_ESP32S3_N16R8) + #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 -// 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 - #define PWDN_GPIO_NUM GPIO_NUM_32 - #define RESET_GPIO_NUM -1 - #define XCLK_GPIO_NUM GPIO_NUM_0 - #define SIOD_GPIO_NUM GPIO_NUM_26 - #define SIOC_GPIO_NUM GPIO_NUM_27 + // 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 + #define GPIO_SDCARD_D1 GPIO_NUM_NC + #define GPIO_SDCARD_D2 GPIO_NUM_NC + #define GPIO_SDCARD_D3 GPIO_NUM_NC - #define Y9_GPIO_NUM GPIO_NUM_35 - #define Y8_GPIO_NUM GPIO_NUM_34 - #define Y7_GPIO_NUM GPIO_NUM_39 - #define Y6_GPIO_NUM GPIO_NUM_36 - #define Y5_GPIO_NUM GPIO_NUM_21 - #define Y4_GPIO_NUM GPIO_NUM_19 - #define Y3_GPIO_NUM GPIO_NUM_18 - #define Y2_GPIO_NUM GPIO_NUM_5 - #define VSYNC_GPIO_NUM GPIO_NUM_25 - #define HREF_GPIO_NUM GPIO_NUM_23 - #define PCLK_GPIO_NUM GPIO_NUM_22 -#elif defined(CAMERA_XIAO_ESP32S3_SENSE_OV2640) + // Camera pin config + // Further models: https://github.com/Mjrovai/XIAO-ESP32S3-Sense/blob/main/camera_round_display_save_jpeg/camera_pins.h + //------------------------------------------------- #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 - #define XCLK_GPIO_NUM GPIO_NUM_10 - #define SIOD_GPIO_NUM GPIO_NUM_40 - #define SIOC_GPIO_NUM GPIO_NUM_39 - - #define Y9_GPIO_NUM GPIO_NUM_48 - #define Y8_GPIO_NUM GPIO_NUM_11 - #define Y7_GPIO_NUM GPIO_NUM_12 - #define Y6_GPIO_NUM GPIO_NUM_14 - #define Y5_GPIO_NUM GPIO_NUM_16 - #define Y4_GPIO_NUM GPIO_NUM_18 - #define Y3_GPIO_NUM GPIO_NUM_17 - #define Y2_GPIO_NUM GPIO_NUM_15 - #define VSYNC_GPIO_NUM GPIO_NUM_38 - #define HREF_GPIO_NUM GPIO_NUM_47 + #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 + + + // LEDs + //------------------------------------------------- + #define GPIO_STATUS_LED_ONBOARD GPIO_NUM_2 // Onboard status LED (blue, active high) + //#define GPIO_STATUS_LED_ONBOARD_LOWACTIVE // Enable if status LED is low active + + #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 + + + // Serial Port: Improv Serial / Improv WiFi + //------------------------------------------------- + #define USB_SERIAL // Use USB Serial/JTAG controller console (USB-OTG port) + + + // 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 camera model defined or model unknown" -#endif //Camera models + #error "define.h: No board type defined or type unknown" +#endif //Board types #endif //DEFINES_H \ No newline at end of file diff --git a/code/partitions_16MB.csv b/code/partitions_16MB.csv new file mode 100644 index 000000000..3ccbec7d3 --- /dev/null +++ b/code/partitions_16MB.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, , 0x5000, +otadata, data, ota, , 0x2000, +ota_0, app, ota_0, , 2560k, +ota_1, app, ota_1, , 2560k, +coredump, data, coredump, , 64K, +data0, data, fat, , 11136k, \ No newline at end of file diff --git a/code/partitions_4MB.csv b/code/partitions_4MB.csv new file mode 100644 index 000000000..5e31db4ec --- /dev/null +++ b/code/partitions_4MB.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, , 0x5000, +otadata, data, ota, , 0x2000, +ota_0, app, ota_0, , 1984k, +ota_1, app, ota_1, , 1984k +coredump, data, coredump, , 64K, \ No newline at end of file diff --git a/code/partitions.csv b/code/partitions_4MB_legacy.csv similarity index 100% rename from code/partitions.csv rename to code/partitions_4MB_legacy.csv diff --git a/code/partitions_8MB.csv b/code/partitions_8MB.csv new file mode 100644 index 000000000..97945d4f7 --- /dev/null +++ b/code/partitions_8MB.csv @@ -0,0 +1,7 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, , 0x5000, +otadata, data, ota, , 0x2000, +ota_0, app, ota_0, , 2240k, +ota_1, app, ota_1, , 2240k, +coredump, data, coredump, , 64K, +data0, data, fat, , 3584k, \ No newline at end of file diff --git a/code/platformio.ini b/code/platformio.ini index 5cacb9606..419a34dc8 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -53,24 +53,20 @@ build_flags = ; ############################################################################# [env:esp32cam] extends = common:esp32-idf -board = esp32cam framework = espidf +board = esp32cam +board_build.partitions = partitions_4MB_legacy.csv build_flags = ; ### Common flags: ${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=1 - -D ENV_CAMERA_MODEL=1 + ; ### Hardware: Define board type (see 'include/defines.h' for definitions) + -D BOARD_AITHINKER_ESP32CAM ; ### Software modules: Uncomment to disable ;-D ENV_DISABLE_MQTT ;-D ENV_DISABLE_INFLUXDB ;-D ENV_DISABLE_WEBHOOK -board_build.partitions = partitions.csv monitor_speed = 115200 -monitor_rts = 0 -monitor_dtr = 0 monitor_filters = default, esp32_exception_decoder @@ -87,10 +83,8 @@ build_flags = ; ### Common flags: ${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=1 - -D ENV_CAMERA_MODEL=1 + ; ### Hardware: Define board type (see 'include/defines.h' for definitions) + -D BOARD_AITHINKER_ESP32CAM @@ -100,24 +94,21 @@ build_flags = ; ############################################################################# [env:xiao-esp32s3-sense] extends = common:esp32-idf -board = seeed_xiao_esp32s3 framework = espidf +board = seeed_xiao_esp32s3 +board_build.partitions = partitions_8MB.csv +board_build.filesystem = fatfs 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=2 - -D ENV_CAMERA_MODEL=2 + ; ### Hardware: Define board type (see 'include/defines.h' for definitions) + -D BOARD_XIAO_ESP32S3 ; ### Software modules: Uncomment to disable ;-D ENV_DISABLE_MQTT ;-D ENV_DISABLE_INFLUXDB ;-D ENV_DISABLE_WEBHOOK -board_build.partitions = partitions.csv monitor_speed = 115200 -monitor_rts = 0 -monitor_dtr = 0 monitor_filters = default, esp32_exception_decoder @@ -134,7 +125,49 @@ 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=2 - -D ENV_CAMERA_MODEL=2 + ; ### Hardware: Define board type (see 'include/defines.h' for definitions) + -D BOARD_XIAO_ESP32S3 + + +; ############################################################################# +; Board +; Freenove ESP32S3-WROOM-1-N16R8 (Freenove pin compatible clones) +; ############################################################################# +[env:freenove-esp32s3-n16r8] +extends = common:esp32-idf +framework = espidf +# 'freenove_esp32_s3_wroom' not yet supported, but already in dev: (#1469) Freenove ESP32-S3-WROOM added +board = 4d_systems_esp32s3_gen4_r8n16 +board_upload.flash_size = 16MB +board_upload.maximum_size = 16777216 +board_build.partitions = partitions_16MB.csv +board_build.filesystem = fatfs +build_flags = + ; ### common imported : + ${common:esp32-idf.build_flags} + ${flags:runtime.build_flags} + ; ### Hardware: Define board type (see 'include/defines.h' for definitions) + -D BOARD_FREENOVE_ESP32S3_N16R8 + ; ### Software modules: Uncomment to disable + ;-D ENV_DISABLE_MQTT + ;-D ENV_DISABLE_INFLUXDB + ;-D ENV_DISABLE_WEBHOOK +monitor_speed = 115200 +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-n16r8-localbuild] +extends = env:freenove-esp32s3-n16r8 +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 (see 'include/defines.h' for definitions) + -D BOARD_FREENOVE_ESP32S3_N16R8 diff --git a/code/sdkconfig.esp32cam.defaults b/code/sdkconfig.esp32cam.defaults index d4f0c6deb..a083234da 100644 --- a/code/sdkconfig.esp32cam.defaults +++ b/code/sdkconfig.esp32cam.defaults @@ -17,8 +17,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y # Partition Table # CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -50,7 +48,4 @@ CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=131072 CONFIG_SPIRAM_CACHE_WORKAROUND=y CONFIG_SPIRAM_IGNORE_NOTFOUND=y CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y - -#force disable HIMEM as not used in default config, can be enabled with [env:esp32cam-himem] -#free 256kb of internal memory : I (2112) esp_himem: Initialized. Using last 8 32KB address blocks for bank switching on 4352 KB of physical memory. CONFIG_SPIRAM_BANKSWITCH_ENABLE=n diff --git a/code/sdkconfig.freenove-esp32s3-n16r8.defaults b/code/sdkconfig.freenove-esp32s3-n16r8.defaults new file mode 100644 index 000000000..44de64c72 --- /dev/null +++ b/code/sdkconfig.freenove-esp32s3-n16r8.defaults @@ -0,0 +1,44 @@ +################################################## +# Application and board specific configuration +# Edit this file instead of sdkconfig.{board_type}! +# After editing make sure to explicitly delete +# sdkconfig.{board_type} to apply your changes! +################################################## + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="16MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y + + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y + + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=n +CONFIG_ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY=n + + +# +# SPI RAM config +# +CONFIG_SPIRAM_SIZE=-1 +CONFIG_SPIRAM_MODE_OCT=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=8192 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=131072 +CONFIG_SPIRAM_IGNORE_NOTFOUND=y +CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=n +CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=n diff --git a/code/sdkconfig.xiao-esp32s3-sense.defaults b/code/sdkconfig.xiao-esp32s3-sense.defaults index 3a821a998..63dd41bc5 100644 --- a/code/sdkconfig.xiao-esp32s3-sense.defaults +++ b/code/sdkconfig.xiao-esp32s3-sense.defaults @@ -17,8 +17,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y # Partition Table # CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -35,7 +33,6 @@ CONFIG_ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY=n # CONFIG_SPIRAM_SIZE=-1 CONFIG_SPIRAM_MODE_OCT=y -#CONFIG_SPIRAM_SPEED_40M=y CONFIG_SPIRAM_SPEED_80M=y CONFIG_SPIRAM_BOOT_INIT=y CONFIG_SPIRAM_USE_MALLOC=y diff --git a/docs/Installation/DeviceReadme/freenove-esp32s3-n16r8.md b/docs/Installation/DeviceReadme/freenove-esp32s3-n16r8.md new file mode 100644 index 000000000..6a05c4a5a --- /dev/null +++ b/docs/Installation/DeviceReadme/freenove-esp32s3-n16r8.md @@ -0,0 +1,54 @@ +# Firmware Installation (Freenove ESP32S3 N16R8) + +## Manual Firmware Installation / Update + + ### 1. Flash microcontroller content (ESP32S3 based microcontroller) + + - Put your board into bootloader mode (IO0 grounded + board reset) + - Use port labeld with `USB-OTG` + - Three files to be flashed with correct flash offset + + | Filename | Offset | Description + |:------------------|:------------|:------ + | bootloader.bin | 0x0 | Bootloader + | partitions.bin | 0x8000 | Partition table + | firmware.bin | 0x10000 | User application + + - Use `Flash Download Tool` from Espressif or the console-based `esptool` to flash the files. + Usage is described [here](https://jomjol.github.io/AI-on-the-edge-device-docs/Installation/#flashing-using-the-flash-tool-from-espressif-gui). + + + ### 2. Prepare SD Card + - Format SD card with FAT32 (Windows recommenend. In MacOS formated cards could not working properly) + - Copy folders `/config` and `/html` from zip file to SD card root folder + + + ### 3. Configure WLAN + + #### Modify content directly in config file + Use config.json template from `sdcard/config/template` folder, copy it to + `sdcard/config` folder and to configure your wlan connection.
+ Note 1: If device is already booted once, a full config with default configuration is already sitting in `/config` folder. + You can also use this file, search for section network and adapt the wlan config there. + Note 2: Be careful with syntax. Messing up the JSON notation, config is getting rejected. + + +## Alternative Provisioning Options + +### Device Provisioning via Web Installer + + Usage is decribed [here](https://github.com/Slider0007/AI-on-the-edge-device/blob/develop/docs/Installation/DeviceProvisioning/WebInstaller.md). + + +### Device Provisioning via Access Point + + Usage is decribed [here](https://github.com/Slider0007/AI-on-the-edge-device/blob/develop/docs/Installation/DeviceProvisioning/AccessPoint.md). + + +### Firmware Update via OTA (Over-The-Air) + + Note: This option is only available after initial installation was successful and regular device web interface is accessible. + + Select firmware package zip from github repository in WebUI OTA Updater page. + The device is getting updated automatically. The existing configuration will not be overwritten. +