Open chrisy810 opened 1 year ago
After tens of hours of testing, I discovered a fix (along with more issues, which I have solved).
By chance, I discovered that by enabling ESP32 S3 EYE BSP option in menuconfig (instead of the camera pin out of my specific board as an option I added manually), PSRAM would function normally and the system would crash at initializing the camera. The latter part is expected, but the former part gave me the intuition to later discover the fix.
The fix is to install the generic BSP dependency: espressif/esp_bsp_generic. I then ran into an issue where when I try to add any dependency through command line, I would get this:
Executing action: add-dependency
ERROR: Environment variable "TFLITE_USE_BSP_S3_EYE" is not set
I have no idea why this environment variable is related to adding dependencies, nor do I think I changed something I shouldn't to cause this to happen. I got around this problem by adding the dependency directly to the idf_component.yml file, which allowed the project to correctly build with this generic BSP dependency.
After which, everything worked out smoothly. PSRAM was successfully initialized and frame buffers were allocated to the PSRAM. I don't have enough technical experience to find out the root cause of this issue, heck, I can't even figure out how the sdkconfig file is generated; I could have just manually added the PSRAM configuration options if I figured out how sdkconfig file worked. That said, this workaround does solve the problem, so I will leave it to the author of this repository to figure out.
For the lack of psram option, we probably have to add esp_psram component over here:
/cc @tore-espressif regarding the add-dependency issue.
@chrisy810 Thank you for the detailed report! I could reproduce all the issues you mentioned. We recently refactored the examples to support more boards (and especially boards with cameras and displays), but unfortunately these regressions happened
idf.py add-dependency
, I'll follow this up internally with the idf-component-manager teamEDIT: The second issue will be fixed in upcoming release of idf-component-manager
@chrisy810 the issues should have been fixed with this change already merged to master: https://github.com/espressif/esp-tflite-micro/commit/85fdecd262413f18e0a9c11909710bcc8c034283
When will this change be published with a new release? ~Or can I test this via vscode esp-idf against master? (could not find any info how to set this up)~
Ok, so I found the correct pin config for the camera on Seeed Studio XIAO ESP32S3 Sense: https://github.com/Seeed-Studio/SSCMA-Micro/blob/dev/porting/espressif/boards/seeed_xiao_esp32s3/board.h
But HREF and Y9 are outside the range of the kconfig settings for these pins.
After adjusting the ranges, settings the custom cam default pins to the ones from the link I do not get the PSRAM error any longer, but instant cpu1 crashes:
Boot/Exception log: https://pastebin.com/uWxh9wxf
Here is how I configured XIAO ESP32S3 for the person detection example:
app_camera_esp.h
(follow the existing pattern in the file):#elif CONFIG_CAMERA_MODULE_XIAO_ESP32S3
#define CAMERA_MODULE_NAME "XIAO_ESP32S3"
#define CAMERA_PIN_PWDN -1
#define CAMERA_PIN_RESET -1
#define CAMERA_PIN_XCLK 10
#define CAMERA_PIN_SIOD 40
#define CAMERA_PIN_SIOC 39
#define CAMERA_PIN_D7 48
#define CAMERA_PIN_D6 11
#define CAMERA_PIN_D5 12
#define CAMERA_PIN_D4 14
#define CAMERA_PIN_D3 16
#define CAMERA_PIN_D2 18
#define CAMERA_PIN_D1 17
#define CAMERA_PIN_D0 15
#define CAMERA_PIN_VSYNC 38
#define CAMERA_PIN_HREF 47
#define CAMERA_PIN_PCLK 13
Kconfig.projbuild
under menu "Camera Configuration"
(follow the existing pattern):config CAMERA_MODULE_XIAO_ESP32S3
bool "XIAO-ESP32S3 by SEEED Studio"
Install the generic BSP package. The issue I previously faced and described in this GitHub Issue should have been fixed. Read the previous comments to learn about the problem if you face any issue installing it.
Go to menuconfig
and select CAMERA_MODULE_XIAO_ESP32S3
as the camera module under Application Configuration
Enable PSRAM in menuconfig
if you plan on using PSRAM. This is done with the following line in app_camera_esp.c
:
config.fb_location = CAMERA_FB_IN_PSRAM; // For DRAM, use "CAMERA_FB_IN_PSRAM"
Please let me know if you face more issues. I recently completed a TinyML project using XIAO ESP32S3. I should be fairly familiar with the person detection example in this repo, which I used as a framework to build my project upon.
I need to reinstall esp-idf without VSCode. This managed environment is only causing issues for me. After several tries to get it to use the new Kconfig entries I managed to rebuilt it with your suggestions. And it finally works now :)
So the main points are indeed the added BSP dependency: espressif/esp_bsp_generic Adding the config table to app_camera_esp.h and config entry to Kconfig.projbuild Then I had to clean the project, build first, THEN do menuconfig and was finally able to select the new entry.
Thanks @chrisy810 !
Oh and merry christmas!
you can allocate memory for your TensorArena on PSRAM. change this block on .ino file:
if (tensor_arena == NULL) {
//allocate memory for TensorArena on PSRAM
tensor_arena = (uint8_t *) ps_malloc(kTensorArenaSize);
}
My board is XIAO ESP32S3 Sense, which has 8MB of PSRAM. When testing out the person detection example, after setting up the camera pins, I was able to successfully run it with camera frame buffers allocated to DRAM. If I allocate to PSRAM, I will receive the error below when initializing. I also was not able to find PSRAM related settings in menuconfig despite being on the latest ESP-IDF version, while these options are available in a new project. My development environment is VSCode on Windows 11. Same issue persists when switching to a different Windows 11 machine with the same setup and source code, and when switching to a different XIAO ESP32S3 Sense instance. PSRAM also functions properly for examples in Arduino IDE that require PSRAM.