Skip to content

Unify differences of I2S hardware via metadata, add C5 and C61 I2S support#5483

Merged
bugadani merged 9 commits intoesp-rs:mainfrom
playfulFence:unify_periphs
May 5, 2026
Merged

Unify differences of I2S hardware via metadata, add C5 and C61 I2S support#5483
bugadani merged 9 commits intoesp-rs:mainfrom
playfulFence:unify_periphs

Conversation

@playfulFence
Copy link
Copy Markdown
Member

closes #5482
closes #5172
closes #5415

Testing

HIL tests

@playfulFence playfulFence changed the title Unify I2S differences of hardware via metadata, add C5 and C61 I2S support Unify differences of I2S hardware via metadata, add C5 and C61 I2S support Apr 30, 2026
@playfulFence
Copy link
Copy Markdown
Member Author

/hil full --tests i2s

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

Triggered full HIL run for #5483.

Run: https://github.com/esp-rs/esp-hal/actions/runs/25173460536

Status update: ❌ HIL (full) run failed (conclusion: failure).

@playfulFence
Copy link
Copy Markdown
Member Author

HIL failure in CI doesn't seem to be related to the changes, runners might have some problems 🤔

Comment thread esp-hal/src/i2s/master.rs Outdated
Comment on lines +1864 to +1873
#[cfg(not(i2s_bck_divider_in_conf))]
self.regs().rx_conf1().modify(|_, w| unsafe {
w.rx_bck_div_num()
.bits((clock_settings.bclk_divider - 1) as u8)
});
#[cfg(i2s_bck_divider_in_conf)]
self.regs().rx_conf().modify(|_, w| unsafe {
w.rx_bck_div_num()
.bits((clock_settings.bclk_divider - 1) as u8)
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a PAC change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately, these seem to be different HW layouts really 😞

Comment thread esp-metadata/src/cfg.rs Outdated
#[serde(default)]
/// Whether MSB shift fields live in the main TX/RX_CONF registers.
/// Another option is CONF1 registers.
msb_shift_in_conf: bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These warrant a v3, perhaps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meeeh 🤔

I think version covers pretty much enough of HW differences... These look more like weird field-placement quirk inside the v2 family (directly related to the earlier review though), I don't think it warrants a separate v3 tbh...

What might make sense though is to unite bck_divider_in_conf and msb_shift_in_conf as they describe the same chips from v2 gen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with @bugadani -the TRMs at least show even more than three variants of I2S_DATE_REG values

Comment thread esp-metadata/CHANGELOG.md
Comment on lines 12 to +14
- C5 and C61: Enable RTC timekeeping (#5449)
- C5 and C61: I2S support (#5483)
- More I2S flags for HW unification (#5483)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to maintain a changelog for esp-metadata. This is purely intended to generate esp-metadata-generated, really, and we can consider stopping to release it, even.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to revert these 2 entries or let's roll with them one last time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep them but the changelog is full of holes already :)

Comment thread esp-hal/src/soc/esp32c61/mod.rs Outdated
#[cfg_attr(not(feature = "unstable"), allow(unused))]
pub(crate) mod constants {
/// The clock frequency for the I2S peripheral in Hertz.
pub const I2S_SCLK: u32 = 160_000_000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these constants should go into esp-metadata (for the I2S driver)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not SCLK, we should be able to query this from the clock tree.

Comment thread esp-hal/src/i2s/master.rs Outdated
"dma_channel" => {
cfg(any(esp32, esp32s2)) => "DMA_I2S0",
cfg(not(any(esp32, esp32s2))) => "DMA_CH0"
cfg(i2s_version = "1") => "DMA_I2S0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe checking dma_kind = "pdma" / dma_kind = "gdma" would be more "correct"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it won't scale well for P4, unfortunately

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, this works here, but since the P4 has two independent GDMAs with different peripheral assignment, the same scheme won't work for SPI and others - so we'll need something else, going forward.

Copy link
Copy Markdown
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a good start for now - we'll see how things work out with the next chip I guess

Copy link
Copy Markdown
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's block this on #5400 for a short bit

@github-actions github-actions Bot added the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

New commits in main have made this PR unmergeable. Please resolve the conflicts.

@playfulFence playfulFence requested a review from bugadani May 5, 2026 09:17
@github-actions github-actions Bot removed the merge-conflict Merge conflict detected. Automatically added/removed by CI. label May 5, 2026
@bugadani bugadani enabled auto-merge May 5, 2026 09:22
@bugadani bugadani added this pull request to the merge queue May 5, 2026
Merged via the queue into esp-rs:main with commit 2e8493a May 5, 2026
23 checks passed
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.

Driver code unification: I2S ESP32-C61 I2S ESP32-C5: I2S peripheral tracking issue

3 participants