Skip to content

fix(esp_board_manager): gate PDM RX HP-filter fields on chip cap (AUD-7249) - #45

Open
PascalAI2024 wants to merge 1 commit into
espressif:mainfrom
PascalAI2024:fix/pdm-rx-hp-filter-cap
Open

fix(esp_board_manager): gate PDM RX HP-filter fields on chip cap (AUD-7249)#45
PascalAI2024 wants to merge 1 commit into
espressif:mainfrom
PascalAI2024:fix/pdm-rx-hp-filter-cap

Conversation

@PascalAI2024

Copy link
Copy Markdown

Closes #44.

Bug

packages/esp_board_manager/peripherals/periph_i2s/periph_i2s.py::build_pdm_rx_slot_config() emits hp_en, hp_cut_off_freq_hz, and amplify_num for any chip with SOC_I2S_HW_VERSION_2. On ESP32-S3, the generated init code fails to compile:

error: 'i2s_pdm_rx_slot_config_t' has no member named 'hp_en'

Root cause

In ESP-IDF components/esp_driver_i2s/include/driver/i2s_pdm.h, those three struct fields are gated by a separate cap, not by HW version:

#if SOC_I2S_HW_VERSION_2
    bool                  hp_en;
    float                 hp_cut_off_freq_hz;
    uint32_t              amplify_num;
#endif

Wait — actually they sit under SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER in current IDF. Either way the relevant cap is SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER, which is currently only set on ESP32-P4 (components/soc/esp32p4/include/soc/Kconfig.soc_caps.in). ESP32-S3 is SOC_I2S_HW_VERSION_2 == 1 but SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER is not defined for it, so i2s_pdm_rx_slot_config_t has no hp_en field on S3 — and the codegen-emitted initializer fails to compile.

The Python codegen was using HW version as a proxy for the HP-filter cap, but those two are not equivalent. HW_VERSION_2 chips (S3, C3, C5, C6, C61, H2, H21, H4, P4) is a strict superset of chips with the HP-filter cap (P4 only).

Fix

Restrict emission of hp_en / hp_cut_off_freq_hz / amplify_num to chips that actually expose the cap. Today that is just ESP32-P4; if a future target also sets SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER, add it to the tuple.

chip_supports_pdm_rx_hp_filter = get_effective_chip_name() in ('esp32p4',)
if hw_version == 2 and chip_supports_pdm_rx_hp_filter:
    slot_cfg['hp_en'] = bool(cfg.get('hp_en', True))
    ...

ESP32 / ESP32-S2 (HW_VERSION_1) are unaffected — they never entered the branch. ESP32-P4 is unaffected — it still gets the fields. ESP32-S3 / C3 / C5 / C6 / C61 / H2 / H21 / H4 stop emitting the fields they don't have, fixing the build.

Verification

Verified hardware: Seeed XIAO ESP32-S3 Sense, ESP32-S3R8, IDF v5.5.4-299-ge46782886f.

After the patch, the generated audio_board_init.c compiles, the firmware flashes, and the PDM mic comes up at 16 kHz mono on real silicon.

Test plan

  • Built for ESP32-S3 (Seeed XIAO ESP32-S3 Sense) — compiles, flashes, boots, mic captures audio
  • Built for ESP32-P4 — HP filter fields still emitted (please verify in CI; esp32p4 remains in the gate tuple)
  • Built for ESP32 / ESP32-S2 (HW_VERSION_1) — untouched code path, should be a no-op (please verify in CI)

The PDM RX slot codegen emits `hp_en`, `hp_cut_off_freq_hz`, and
`amplify_num` for any chip with SOC_I2S_HW_VERSION_2, but these struct
fields are gated by SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER, which is currently
only set on ESP32-P4. ESP32-S3 has HW_VERSION_2 but lacks the cap, so
builds fail with:

    error: 'i2s_pdm_rx_slot_config_t' has no member named 'hp_en'

Restrict the emission to chips that actually support the cap.

Verified on real hardware: a Seeed XIAO ESP32-S3 Sense board adaptation
compiles, flashes, and boots — PDM mic comes up at 16 kHz mono.

Refs: espressif#44
@github-actions github-actions Bot changed the title fix(esp_board_manager): gate PDM RX HP-filter fields on chip cap fix(esp_board_manager): gate PDM RX HP-filter fields on chip cap (AUD-7249) May 1, 2026
@LiuCodee

LiuCodee commented May 8, 2026

Copy link
Copy Markdown
Contributor

Processing this fix. The issue will be fixed in v0.5.10.

@LiuCodee

Copy link
Copy Markdown
Contributor

This fix has now been included in v0.5.10. Thanks again for the contribution and testing!

Also, esp_board_manager now has a standalone repository. Feel free to report future issues or submit PRs there:
https://github.com/espressif/esp-board-manager

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.

esp_board_manager: PDM RX codegen emits HP-filter fields on chips that lack SOC_I2S_SUPPORTS_PDM_RX_HP_FILTER (ESP32-S3 build fails) (AUD-7248)

2 participants