Question/Issue:
[Describe the question or issue in detail]
Calling run_classifier() returns -3 (error code EI_IMPULSE_ERROR_INVALID_TENSOR_ARENA, invalid tensor arena), model inference fails.
Project ID:
[Provide the project ID]
1055362
Context/Use case:
[Provide context or use case where the issue is encountered]
The program cannot enter the inference stage after successful flashing.
Steps Taken:
- PSRAM allocation test (heap_caps_malloc to allocate 2MB memory): Passed, PSRAM hardware works normally
- Memory status check: The largest contiguous free block of internal SRAM is only 30KB, which cannot meet the 182KB arena requirement of the model
- Locate tensor arena allocation position: The static array static uint8_t tensor_arena[…] in tflite_micro.h is fixed in the .bss segment (internal SRAM)
- Modified code to allocate arena from PSRAM via heap_caps_calloc: PSRAM allocation succeeded at address 0x3c084b40
- Added debug print logs: AllocateTensors() returns 1 (TFLite error flag kTfLiteError)
Expected Outcome:
[Describe what you expected to happen]
The inference program runs normally.
Actual Outcome:
PSRAM Allocation: Success (Address: 0x3c084b40)
Model Loading: Success (version = 3)
MicroInterpreter Initialization: Success
AllocateTensors(): Failed, returned 1 (kTfLiteError)
Conclusion: PSRAM allocation is successful, but there is an abnormality in either the model file or the underlying TFLite Micro initialization process, and AllocateTensors() returns error code 1.
Serial Monitor Log Details:
[DEBUG] PSRAM free: 8369344 bytes
[DEBUG] PSRAM largest contiguous block: 8257524 bytes
[DEBUG] Arena size required: 182579 bytes
[DEBUG] tensor_arena = 0x3c084b40
[DEBUG] model = 0x3c05d9d0, version = 3
[DEBUG] MicroInterpreter created
[DEBUG] AllocateTensors() returned: 1
AllocateTensors() failed with error code: 1
Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Unhandled exception occurred.
Reproducibility:
- [√] Always
- Sometimes
- Rarely
Environment:
- Hardware: ESP32-S3 N16R8 (8MB PSRAM)
- Model: TFLite Micro object detection model generated by Edge Impulse, 96×96 image classification, required tensor arena size 182KB
- OS Version: Windows 10
- Edge Impulse Version: arduino-1.0.1-impulse-#2
Or
#define EI_STUDIO_VERSION_MAJOR 1
#define EI_STUDIO_VERSION_MINOR 93
#define EI_STUDIO_VERSION_PATCH 24
- Build Environment Details: Arduino IDE 2.3.6
Logs/Attachments:
Additional Information:
[Any other information that might be relevant]