Skip to content

sof-remote-server: Add Android (AOSP/NDK Bionic + TinyALSA) build support - #4

Draft
lgirdwood wants to merge 1 commit into
mainfrom
feat/android-remote-server
Draft

lgirdwood wants to merge 1 commit into
mainfrom
feat/android-remote-server

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Summary

Adds Android (AOSP Soong and standalone NDK/AOSP Clang cross-compilation) build and deployment support for sof-remote-server (sof_remote_server and sof-remote):

  1. AOSP Soong Integration & Init Service:

    • Adds sof-remote-server/Android.bp defining cc_binary targets for sof_remote_server and sof-remote (vendor: true, linking libtinyalsa, libtinycompress, and liblog).
    • Adds sof-remote-server/sof_remote_server.rc to start vendor.sof_remote_server on boot when ro.debuggable=1.
  2. Standalone NDK / AOSP Cross-Compilation (make android & make android-push):

    • Adds android and android-push targets to sof-remote-server/Makefile, top-level Makefile, and sof-remote-server/CMakeLists.txt.
    • Auto-detects ANDROID_NDK_HOME or an AOSP checkout (AOSP_DIR) and embeds tinyalsa and tinycompress directly into build-android-<abi>/sof_remote_server so it only depends on NDK system libraries (libc.so, libm.so, libdl.so, liblog.so) when pushed via adb.
  3. Bionic & AOSP external/tinyalsa / external/tinycompress Adaptations:

    • audio_backend_alsa.c: Makes alsa-lib optional (HAVE_ALSA) and forwards alsa_* calls to tinyalsa_* when built without alsa-lib (-DNO_ALSA / __ANDROID__).
    • audio_backend_tinyalsa.c: Supports both upstream TinyALSA v2 (<tinyalsa/pcm.h>, pcm_writei/pcm_readi) and AOSP external/tinyalsa (<tinyalsa/asoundlib.h>, pcm_write/pcm_read).
    • audio_backend_compress.c: Uses C11 _Generic (compr_get_tstamp_compat) to support both AOSP (unsigned long *) and upstream (unsigned int *) compress_get_tstamp signatures.
    • sof_remote_server.c & dapm_inspector.c: Adds Android logcat logging, defaults g_tone_api to SOF_AUDIO_API_TINYALSA on Android, and adds /vendor/firmware and /d debugfs fallback paths.

Test Plan

  • Verified make android (x86_64-linux-android34 Bionic PIE binaries) and make all (native Linux x86_64 binaries).
  • Verified readelf -d on build-android-x86_64/sof_remote_server (NEEDED: liblog.so, libdl.so, libm.so, libc.so).

@lgirdwood lgirdwood left a comment

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.

lets make sure we update the readme with build instructions and support

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The boot service exposes unauthenticated root command execution when started, and unresolved Android build failures, SELinux startup requirements, and audio correctness defects remain.

6 open issues
What changed in this PR

Adds Android build and deployment support for the SOF remote telemetry server and CLI, adapting the existing Linux audio backends for Bionic and AOSP libraries.

Changes:

  • Adds Soong targets, an Android init service, and standalone cross-build and ADB deployment commands.
  • Adds compatibility handling for ALSA-free builds and differing TinyALSA/Tinycompress APIs.
  • Adds Android firmware/debugfs paths, startup logging, and quick-start documentation.
File Description
sof-remote-server/​sof_remote_server.rc Defines boot startup on debuggable Android builds.
sof-remote-server/​sof_remote_server.c Adds Android defaults, startup logging, and discovery paths.
sof-remote-server/​Makefile Adds Android cross-compilation and ADB deployment.
sof-remote-server/​dapm_inspector.c Adds Android firmware and debugfs fallbacks.
sof-remote-server/​CMakeLists.txt Enables Android server builds and conditional linking.
sof-remote-server/​audio_backend_tinyalsa.c Adapts PCM and mixer operations for AOSP TinyALSA.
sof-remote-server/​audio_backend_compress.c Handles differing timestamp function signatures.
sof-remote-server/​audio_backend_alsa.c Supports builds without ALSA by forwarding to TinyALSA.
sof-remote-server/​Android.bp Defines vendor server and CLI Soong targets.
README.md Documents Android build and deployment commands.
Makefile Exposes Android targets and excludes artifacts from RPM sources.
.gitignore Ignores Android build output directories.

Review effort: Balanced

set(TINYCOMPR_OBJ2 "${SOF_WORK_DIR}/tinycompress/src/lib/.libs/libtinycompress_la-compress_hw.o" CACHE FILEPATH "Path to tinycompress compress_hw.o")

if(ASOUND_LIB)
if(ASOUND_LIB OR ANDROID)
Comment on lines +76 to +77
ANDROID_CRTBEGIN ?= $(dir $(firstword $(wildcard $(AOSP_DIR)/out/soong/.intermediates/bionic/libc/crtbegin_dynamic/android_$(ANDROID_ABI)*/crtbegin_dynamic.o)))
ANDROID_CRTEND ?= $(dir $(firstword $(wildcard $(AOSP_DIR)/out/soong/.intermediates/bionic/libc/crtend_android/android_$(ANDROID_ABI)*/crtend_android.o)))
Comment on lines +10 to +11
on property:sys.boot_completed=1 && property:ro.debuggable=1
start vendor.sof_remote_server
Comment on lines +44 to +46
#ifdef HAVE_TINYALSA_V2
case SOF_PCM_FMT_FLOAT_LE: return PCM_FORMAT_FLOAT_LE;
#endif
Comment on lines +91 to +92
(void)ctl;
return fallback_idx;
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
# Android init service for SOF Remote Telemetry & Debug Server

service vendor.sof_remote_server /vendor/bin/sof_remote_server -p 9998
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.

3 participants