Skip to content

rework psram_mode frame buffer overflow check #781

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

Conversation

RubenKelevra
Copy link
Contributor

@RubenKelevra RubenKelevra commented Jul 31, 2025

Description

Follow-Up for PR #772

  • Do this check only in psram_mode
  • Improve code comment, to make clear that it will stop early on copy operations
  • Increase fb size by one dma_half_buffer_size in psram_mode

Rationale:

In psram_mode we will be called after each memory copy operation is completed, by the CAM_IN_SUC_EOF event. Since we cannot predict at this point, if the camera will copy another dma_half_buffer_size into the fb, we need to abort here, if there's not enough size in the fb for the next copy operation.

This assumption means, we will abort even if this is indeed the last copy operation the camera did, and the next event will be a CAM_VSYNC, notifying us, that the copy operation is completed.

Since we cannot predict this, we need one dma_half_buffer_size more space in the fb in psram_mode to allow images of the same size in psram_mode as in the regular mode.

Related:

Fixes espressif/arduino-esp32#11674

Fixes the same issue observed on jpeg images here

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

- Do this check only in psram_mode
- Improve code comment, to make clear that it will stop early on copy operations
- Increase fb size by one dma_half_buffer_size in psram_mode

Rationale:

In psram_mode we will be called after each memory copy operation is completed, by
the CAM_IN_SUC_EOF event. Since we cannot predict at this point, if the camera
will copy another dma_half_buffer_size into the fb, we need to abort here,
if there's not enough size in the fb for the next copy operation.

This assumption means, we will abort even if this is indeed the last
copy operation the camera did, and the next event will be a CAM_VSYNC,
notifying us, that the copy operation is completed.

Since we cannot predict this, we need one dma_half_buffer_size more
space in the fb in psram_mode to allow images of the same size in
psram_mode as in the regular mode.
@RubenKelevra RubenKelevra force-pushed the buffer_overflow_check_rework_for_psram_mode branch from d6fbaf0 to 5bb9bfe Compare August 4, 2025 17:36
@RubenKelevra
Copy link
Contributor Author

RubenKelevra commented Aug 4, 2025

I switched from ESP_LOGE() to a more lightweight ESP_CAMERA_ETS_PRINTF() due to issues with the stack size, for the print in this part of the code.

The rest of the prints have been filed as a separate PR:

#787

(includes of both will lead to a mild conflict)

@me-no-dev me-no-dev merged commit 307bcc0 into espressif:master Aug 5, 2025
30 checks passed
@RubenKelevra RubenKelevra deleted the buffer_overflow_check_rework_for_psram_mode branch August 5, 2025 19:17
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.

ESP32 3.3.0 - Only Pixformat JPEG works
2 participants