Skip to content

PRIME4 Devices and Services

Carl Kittelberger edited this page Jul 25, 2026 · 2 revisions

PRIME 4 Devices and Services

Overview

The Denon PRIME 4 runs a real-time Linux kernel (6.6.119-az01-rt67) on ARMv7l Rockchip RK3288-C SoC. The system uses overlayfs for writable directories (/etc, /var, /srv) and systemd manages 24 enabled services.

Services

The following services run on boot:

avahi-daemon.service         mDNS / Bonjour
az01-script-runner.service   Remote command execution daemon
az01-usbsata-fixer.service   JMB583 USB SATA bridge fixer
az0x-info.service            Boot info logger
az0x-setup-hostname.service  Sets device hostname based on DT
bluetooth.service            BlueZ Bluetooth stack
connman.service              Connection manager
engine.service               DJ application (44 MB)
getty@[ttyS0].service        Console on UART (USB OTG)
iptables.service             Firewall (nftables)
networkd.service             Network daemon
resolved.service             mDNS resolver
ssh.service                  OpenSSH server
timesyncd.service            NTP time sync
touch-fw-update.service      Ilitek 2117 touchscreen firmware

Two services exit/failed:

az01-script-runner.service   (exit/failed) — runs once
az01-update.service          (exit/failed) — one-shot update check

Storage

Device Mount Point Size Type
/dev/mmcblk0p6 / (read-only rootfs) ~182 MB ext2 (overlay)
/dev/mmcblk0p7 /data (read-write) ~1 GB jfs
/dev/mmcblk1 /media/az01-internal (SD card) ~64 GB FAT/exFAT
/dev/sda1 /media/az01-ext-drive (USB) — exFAT

Rootfs Contents

The read-only rootfs contains:

  • /usr/Engine/Engine — DJ application (44 MB)
  • /usr/bin/az01-script-runner — Remote command execution daemon
  • /usr/bin/az01-ssh-login — SSH login wrapper
  • /usr/bin/bluemoon — Bluetooth L2CAP service
  • /usr/bin/az01-signed-fs — Signed filesystem tool
  • /usr/bin/az01-image — Firmware image tool
  • /usr/bin/az0x-hwctl — Hardware control CLI
  • /usr/bin/xmosdfu — Xmos USB DFU updater
  • /usr/lib/libaz01-prog.so.0 — Az01 firmware library
  • /usr/lib/libaz0x-info.so.0 — Az0x hardware info library
Device Mount Point Size Type
/dev/mmcblk0p6 / (read-only rootfs) ~182 MB ext2 (overlay)
/dev/mmcblk0p7 /data (read-write) ~1 GB jfs
/dev/mmcblk1 /media/az01-internal (SD card) ~64 GB FAT/exFAT
/dev/sda1 /media/az01-ext-drive (USB) — exFAT

az01-script-runner

Description

A remote command execution daemon that listens for commands over UDP and executes them via system().

Binary Details

  • Size: 5.5 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3
  • Stack Canary: Enabled
  • GLIBC version: 2.34

Network Protocol

Interface: UDP 65423

Command format:

recvfrom → buf[0x100]

if buf[0] == 0:
    // buf[0] = flag
    // buf[1..N] = command string (including null terminator)
    runCommand(buf)  // via system()
else:
    // command was longer than buffer, ignored
    fprintf(stderr, "Command received was longer than buffer - ignoring\n")

The protocol is simple: a single UDP datagram containing a command string followed by a null terminator. The first byte buf[0] is checked for non-zero to indicate truncation. The command is printed to stderr and executed via system().

Implementation

int az01ScriptRunnerMain(void) {
    int __fd = socket(AF_INET, SOCK_DGRAM, 0x11);
    if (__fd < 0) exitOnError("socket");

    // bind to UDP 65423 (port 0xff8f)
    sockaddr.sin_family = AF_INET;
    sockaddr.sin_port = htons(0xff8f); // 65423
    sockaddr.sin_addr.s_addr = INADDR_ANY;

    bind(__fd, &sockaddr, sizeof(sockaddr));

    while (1) {
        char buf[0x100];
        memset(buf, 0, 0x100);

        ssize_t n = recvfrom(__fd, buf, 0x100, 0, 0, 0);
        if (n < 0) exitOnError("recvfrom");

        if (buf[0] == '\0') {
            fprintf(stderr, buf);  // "Command received: ..."
            runCommand(buf);       // system()
        } else {
            perror("Command received was longer");
        }
    }
}

SSH Service

az01-script-runner is listed as a Service=console-only unit in the systemd service file. It provides a console service accessible from another PRIME 4 unit (or via SSH) to send commands to this unit.


bluemoon

Description

A Bluetooth L2CAP service that manages Bluetooth connections on the PRIME 4 for the internal firmware. It provides L2CAP (Logical Link Control and Adaptation Protocol) socket management.

Binary Details

  • Size: 74 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Functions: 220
  • Interpreter: /usr/lib/ld-linux-armhf.so.3

Network Protocol

Interface: Bluetooth RFCOMM/L2CAP

Socket creation:

int fd = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_RFCOMM);
// AF_BLUETOOTH = 0x1f
// BTPROTO_RFCOMM = 1

Implementation

The service manages Bluetooth connections:

bool main(int argc, char **argv) {
    if (argc > 0) {
        return bluemoon_service_loop(argc, argv);
    }
    return false;
}

The bluemoon_service_loop function manages multiple Bluetooth connections using an epoll loop with up to 128 connections (0x80).

Key globals:

  • DAT_00023048 = epoll file descriptor
  • &DAT_00023050[] = connection table (128 entries)
  • DAT_0002301c = firmware buffer
  • DAT_00023024 = firmware offset
  • DAT_00023028 = firmware size

Data Structures

Connection structure (128 entries):

struct bluemoon_connection {
    int fd;                // offset 0x00
    uint events;           // offset 0x04
    int callback_ptr;      // offset 0x08
    void *callback_arg;    // offset 0x0c
    bool active;           // offset 0x10 (byte)
};

Function Summary

Function Address Description
processEntry 0x00013bf0 ELF entry point, calls libc_start_main
load_bluemoon_firmware 0x00014418 Loads Bluemoon firmware image file
create_bluetooth_socket 0x000157c4 Creates RFCOMM/L2CAP socket
process_bluetooth_event 0x000158c8 Processes incoming Bluetooth event
parse_bluetooth_data 0x00015938 Parses received data
handle_pairing 0x00015960 Handles Bluetooth pairing
send_bluetooth_packet 0x00015a60 Sends packet to device
handle_connection 0x00015b00 Handles connection setup/teardown
main 0x00015d20 Entry point, saves argc/argv
bluemoon_service_loop 0x00016598 Saves argc/argv to global
bluemoon_epoll_ctl 0x0001664c Internal epoll_ctl (adds/removes fd)
bluemoon_epoll_add 0x00016b6c Registers file descriptors with epoll
bluemoon_process_events 0x00017a80 Processes events from epoll wait
bluemoon_is_connected 0x00017be8 Checks if connection is active

az01-ssh-login

Description

A shell script wrapper used by the OpenSSH server's AuthorizedKeysCommand to validate incoming SSH connections. It checks the device's hardware and serial number before granting shell access.

Implementation

#!/bin/sh

# --product checks device compatibility string from Device Tree
# --serial checks device serial number from u-boot env

while test $# != 0; do
    case "$1" in
        --product)
            shift
            # Grep device DT compatible strings from /sys/firmware/devicetree/base/compatible
            for i in $(grep . /sys/firmware/devicetree/base/compatible); do
                if test "$1" = "$i"; then
                    product_pass=$((product_pass + 1))
                fi
            done
            ;;
        --serial)
            shift
            test "serial#$1" = "$(fw_printenv 'serial#')" || denied
            ;;
        *)
            denied
            ;;
    esac
    shift
done

Validation Rules

The script validates:

  1. The SSH public key matches the device's DT compatible strings
  2. The SSH serial number matches the u-boot serial# environment variable
  3. If all checks pass, an interactive shell (/bin/sh -l) is launched

SSH Certificate-Based Authentication

The SSH server uses certificate-based authentication:

  • Each login request is validated through the SSH certificate system
  • The certificate-authority (CA) validates device compatibility and serial number
  • Once validated, the user gains full root shell access

az01-update

One-shot service that fetches and applies firmware updates. Verifies the SHA-256 hash of downloaded images before mounting and writing them.

CLI Usage

Command Description
az01-update --file <zip> Apply file-based update
az01-update --net Fetch and apply network update
az01-update --usb <path> Apply USB update
az01-update --erase-data Erase user data partition

Services

# az01_update.service
[Service]
Type=oneshot
ExecStart=/usr/bin/az01-update
# az01_update_check.service
[Service]
Type=oneshot
ExecStart=/usr/bin/az01-update --net

Functionality

  • Fetches and verifies OTA update signatures
  • Verifies SHA-256 hashes before applying updates
  • Mounts and writes rootfs partitions
  • Reboots after updates (or waits for manual reboot)

az0x-hwctl

Description

Hardware control CLI utility. Links to libaz0x-info.so.0 (Az0x hardware info library).

Binary Details

  • Size: 9.5 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3

Core APIs (from libaz0x-info.so.0)

Function Purpose
az0x_hwctl_new() Initialize hwctl handle
az0x_hwctl_fd() Get event fd for polling
az0x_hwctl_set_notification_cb() Set callback for hardware events
az0x_hwctl_handle_notifications() Process pending HW event notifications
az0x_hwctl_typec_get() Get USB Type-C port property value
az0x_hwctl_typec_set() Set USB Type-C port property (e.g. alt mode)
az0x_hwctl_typec_str() Convert Type-C property to human string

CLI Usage

az0x-hwctl [options] [<device> [<property> [<newvalue]]]
  • Supported devices: typec
  • Type-C properties include alternate mode, role, power direction
  • Watch mode via --notification to receive event callbacks
  • -h, --help flag for options

Supported Property Operations

# Read Type-C current state
az0x-hwctl typec role
az0x-hwctl typec mode

# Monitor for changes
az0x-hwctl --notification typec

# Listen for property change events
# e.g. "typec: mode changed: USB -> DP"

touch-fw-update

Description

Service that updates the Ilitek 2117 touchscreen controller firmware. The touch-fw-upd binary flashes the touchscreen firmware to the Ilitek 2117 I2C controller during boot, before the Engine app starts.

Purpose

Updates firmware for the 7-inch LCD display (1920x720) and 6-inch HDMI output via the Ilitek 2117 I2C touchscreen controller.


az01-usbsata-fixer

Description

Service that fixes the JMB583 USB-to-SATA bridge controller.

Purpose

Fixes issues with the JMicron JMB583 USB-to-SATA bridge controller used for internal storage. Runs at boot to ensure the bridge controller works correctly.


az01-setup-hostname

Description

Sets the device hostname based on the Device Tree.

Functionality

  • Reads device hostname from DT
  • Sets the system hostname to match

engine

Description

The DJ application (44 MB) that manages audio, output, and display.

Functionality

  • Manages dual Xmos USB audio interfaces (MIDI and 4-channel ALSA)
  • Manages I2S audio (disabled on this device)
  • Displays on 7-inch LCD display and 6-inch HDMI output
  • Touchscreen input via Ilitek 2117 I2C touchscreen

az01-bootloader-sig

Description

Bootloader signing and verification tool for the PRIME 4 ROM.

Binary Details

  • Size: 9.6 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3

Functionality

  • Verifies bootloader signature
  • Signs bootloader for OTA updates
  • Validates bootloader image integrity

az01-image

Description

Firmware image library and CLI tool for handling PRIME 4 firmware images. Links to libaz01-prog.so.0.

Binary Details

  • Size: 18 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3

Core APIs (from libaz01-prog.so.0)

Function Purpose
az01_open_image() Opens a firmware image file
az01_close_image() Closes a firmware image handle
az01_verify_image() Cryptographically verifies image signatures
az01_load_public_key_file() Loads RSA/EC public key for verification
az01_set_image_key_provider() Sets callback for runtime key loading
az01_image_description() Returns image metadata string
az01_image_version Image version (v2/v3)
az01_image_v2_ops v2 image operations handler (legacy)
az01_image_v3_ops v3 image operations handler (current)
az01_image_fdt_ops Flattened Device Tree operations

Image Iteration APIs

Function Purpose
az01_image_for_each_compatible Iterate compatible device strings
az01_image_for_each_dt_compatible Iterate DT compatible strings
az01_image_for_each_signature Iterate signatures in image
az01_image_for_each_partition Iterate partitions in image
az01_image_for_each_partition_compatible Iterate compatible strings per partition
az01_image_for_each_partition_hash Iterate partition hashes

Compression

Uses LZMA compression (lzma_code, lzma_end, lzma_stream_decoder from liblzma.so.5) for image content packaging.

CLI Usage

az01-image [options] <image>

Options include -f (force), -s (signature check), -t (type filter), --device <dev> (device compatible filter), and --partition <name>.

az01-signed-fs

Cryptographic signing and verification tool. Uses OpenSSL for SHA-256 signatures and libmount for mounting verified filesystems.

Binary Details

  • Size: 14 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3
  • Core APIs:
    • EVP_sha256, EVP_DigestVerify, EVP_DigestVerifyInit, EVP_MD_CTX_new, EVP_MD_CTX_free, EVP_PKEY_free, PEM_read_PUBKEY
    • mnt_new_context, mnt_context_mount, mnt_context_append_options, mnt_context_set_source, mnt_context_set_target

Functionality

  • Verifies signed filesystem images before mounting
  • Loads public keys via PEM_read_PUBKEY from external files
  • Handles v2 and v3 firmware formats
  • Validates SHA-256 signatures using OpenSSL EVP APIs
  • Mounts verified filesystems via libmount
  • Uses flock for file locking during signed filesystem operations

az0x-info / az01-info

Boot log service. Logs kernel version, device serial, and boot time info. Links to libaz0x-info.so.0. Binary at /usr/bin/az01-info.

xmosdfu

Description

Xmos USB DFU firmware updater. Communicates with Xmos USB audio interface chips via USB using libusb for firmware flashing over DFU (Device Firmware Upgrade) protocol.

Binary Details

  • Size: 18 KB
  • Type: ELF 32-bit LSB ARM EABI5 stripped
  • Interpreter: /usr/lib/ld-linux-armhf.so.3
  • Dependencies: libusb (libusb-1.0), POSIX time

USB Library Functions Used

Function Purpose
libusb_init / libusb_exit Initialize and cleanup libusb
libusb_get_device_list Enumerate USB devices
libusb_get_device_descriptor Get device descriptors
libusb_open / libusb_close Open/close device handle
libusb_claim_interface / libusb_release_interface Claim/release USB interface
libusb_control_transfer Send control transfers
libusb_hotplug_register_callback / libusb_hotplug_deregister_callback Hot-plug events
libusb_handle_events_timeout USB event polling

Functionality

  • Detects Xmos USB audio interface chips connected via USB
  • Sends DFU firmware upgrade commands via USB control transfers
  • Handles hot-plug events (device connect/disconnect)
  • Reads firmware files from disk and writes to Xmos device
  • Verifies flash integrity after upload

iptables / nftables

Description

Firewall service using nftables.

Rules

  • Allows SSH (port 22)
  • Allows DHCP (port 67/68)
  • Allows Bluetooth
  • Blocks unknown traffic

connman / networkd

Description

Connection manager and network daemon.

Functionality

  • Manages network connections (wired, wireless)
  • Provides DHCP client
  • Manages DNS resolution via systemd-resolved
  • Handles network interface configuration

avahi-daemon

Description

Avahi mDNS/DNS-SD daemon (Bonjour compatible).

Functionality

  • Advertises the PRIME 4 on the local network
  • Resolves mDNS names for other devices
  • Provides service discovery for the PRIME 4's own services

bluetooth

Description

BlueZ Bluetooth stack service.

Functionality

  • Manages Bluetooth radio
  • Provides Bluetooth API to applications
  • Supports Bluetooth HID, A2DP, AVRCP, SPP, and L2CAP profiles

timesyncd

Description

Network Time Protocol (NTP) time synchronization service.

Functionality

  • Synchronizes clock with NTP servers
  • Provides time to other services
  • Uses systemd-timesyncd

resolved

Description

systemd-resolved mDNS/DNS-SD resolver service.

Functionality

  • Resolves mDNS names (Bonjour)
  • Provides DNS caching
  • Provides DNS-over-TLS (DoT) support

getty@[ttyS0]

Description

Console service for the serial UART (ttyS0).

Functionality

  • Provides a login console on the UART
  • Used for debugging and development
  • Console is accessible via USB OTG (az01-setup-otg-console)

Clone this wiki locally