How to Build ALSA Applications#

Note

By default, the ALSA library headers are not packaged in the NVIDIA DRIVE SDK. To build ALSA applications, the following additional steps are needed.

ALSA Library Setup#

ARM64 Cross-Compilation Setup#

Where to run these steps: These steps are performed on the host development machine (not on the AGX device) for cross-compilation.

Docker Environment (Host):

# Add to your Dockerfile
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    tar

Step-by-step process for ARM64 cross-compilation (Host):

  1. Set environment variables and download latest ALSA library:

    HOST=aarch64-buildroot-linux-gnu
    TOOLCHAIN=/drive/toolchains/aarch64--glibc--bleeding-edge-2024.02-1/bin
    PREFIX=/drive/drive-linux/oss/asound/libasound2/usr
    cd /tmp
    TARBALL=$(curl -s https://www.alsa-project.org/files/pub/lib/ | grep -oE 'alsa-lib-[0-9]+\.[0-9]+\.[0-9]+\.tar\.bz2' | sort -V | tail -1)
    curl -sO "https://www.alsa-project.org/files/pub/lib/${TARBALL}"
    
  2. Extract and configure for ARM64 cross-compilation:

    tar xf "$TARBALL" && cd "${TARBALL%.tar.bz2}"
    ./configure --enable-shared --disable-static --with-pic \
      --host="$HOST" --prefix="$PREFIX" --libdir="$PREFIX/lib/aarch64-linux-gnu" \
      CC="$TOOLCHAIN/$HOST-gcc" CXX="$TOOLCHAIN/$HOST-g++"
    
  3. Compile and install:

    make -j"$(nproc)" && make install
    
  4. Verify installation:

    ls -la /drive/drive-linux/oss/asound/libasound2/usr/lib/
    ls -la /drive/drive-linux/oss/asound/libasound2/usr/include/alsa/
    
  5. Build your ALSA application:

    cd /drive/drive-linux/samples/nvavb/test_utils/crf
    make 2>&1 | tee build_log.txt