Skip to content

fix(p4-eth/p4-nano): Fix audio and screen to match waveshare hardware better - #701

Open
finger563 wants to merge 13 commits into
mainfrom
fix/esp32-p4-panel-dsi-read-watchdog
Open

fix(p4-eth/p4-nano): Fix audio and screen to match waveshare hardware better#701
finger563 wants to merge 13 commits into
mainfrom
fix/esp32-p4-panel-dsi-read-watchdog

Conversation

@finger563

Copy link
Copy Markdown
Contributor
  • fix(esp32-p4): Skip MIPI-DSI DCS reads during panel init (watchdog hang)
  • fix(esp32-p4): Per-panel MIPI-DSI lane bit rate (1500 for ILI9881C)
  • fix(esp32-p4): Send panel vendor init before creating the DPI panel (DSI FIFO hang)
  • fix(esp32-p4): Drive the Waveshare 10.1" JD9365 panel with the vendor component
  • fix(esp32-p4): Espp-native JD9365 driver; single I2C owner fixes touch/audio/backlight
  • fix touch inversion
  • match eth kit
  • fix(esp32-p4): Feed I2S playback at a constant frame cadence (choppy audio)
  • feat(esp32-p4): Add clear_audio() and restart the click sound on each touch
  • fix(esp32-p4): Run the camera SCCB at 100 kHz like Waveshare's demos
  • fix(esp32-p4): Example polish - click gating, WAV data-chunk parsing, tab scroll

Description

Motivation and Context

How has this been tested?

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Hardware

  • I have updated the design files (schematic, board, libraries).
  • I have attached the PDFs of the SCH / BRD to this PR
  • I have updated the design output (GERBER, BOM) files.

finger563 and others added 11 commits August 6, 2026 10:02
On the Waveshare ESP32-P4-NANO/ETH the 10.1" ILI9881C panel does not answer
MIPI-DSI DCS reads (bus turn-around), and the ESP-IDF DSI HAL busy-waits on the
read with no timeout. The optional panel-ID read in Ili9881::initialize() therefore
hung panel bring-up and tripped the task watchdog (IDLE0 starvation) instead of
showing the display.

Stop passing a read_command to the panel driver in both BSPs so it skips the ID
read and initializes with writes only.

Reported on hardware (esp32-p4-nano + 10.1" ILI9881C). Builds for esp32p4 on
ESP-IDF 6.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…DSI FIFO hang)

initialize_lcd() created the DPI video panel (esp_lcd_new_panel_dpi) BEFORE sending
the panel controller's vendor init sequence over DBI. esp_lcd_new_panel_dpi() starts
the HS video stream immediately, and while it is running the DSI cannot drain the
low-power command FIFO. A short init (EK79007) fits the FIFO, but ILI9881C's 202
commands overflow it, so the HAL busy-waits on a full FIFO and the task watchdog
fires during Ili9881::initialize().

Reorder so the vendor init runs while the DSI is still in command mode, then create
the DPI panel and start video. Applies to both esp32-p4-nano and esp32-p4-eth.

Builds for esp32p4 on ESP-IDF 6.0. Hardware test pending (esp32-p4-eth + ILI9881C).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… component

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…h/audio/backlight

The waveshare/esp_lcd_jd9365 component brought the display up but internally
creates its own I2C bus on hardcoded SDA=7/SCL=8 (I2C_NUM_1) for the panel's
power controller at 0x45 - and never deletes it (the cleanup is commented out in
its source). That second master on the BSP's own I2C pins broke every subsequent
transaction on the BSP bus: GT911 probe timeouts, ES8311 and backlight writes
failing with ESP_ERR_INVALID_RESPONSE.

Replace the component with an espp-native driver so exactly one I2C owner exists:

- New espp::Jd9365 (display_drivers/jd9365.hpp), modeled on espp::Ili9881, with
  the component's active 200-entry vendor init table converted verbatim
  (attributed, Apache-2.0), the same no-GPIO reset (DCS SWRESET + 120 ms), and
  the same DCS order (user page, MADCTL, COLMOD, 2-lane config, table,
  SLPOUT/DISPON). No DCS reads.
- BSPs run the panel power-on sequence over their own internal_i2c_ before DSI
  init (0x45: 0x95=0x11, 0x95=0x17, 0x96=0x00, 100 ms, 0x96=0xFF, 1 s), then the
  espp-driver path with the identical DPI timing; on IDF >= 6.0 the JD9365 path
  also enables DMA2D like the vendor component did.
- brightness() now writes the correct backlight register 0x96 (0-255); 0x86 is
  used by other panel revisions in Waveshare's BSP.
- Drop the waveshare/esp_lcd_jd9365 dependency (and transitively i2c_bus).

Applies to both esp32-p4-nano and esp32-p4-eth; builds green for esp32p4 on
ESP-IDF 6.0. Display verified on hardware with the vendor flow; this preserves
that flow byte-for-byte while unbreaking I2C. Hardware re-test pending.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…audio)

The audio task drained the TX stream buffer by writing only the currently
`available` bytes to I2S each cycle. With a bursty producer that makes the DMA
cadence variable and interleaves full frames of silence into continuous program
material, which sounds choppy/glitchy - notably worse than the m5stack-tab5,
whose playback path (like esp-box and t-deck) always writes a full, frame-aligned
buffer with the queued samples zero-padded to buffer_size so the DMA is fed at a
constant cadence.

Match that proven path in esp32-p4-eth, esp32-p4-nano, and the
esp32-p4-function-ev-board (where the pattern was copied from).

Builds green for esp32p4 on ESP-IDF 6.0 (eth + nano examples).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… touch

Clicks were queueing: play_audio() appends to a large TX stream buffer (up to
~64 KB), so rapid touches serialized their click sounds behind whatever was
still queued, playing long after the touches stopped. Add clear_audio(), which
drops any queued-but-unplayed audio (the current ~16 ms DMA frame still
finishes), and use it in the examples' touch handler so each new touch restarts
the click immediately for responsive UI feedback.

Applies to esp32-p4-eth and esp32-p4-nano; builds green on ESP-IDF 6.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Waveshare's own working OV5647 demos for these boards run the SCCB at 100 kHz
(their Kconfig floor), while we inherited 400 kHz from the tab5. Some OV sensors
probe unreliably at higher SCCB rates, and esp_video applies this frequency to
the SCCB device even when reusing an external I2C bus handle, so match the
vendor's proven value.

Verified against the board schematics that the rest of the camera topology is
correct as-is: the CSI connector's SCCB is the shared GPIO7/8 bus, the module
enable line (CSI_IO0) is pulled high in hardware, and there is no reset/pwdn
GPIO to drive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… tab scroll

- Gate the touch click sound (and circle draw) to the draw/status page, so
  touches on the Audio/Camera tabs stay silent like the other BSP examples.
- Parse the WAV RIFF chunks properly and play exactly the 'data' payload. The
  fixed 44-byte strip played the file's trailing metadata chunks (cue/LIST/bext,
  686 bytes in click.wav) as audio, causing a pop at the end of every click.
- Disable LV_OBJ_FLAG_SCROLLABLE on the individual tab pages so drags inside a
  page don't rubber-band/scroll (the tabview content swipe was already off).

Applies to esp32-p4-eth and esp32-p4-nano examples; builds green on ESP-IDF 6.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 6, 2026 20:44

Copilot AI left a comment

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

finger563 and others added 2 commits August 6, 2026 16:21
…own-edge only

Touch drawing produced few points because Gui::draw_circle() (called from the
60 Hz touch poll task) locked the same mutex Gui::update() holds for the whole
lv_task_handler() render - tens of ms per frame on the 800x1280 panel with CPU
software rotation - so the touch task spent most of each frame blocked and the
effective sample rate collapsed. draw_circle() now just queues the point under a
small dedicated lock and the GUI update task drains the queue under the LVGL
mutex, so touch sampling runs at the full poll rate regardless of render time.

Also fire the click sound only on the touch-DOWN edge (prev.num_touch_points ==
0) instead of on every reported change: previously each drag movement counted as
a "new touch", which both restarted the click continuously while drawing and was
the original source of the queued-clicks behavior.

Touch is polled (~60 Hz / 16 ms; the GT911 INT line is not wired to the P4 on
these boards) - the sparse points were mutex contention, not the poll rate, and
not audio (play_audio is a 0-timeout non-blocking enqueue).

Applies to esp32-p4-eth and esp32-p4-nano examples; builds green on ESP-IDF 6.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…art)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

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