Skip to content

feat: add PSRAM-DMA flag + runtime API for ESP32-S2/S3; remove 16MHz heuristic #774

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RubenKelevra
Copy link
Contributor

@RubenKelevra RubenKelevra commented Jul 17, 2025

Description

Add a Kconfig switch (CONFIG_CAMERA_PSRAM_DMA) to enable camera to PSRAM
DMA copy on ESP32-S2 and ESP32-S3 targets, in favor of removing the
undocumented "set XCLK=16MHz to enable PSRAM DMA" heuristic.

cam_hal.c:

  • Select psram_mode = true when CONFIG_CAMERA_PSRAM_DMA && target is S2/S3.
  • Otherwise psram_mode = false.
  • Log whether PSRAM DMA mode is enabled.

Kconfig:

  • New bool CAMERA_PSRAM_DMA (default n) under Camera configuration.

Runtime control:

  • New public API:
    • esp_camera_set_psram_mode(bool enable)
    • esp_camera_get_psram_mode(void)
    • esp_camera_reconfigure(const camera_config_t *cfg)

README/test:

  • Remove stale 16MHz XCLK comments.
  • Add short note describing CONFIG_CAMERA_PSRAM_DMA.

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.

@me-no-dev
Copy link
Member

please think of a way to make this runtime configurable. The driver is used in Arduino, which uses a pre-compiled version of the driver and can not change sdkconfig on the fly

@RubenKelevra
Copy link
Contributor Author

Oh okay, wasn't aware of this limitation.

What do you think of putting the capability behind a build flag thought, that would make the binary a bit smaller on devices which don't need it (which do usually have also very limited ROM).

@RubenKelevra RubenKelevra marked this pull request as draft July 18, 2025 08:46
@me-no-dev
Copy link
Member

The driver runs only on ESP32, ESP32S2 and ESP32S3 which do not have such limitation. One option is to have a flag in the camera config (at the end), but preferably is to be set some other way, like a method that would set a flag in the driver, so it does not break existing code.

@RubenKelevra
Copy link
Contributor Author

Okay, will do, as soon as I'm back home.

Since you've implemented it: Have you recently tested this mode?

@RubenKelevra RubenKelevra force-pushed the feat/introduce_flag_to_enable_psram_dma branch 2 times, most recently from ef1c0da to ba2a8be Compare July 18, 2025 22:23
@RubenKelevra RubenKelevra changed the title feat: add CONFIG_CAMERA_PSRAM_DMA for ESP32-S2/S3; remove 16MHz heuristic feat: add PSRAM-DMA flag + runtime API for ESP32-S2/S3; remove 16MHz heuristic Jul 18, 2025
@RubenKelevra RubenKelevra marked this pull request as ready for review July 18, 2025 22:25
@RubenKelevra RubenKelevra marked this pull request as draft July 18, 2025 22:26
…heuristic

Add a Kconfig switch (CONFIG_CAMERA_PSRAM_DMA) to enable camera to PSRAM
DMA copy on ESP32-S2 and ESP32-S3 targets, in favor of removing the
undocumented "set XCLK=16MHz to enable PSRAM DMA" heuristic.

cam_hal.c:
- Select psram_mode = true when CONFIG_CAMERA_PSRAM_DMA && target is S2/S3.
- Otherwise psram_mode = false.
- Log whether PSRAM DMA mode is enabled.

Kconfig:
- New bool CAMERA_PSRAM_DMA (default n) under Camera configuration.

Runtime control:
- New public API:
  - esp_camera_set_psram_mode(bool enable)
  - esp_camera_get_psram_mode(void)
  - esp_camera_reconfigure(const camera_config_t *cfg)

README/test:
- Remove stale 16MHz XCLK comments.
- Add short note describing CONFIG_CAMERA_PSRAM_DMA.
@RubenKelevra RubenKelevra force-pushed the feat/introduce_flag_to_enable_psram_dma branch from ba2a8be to 1484db7 Compare July 18, 2025 23:17
@RubenKelevra RubenKelevra marked this pull request as ready for review July 18, 2025 23:36
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