Skip to content

piolib: do not try to claim DMA channels that machine has already used - #65

Merged
soypat merged 1 commit into
mainfrom
dma-skip-machine
Oct 11, 2026
Merged

soypat merged 1 commit into
mainfrom
dma-skip-machine

Conversation

@deadprogram

@deadprogram deadprogram commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

TinyGo machine always uses DMA channel 0 for SPI0 and DMA channel 1 for SPI1. See spi0DMAChannel in src/machine/machine_rp2.go.

ClaimChannel in piolib started the search at channel 0. Thus a piolib driver can get the same channel as SPI0.

Example: piolib.I2S sends audio and an SD card is on SPI0. The first SPI write changes the I2S DMA channel. Then the program stops.

This change starts the search at channel 2.

Test on a xiao-rp2350 with piolib.I2S to a PCM5102 and a microSD card on SPI0:

  • Before: the program stops at the first SD read after I2S starts.
  • After: audio plays correctly while the program reads from the SD card.

TinyGo machine always uses DMA channel 0 for SPI0 and channel 1 for SPI1.
ClaimChannel started at channel 0, so I2S got the same channel as SPI0.
The first SPI write then stopped the I2S DMA and the program hung.
Start the search at channel 2.
@deadprogram deadprogram changed the title piolib: do not claim the DMA channels that machine uses piolib: do not try to claim DMA channels that machine has already used Oct 11, 2026
@deadprogram

Copy link
Copy Markdown
Member Author

@soypat I need this for https://github.com/hybridgroup/tinypod if you could PTAL? Thank you!

@soypat
soypat merged commit ef634f7 into main Oct 11, 2026
1 check passed
@soypat
soypat deleted the dma-skip-machine branch October 11, 2026 13:43
@soypat

soypat commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the contribution!

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