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

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from

Conversation

Slider0007
Copy link
Owner

@Slider0007 Slider0007 commented Aug 2, 2024

Add support for boards based on Freenove ESP32S3-WROOM design with 16MB flash and 8MB RAM (N16R8)


Implementation based on a board with 16MB flash and 8MB RAM using module ESP32-S3-WROOM-1-N16R8:


Flashlight:

  • Default flashlight pin configuration: GPIO48 (WS2812)
  • Flashlight configuration can be adapted via WebUI -> Settings > Configuration > GPIO section

Builds:

  • Use build packages suitable for this hardware:
    -> Generic syntax: AI-on-the-edge-device__{board type}__xxx.zip
    -> Example: AI-on-the-edge-device__freenove_esp32s3_n16r8__xxx.zip

Further adaptions:

  • Add support of high active status LED
  • Use dedicated partition tables depending on device flash size (4MB, 8MB, 16MB)
    • ESP32CAM (4MB flash): Keep 4MB legacy partition table with application partition size of 1900kb for compability reason (Drawback: Some space is unused. An application partition up to 1984kb could be used, but would impact all existing installations, because partition table is not been updated via OTA)
    • XIAO ESP32S3 Sense (8MB flash): Use larger application partition size (2240kb), Remaining space: Use as spare FAT partition
    • ESP32S3-WROOM-N16R8 (16MB flash): Use larger application partition size (2560kb), Remaining space: Use as spare FAT partition

Usage statistics:

Before (based on ESP32):
RAM: [= ] 14.3% (used 46972 bytes from 327680 bytes)
Flash: [========= ] 87.9% (used 1709785 bytes from 1945600 bytes)

After:
RAM: [= ] 14.3% (used 46972 bytes from 327680 bytes)
Flash: [========= ] 87.9% (used 1709785 bytes from 1945600 bytes)

@Slider0007 Slider0007 changed the title feat(hardware): Add support for board type based on ESP32S3 WROOM N16R8 (Freenove ESP32S3 and pin compatible) feat(hardware): Add support for board type based on ESP32S3 WROOM N16R8 Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for board type based on ESP32S3 WROOM N16R8 feat(hardware): Add support for boards based on ESP32S3 WROOM N16R8 Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for boards based on ESP32S3 WROOM N16R8 feat(hardware): Add support for board Freenove ESP32S3 WROOM Cam (and clones) Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for board Freenove ESP32S3 WROOM Cam (and clones) feat(hardware): Add support for board Freenove ESP32S3 WROOM (and clones) Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for board Freenove ESP32S3 WROOM (and clones) feat(hardware): Add support for board Freenove ESP32S3-WROOM (and clones) Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for board Freenove ESP32S3-WROOM (and clones) feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM design Aug 2, 2024
@Slider0007 Slider0007 changed the title feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM design feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM (N16R8) design Aug 8, 2024
@Slider0007 Slider0007 marked this pull request as draft September 23, 2024 21:20
@Slider0007 Slider0007 changed the title feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM (N16R8) design feat(hardware): Add support for boards based on Freenove ESP32S3-WROOM design (N16R8) Oct 11, 2024
@Slider0007 Slider0007 marked this pull request as ready for review November 19, 2024 18:08
@Adminius
Copy link

Adminius commented Jan 9, 2025

Hey, thanks for your work!
I'm trying to use this with freenove chineese clone.

  1. AP is not showing on start, debug console says it's on, but my smarthone/pc doesn't see it.
    -> I added my wifi settings direct to config file and i can see UI, camera works
  2. I have WS2812 on board
    image
    but with this setting only "normal" blue led flashes, and not the WS2812

@Slider0007
Copy link
Owner Author

Hi @Adminius,

  1. AP is not showing on start, debug console says it's on, but my smarthone/pc doesn't see it.
    -> I added my wifi settings direct to config file and i can see UI, camera works

Difficult to say with this info. AP only starts when no SD card content is available or no SSID is configured. As you wrote, console reported AP was activated, then it's was activated software wise at least...

2. I have WS2812 on board

From my limited point of view your config seems correct.
Tipp: There is no need to additionally configure anything in GPIO section as long you're fine with device's default (with freenove board: onboard WS2812B at GPIO48 --> Actual config in use is also stated in section Take Image). The only parameter you need to adjust are here:
image

Do you have set any flash intensity?

Which specific board do you have? I'm not sure if there are multiple versions available. I have only one board in hand and with this one it's working with onboard WS2812. Are you sure that your board is using GPIO48?

@Adminius
Copy link

Adminius commented Jan 9, 2025

I have this one with OV2640: https://www.aliexpress.com/item/1005007308040075.html

I checked PCB connections:
Blue LED marked "IO2", and is also connected to IO2 on ESP32-S3-WROOM module
WS2812 marked with "48" and is connected to IO48 on ESP32-S3-WROOM module

image
It was set to GPIO48 per default but also didn't work (only blue LED=IO2 flashes) (that's why I changed settings)

I'm usind precompiled version from this PR: https://github.com/Slider0007/AI-on-the-edge-device/actions/runs/12116397491/job/33776694608?pr=164

Slider0007 Fork | Develop: HEAD (Commit: d869586)

image

@Slider0007
Copy link
Owner Author

Slider0007 commented Jan 9, 2025

@Adminius

I have this one with OV2640: https://www.aliexpress.com/item/1005007308040075.html

It seems identical to my board.

I'm usind precompiled version from this PR: https://github.com/Slider0007/AI-on-the-edge-device/actions/runs/12116397491/job/33776694608?pr=164

Slider0007 Fork | Develop: HEAD (Commit: d869586)

image

That's also OK. Device info looks also identical.

Have you already checked the logs?
Switch to DEBUG log level in config and check the logs for any errors and the correct behaviour (WebUI > System > Logs).

image

You could also provide the config.json file for a short cross check (WebUI > File Server > browse and download the file).

Have you checked the live stream with flashlight function? (WebUI > System > Live Stream)

Have you tried the different availabale LED types?

Unfortunately SmartLEDs are quite difficult to debug. If you have an oscilloscope, you could check the output signal. Maybe a hardware issue?

@Adminius
Copy link

Adminius commented Jan 9, 2025

Log:

[0d02h14m30s] 2025-01-09T15:03:06 <INF> [MAINCTRL] Trigger: Reload configuration
[0d02h14m30s] 2025-01-09T15:03:06 <INF> [MAINCTRL] Process state: Initialization
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [FLOWCTRL] Deinit flow
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [FLOWCTRL] Deinit flow completed
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [HEAP] deinitFlow completed Heap Total: 8337279 | SPI Free: 8197728 | SPI Large Block: 8126464 | SPI Min Free: 5967632 | Int Free: 139551 | Int Large Block: 90112 | Int Min Free: 103015
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [FLOWCTRL] Init flow
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [PSRAM] IMG_BASIS->CImageBasis (rawImage): Allocated: 921601
[0d02h14m30s] 2025-01-09T15:03:06 <ERR> [ALIGN] Alignmant marker image missing: '/sdcard/config/marker1.jpg' > Please update alignment marker
[0d02h14m30s] 2025-01-09T15:03:06 <ERR> [FLOWCTRL] Image Alignment: Init failed
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [TFLITE] Loading TFLITE model
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [TFLITE] Read TFLITE model file: /sdcard/config/models/dig-class100_0173_s2_q.tflite
[0d02h14m30s] 2025-01-09T15:03:06 <DBG> [PSRAM] TFLITE->modelfile: Allocated: 226968
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [TFLITE] TFLITE model successfully loaded
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [TFLITE] Allocating tensors
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [PSRAM] TFLITE->tensor_arena: Allocated: 819200
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [TFLITE] Tensors successfully allocated
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [CNN] CNN-Type: Digit - Class100
[0d02h14m31s] 2025-01-09T15:03:06 <INF> [CNN] Network parameter loaded: /sdcard/config/models/dig-class100_0173_s2_q.tflite
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [TFLITE] TFLITE arena - Used bytes: 50564
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [PSRAM] TFLITE->tensor_arena: Free memory
[0d02h14m31s] 2025-01-09T15:03:06 <DBG> [TFLITE] Loading TFLITE model
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [TFLITE] Read TFLITE model file: /sdcard/config/models/ana-class100_0171_s1_q.tflite
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] TFLITE->modelfile: Allocated: 133784
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [TFLITE] TFLITE model successfully loaded
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [TFLITE] Allocating tensors
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] TFLITE->tensor_arena: Allocated: 819200
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [TFLITE] Tensors successfully allocated
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [CNN] CNN-Type: Analog - Class100
[0d02h14m31s] 2025-01-09T15:03:07 <INF> [CNN] Network parameter loaded: /sdcard/config/models/ana-class100_0171_s1_q.tflite
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [TFLITE] TFLITE arena - Used bytes: 142160
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] TFLITE->tensor_arena: Free memory
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [POSTPROC] Number sequence: main, Digits: 0, Analogs: 0
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [POSTPROC] loadFallbackValue: nvs_open | No data in NVS namespace 'fallbackvalue'
[0d02h14m31s] 2025-01-09T15:03:07 <INF> [LOGFILE] Set log level to DEBUG
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [FLOWCTRL] Init flow completed
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [HEAP] initFlow done Heap Total: 6924371 | SPI Free: 6787352 | SPI Large Block: 6684672 | SPI Min Free: 5967632 | Int Free: 137019 | Int Large Block: 90112 | Int Min Free: 103015
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [FLOWCTRL] Deinit flow
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] TFLITE->modelfile: Free memory
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] TFLITE->modelfile: Free memory
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] AlgROI: Free memory
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [PSRAM] IMG_BASIS->CImageBasis (rawImage, 921601): Free memory
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [FLOWCTRL] Deinit flow completed
[0d02h14m31s] 2025-01-09T15:03:07 <DBG> [HEAP] deinitFlow completed Heap Total: 8337035 | SPI Free: 8197728 | SPI Large Block: 8126464 | SPI Min Free: 5967632 | Int Free: 139307 | Int Large Block: 90112 | Int Min Free: 103015
[0d02h14m31s] 2025-01-09T15:03:07 <ERR> [MAINCTRL] Process state: Initialization Failed
[0d02h14m33s] 2025-01-09T15:03:09 <INF> [CAMCTRL] Live stream started
[0d02h14m37s] 2025-01-09T15:03:13 <INF> [CAMCTRL] Live stream stopped

Something is wrong. Live Stream with flash ist working, aber with a blue=IO2 LED.
I already switched to IO48=digital flash light -> same, blue LED.

I didn't run initail setup yet, because without LED my cammera doesn't see anything on my meter. Can it be the issue?
I can try to light up with external light to go through setup

@Slider0007
Copy link
Owner Author

Slider0007 commented Jan 9, 2025

@Adminius

Something is wrong. Live Stream with flash ist working, aber with a blue=IO2 LED.

This is correct behaviour, because IO02 blue status LED is also on in parallel to defined flashlight GPIO pin whenever flash light is requested by the software.

I didn't run initail setup yet, because without LED my cammera doesn't see anything on my meter. Can it be the issue?
I can try to light up with external light to go through setup

Does this mean you have already aborted the setup and you're now in regular WebUI? This shouldn't be an issue in terms of hardware init. Software init aborted because you do not have any alignment marker configured. You could try to complete setup by generating any (in your case black) reference image and setup (in your case black) alignment marker. ROI setup is not mandatory to start cycle processing. It should start the cycle (with nonsense data) and should trigger the flashlight in first step "Take Image".

Software wise all looks ok so far (even the log is exptected in relation how you described your situation), so I believe it's hardware related or the used smartLED is a different type and therefore timing is not correct.

Alternativly, you could hook up an external LED to any of the spare GPIO pins and define it correctly in software (ON/Off, PWM or another smartLED is possible).
image

@Adminius
Copy link

Adminius commented Jan 9, 2025

ehh... I tried to make some "all black" reference images + 2x makers, initialisation is done now. and now WS2812 working ?!
sorry for confusion.
Let's see if a build in LED helps... I have some white spare LEDs also

@Slider0007
Copy link
Owner Author

Slider0007 commented Jan 9, 2025

@Adminius

ehh... I tried to make some "all black" reference images + 2x makers, initialisation is done now. and now WS2812 working ?!

Good to hear that it's now working. That's interessting and after a short check it seems it's not your fault :-) I assume there is a small software issue with this new board using a smartLED as default flashlight, because in setup routine GPIO handler was not initialized, therefore no smartLED flashlight in setup mode. I going to fix that... Thanks for your feedback.

@Adminius
Copy link

Adminius commented Jan 9, 2025

Thank you for your work!

I'll try to reproduce WiF/AP Issues.

My steps were:
flash via esp tool 3 single files and start:
LOG via web console: no wifi because no SD-Card

next step: put empty SD-Card and restart:
LOG via web console: SD card found, wifi AP start with name AI-on-the-edge (or so) -> but no wifi AP visible on phone/pc.

then put to special folder on sd-card from archive
LOG via web console: SD card found, wifi AP start with name AI-on-the-edge (or so) -> but no wifi AP visible on phone/pc.

then I edited config file on PC an ESP32-S3 started with connection to my home wifi

@Slider0007
Copy link
Owner Author

Slider0007 commented Jan 10, 2025

@Adminius

flash via esp tool 3 single files and start: LOG via web console: no wifi because no SD-Card

next step: put empty SD-Card and restart: LOG via web console: SD card found, wifi AP start with name AI-on-the-edge (or so) -> but no wifi AP visible on phone/pc.

then put to special folder on sd-card from archive LOG via web console: SD card found, wifi AP start with name AI-on-the-edge (or so) -> but no wifi AP visible on phone/pc.

then I edited config file on PC an ESP32-S3 started with connection to my home wifi

I wasn't able to reproduce fully, but maybe I figured something out. One upstream functionality which was implemented recently seems to be instable with ESP32S3 boards. Therefore I disabled this functionality for now and also merged this upstream change to this PR. This could potentially be related to your situation. Thanks for sharing your info.

BTW: The topic with the non-functionality of smartLEDs in setup mode is also fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants