Skip to content

feat(jieli): AC792 audio board wiring, adapter contract tests, and the JIELI pin bump - #728

Closed
maidang-xing wants to merge 1 commit into
tuya:masterfrom
maidang-xing:codex/tuya-ai-hold-chain
Closed

maidang-xing wants to merge 1 commit into
tuya:masterfrom
maidang-xing:codex/tuya-ai-hold-chain

Conversation

@maidang-xing

@maidang-xing maidang-xing commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Companion to tuya/TuyaOpen-JieLi#11. Depends on that PR merging first — the pin below points at a commit on that PR's branch, so a build of this branch before #11 merges will fail to resolve the platform commit.

What this carries

  • boards/JIELI/AC792N_Develop_Board/audio_config.h — records which onboard microphone is captured and why (ADC1 over ADC0, measured), and that the two microphones cannot be opened together because the vendor ADC asserts on the second one.
  • boards/JIELI/AC792N_Develop_Board/CMakeLists.txt — exports JIELI_BOARD_AUDIO_CONFIG so the CMake adapter target compiles the audio sources against this board's mic-routing macros, matching what the staged vendor Makefile already does. Without it the wl83 leg does not build at all.
  • tests/platform/test_jieli_tkl_audio_output.py — regression tests pinning the playback volume path (the vendor state switch, the 0-100 DAC level scale, the Q14 digital-gain curve and its ordering after channel start) and the capture path (the ADC 0-19 gain scale, which is a different range from the DAC's and must not be "aligned" to it).
  • platform/platform_config.yaml — JIELI pin moves from ec4c6cce to 8e5fdf3d, the head of the platform branch.

The pin move exposed stale platform contracts — they are repointed here

Moving the pin past the TKL adapter refactor turned 35 of this repo's source-contract tests red. Those tests read platform source files as text and assert on their shape, and the refactor moved the code they were written against — so they had been stale all along, latent only because the pin had not moved.

They are repointed, not weakened; each assertion now pins the mechanism that replaced the one it described:

  • the audio provider tests scope to the WL83 region of the folded tkl_audio.c;
  • the build tests follow the logic from jieli_build.py into tools/jieli_build/;
  • the entry-point assertions follow tuyaos_switch_app_main.c to tuyaos/entry/jieli_app_entry.c;
  • the backend-install assertions invert to pin the vtable's absence, which is the point of the fold;
  • the queue tests follow the vendor os_q_* API to the local ring buffer that replaced it (chosen because the two SDKs disagree on os_q_post_to_back()'s message semantics and os_q_pend()'s timeout encoding);
  • the K1-key assertions follow the build-time board.c patching to the board adkey config and TDL registration that replaced it;
  • the MAC assertions follow the deleted tkl_jieli_chip_mac.c into tkl_wifi.c / tkl_bluetooth.c.

One test was dropped rather than repointed: test_jieli_uart_hello.py asserted a bring-up banner that the refactor deleted from tuyaos_app_main.c, and read examples/get-started/jieli_uart_hello, which has never been committed to this branch (it lives on feat/jieli-7916-uart). It had failed since before the pin move. It should come back with the example that gives it meaning.

Verification

  • Outer repo: 83 passed, 10 subtests passed.
  • Platform repo: 40 passed, 4 subtests passed.
  • Both chips build green against the platform branch (switch_demo on wl83 and wl82, output_speaker on wl83 — BUILD SUCCESS, zero undefined references).
  • Hardware-verified on an AC792N board: the 1 kHz boot tone plays and the ADKEY microphone loopback returns the speaker's voice.

Note

The two audio fixes themselves (playback audibility, capture gain) are diagnosed and documented in tuya/TuyaOpen-JieLi#11, where the adapter code lives.

test_jieli_config.py now pins the platform registry commit SHA literally, so it needs a one-line update on every future pin move. That is deliberate — the drift guard is what caught this one.


Added since first opened

The pin moved again, to 7d24da28 — the platform branch now also carries the board/TKL/app layer separation (see tuya/TuyaOpen-JieLi#11), which had not been pushed when this PR first went up. The registry drift guard in test_jieli_config.py moved with it.

your_chat_bot gains the gitignored-license hook the other apps have. switch_demo and friends keep real credentials in a gitignored tuya_config_secrets.h that tuya_config.h pulls in via #if __has_include; this app had none, so its tracked header was the only place to put a license. Same hook added, placeholders guarded, plus a tracked .example template.

A crash fix, and an honest caveat about it. your_chat_bot crashed and rebooted ~0.47 s into startup on AC792N, at the instant wq_highpri started. A controlled A/B — same app, same board, firmware built from the pre-change platform commit — crashed identically, so the defect predates the layer separation. The evidence points at the work-queue stacks: switch_demo carries CONFIG_STACK_SIZE_MSG_QUEUE=10240 / CONFIG_STACK_SIZE_WORK_QUEUE=8192 with a comment recording that the 4096 default overflowed wq_highpri and corrupted FreeRTOS list nodes; your_chat_bot carried neither. Confirmed on hardware. Flashed, and the app now passes the old crash point and runs on: reset_netcfg's timer starts, netmgr [wifi] register start, tuya_iot_init success at 1.391 s (the old crash was at 0.472 s), and it is still alive at 11.95 s with no reboot in the capture. Note commit a05dfaea's body still carries the pre-verification caveat; it is superseded by this, and the history is left unrewritten rather than force-pushed.

One test repointed. test_full_stack_audio_provider_is_registered_before_tkl_init pinned a call that the layer separation moved into tkl_init(); it had been failing unnoticed because no step between those commits ran the suite. Now pins the new location at equal strength.

Outer repo suite: 83 passed, 10 subtests passed. Platform suite: 40 passed, 4 subtests passed.

Squashed from the 21-commit series so the PR carries a single commit.

Platform registration and pinning:
- register JIELI in platform_config.yaml and move the pin to each contract
  the tests below lock down
- board definitions for AC7916A (wl82) and AC792N (wl83), with switch_demo
  defaulting to the AC791 board
- AC79x audio and board peripheral support, handing the CMake audio adapter
  this board's mic routing

Board/TKL layering:
- make the board the only key path and drop the vendor key path from the
  platform entry
- give your_chat_bot the gitignored license hook the other apps have

Stack headroom, both found by crashing on AC792N:
- wq_highpri / wq_system: 4096/5120 -> 10240/8192, matching switch_demo.
  wq_highpri runs the BLE netcfg completion chain and the default
  overflowed it, corrupting FreeRTOS list nodes.
- tuya_app_main: 4096 -> 8192. The tuya_iot_yield() loop drives the mbedtls
  handshake, HTTP and MQTT from this thread, and the stock 4 KB overflowed
  during the iotdns TLS connect. Measured with a pre-connect SP probe: the
  chain has consumed 1504 B by the time mbedtls_ssl_handshake() is entered,
  leaving 2516 B of the 4 KB for the handshake itself, which is not enough
  (SP ran >=116 B past the stack floor).
- ai_client: 4096 -> 8192. Getting a CA for rtc-ai1-*.tuyacn.com makes it
  run an iotdns TLS handshake on its own stack, which overflowed the same
  way.

Tests:
- adapter contract tests pinned to the refactored layout: TKL-only sources,
  the quiet ATT write callback, resident STA worker semantics, the board-only
  key path, the tkl_init audio bring-up and the posix-rendered TOOL_DIR
- lock the AC792 audio adapter contracts and pin the VAD capture feeder's
  cross-callback accumulation
@maidang-xing
maidang-xing force-pushed the codex/tuya-ai-hold-chain branch from 47aee56 to 18808a1 Compare October 8, 2026 03:43
@maidang-xing

Copy link
Copy Markdown
Contributor Author

Superseded by #730, which carries the same work squashed onto xb/tuyaopen-jl.

This PR was based on master; the Jieli work belongs on xb/tuyaopen-jl (#725 and #715 already target it). #730 also adds the AC792N audio board wiring, the your_chat_bot stack fixes and the adapter contract tests, and moves the JIELI pin to a84e800c (the platform commit merged as tuya/TuyaOpen-JieLi#11) — the old pin 7d24da28 is no longer reachable on the platform's master.

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.

1 participant