Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM design (N16R8) #164

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
plat:
- esp32cam
- xiao-esp32s3-sense

- freenove-esp32s3-n16r8
steps:
- name: Checkout branch
if: ${{ ! needs.prepare-release.outputs.release_created }}
Expand Down Expand Up @@ -178,6 +178,7 @@ jobs:
plat:
- esp32cam
- xiao-esp32s3-sense
- freenove-esp32s3-n16r8

# Sets permissions of the GITHUB_TOKEN to allow downloading artifacts
permissions:
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ As a result, you get the digitized value of your meter. There are several option


## Supported Hardware
| Board Type | SOC | Firmware Release | Remarks
|:--- |:--- |:--- |:---
| [ESP32-CAM](http://www.ai-thinker.com/pro_view-24.html) | ESP32 | All | - Only boards with >4MB RAM are supported<br>- Beware of inferior quality Chinese clones
| [XIAO ESP32 Sense](https://www.seeedstudio.com/XIAO-ESP32S3-Sense-p-5639.html) | ESP32S3 | $\ge$ v17.0.0 |- No onboard illumination: Separate illumination (PWM controlable LED / Intelligent LED) necessary<br>- Running quite hot, small heat sink recommended
### Board

| Board Type | SOC / Module | Firmware Release | Remarks
|:--- |:--- |:--- |:---
| [ESP32-CAM](http://www.ai-thinker.com/pro_view-24.html) | ESP32 | All | - Only boards with >4MB RAM are supported<br>- Beware of inferior quality Chinese clones
| [XIAO ESP32 Sense](https://www.seeedstudio.com/XIAO-ESP32S3-Sense-p-5639.html) | ESP32S3 | $\ge$ v17.0.0 |- No onboard illumination: Separate illumination (PWM controlable LED / Intelligent LED) necessary<br>- Running quite hot, small heat sink recommended
| [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 | Resolution | Firmware Release | Remarks
|:--- |:--- |:--- |:---
| [OV2640](https://www.arducam.com/ov2640/) | 2MP (max. 1600x1200) | All | - Officially EOL since 2009, but still very popular<br>- Pin and function compatible Chinese clones are supported


## Device Installation
Expand Down
4 changes: 3 additions & 1 deletion code/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ dependencies.lock
sdkconfig.esp32cam
sdkconfig.esp32cam-localbuild
sdkconfig.xiao-esp32s3-sense
sdkconfig.xiao-esp32s3-sense-localbuild
sdkconfig.xiao-esp32s3-sense-localbuild
sdkconfig.freenove-esp32s3-n16r8
sdkconfig.freenove-esp32s3-n16r8-localbuild
7 changes: 7 additions & 0 deletions code/components/camera_ctrl/ClassControlCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,10 +963,17 @@ 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
}
}

Expand Down
24 changes: 24 additions & 0 deletions code/components/misc_helper/statusled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ 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
#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

for (int i=0; i<2; ) // Default: repeat 2 times
{
Expand All @@ -34,19 +38,35 @@ void task_StatusLED(void *pvParameter)

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
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
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
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
vTaskDelay(StatusLEDDataInt.iBlinkTime / portTICK_PERIOD_MS);
}
vTaskDelay(1500 / portTICK_PERIOD_MS); // Delay to signal new round
Expand Down Expand Up @@ -147,5 +167,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
#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
}
214 changes: 148 additions & 66 deletions code/include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,33 +277,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


Expand All @@ -324,9 +314,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
Expand Down Expand Up @@ -396,14 +410,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
Expand Down Expand Up @@ -449,53 +488,96 @@ 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


// 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
7 changes: 7 additions & 0 deletions code/partitions_16MB.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, , 0x5000,
otadata, data, ota, , 0x2000,
ota_0, app, ota_0, , 2048K,
ota_1, app, ota_1, , 2048K,
coredump, data, coredump, , 64K,
littlefs, data, littlefs, , 0xBE0000,
Loading