XMOS XU316 HiFi USB Decoder ZeroCode Firmware Configuration Protocol
I. 💡 ZeroCode Firmware Functional Scope
- The firmware focuses exclusively on audio-related functions and does not handle buttons, indicators, or other functions unrelated to core functionality.
- Other user interaction features are managed by the MCU.
- MCU and XU316 communicate bidirectionally via UART for command and data exchange.
- The firmware communicates with the computer via HID.
II. XU316 and MCU Configuration Protocol
1. Low-Level Protocol
Based on UART (Universal Asynchronous Receiver/Transmitter) protocol
Terminology
Term | Description |
Baud Rate | 115200 bps |
Data Bits | 8 |
Parity | None |
Stop Bits | 1 |
Flow Control | None |
Field | Bytes | Description |
Header | 2 | Fixed as 0x55aa |
Version | 1 | Protocol version number |
Command | 1 | Indicates the frame's function |
Data Length | 2 | Length of subsequent data N |
Data | N | Specific data content |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
Notes All multi-byte data is transmitted in big-endian format. Examples in the protocol are in hexadecimal.
3. XU316 Startup Sequence and MCU Interaction Process
3.1 Power-on Startup and Startup Options Phase (Only runs during manual power-on startup)
Steps:
- XU316 startup sends a start command (command 0x00) to the MCU, including UAC1.0 VID/PID, UAC2.0 VID/PID, basic information CRC, and power-on configuration CRC.
- MCU receives the startup command, checks whether basic information and power-on configuration need to be updated, and sends the corresponding response to XU316. XU316 waits for MCU to respond to startup for up to 3 seconds.
- If no response is received within 300ms, XU316 resends the startup command up to 4 times. If no response is received after 4 attempts, it loads the default USB configuration and enumerates USB.
- MCU responds to the startup command to XU316, including startup options.
- XU316 parses the startup options.
Condition: Startup options include 0x01 (Update basic product information)
- XU316 requests to read basic product information, sends command 0x01
- MCU returns new basic product information to XU316.
- XU316 updates and saves the configuration.
3.3 Power-on Configuration Acquisition Phase (Only runs during manual power-on startup)
Condition: Startup options include 0x02 (Update power-on configuration) or data read from Flash is incomplete.
- XU316 requests to get power-on configuration. Sends command 0x02
- MCU returns new power-on configuration to XU316.
- XU316 updates and saves the configuration.
3.4 Loading Application Firmware Phase
Steps:
- XU316 gets the current mode, sends command 0x03.
- MCU returns the current mode to XU316.
- XU316 loads the corresponding mode based on the current mode.
APP Running Phase
Steps:
- XU316 gets the current user configuration (volume, etc.), command 0x04.
- MCU returns the current user configuration to XU316.
- XU316 initializes the APP and applies the current user configuration.
- XU316 sends a startup completion command to MCU, command 0x05.
- MCU returns a completion command response to XU316.
4. Command List
Command | Description |
0x00 | Start Startup |
0x01 | Read Product Information |
0x02 | Read Power-on Configuration Information |
0x03 | Get Current Audio Mode |
0x04 | Get Current User Configuration |
0x05 | Startup Completion Command |
0x20 | Report Application Status |
0x21 | Media Control |
0x22 | Set Playback Audio Stream Format and Type |
0x23 | Set Audio Mode |
0x24 | Send Playback Volume |
0x25 | Send Recording Volume |
0x01 | HID Start MCU OTA Upgrade Command |
0x02 | HID Send MCU Upgrade Data Packet |
0x03 | HID Send MCU Upgrade End Packet |
Notes:
- All commands must follow the basic frame format
- Some commands require confirmation response from the other party
- Certain commands can only be used under specific conditions (such as OTA-related commands)
- Command response timeout is typically 5 seconds
- Application commands should be sent only after XU316 startup commands are completed
5. Protocol Mechanism
5.1 Confirmation Mechanism
- All commands require a confirmation reply from the other party
- Default command timeout is 5 seconds, after which it's considered failed, unless otherwise specified
6. Business Protocol
6.1 Basic Function Commands
6.1.1 Start Startup (Command: 0x00)
XU316 Sends:
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x00 |
Data Length | 1 | 17 |
Data | 17 | B0 Restart Reason: 0x00 Power-on restart, 0x01 Mode switch restart, 0xFF Other reason restart |
| | B1-2 unsigned short VID (UAC1.0) |
| | B3-4 unsigned short PID (UAC1.0) |
| | B5-6 unsigned short VID (UAC2.0) |
| | B7-8 unsigned short PID (UAC2.0) |
| | B9-12 unsigned int Basic information 32bit CRC |
| | B13-16 unsigned int Power-on configuration 32bit CRC |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response Field Description
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x00 |
Data Length | 1 | 0x1 |
Data | 1 | B0 Startup options, see Data Field Description section |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x01 |
Data Length | 1 | 0x00 |
Data | 0 | |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x01 |
Data Length | 1 | 0x3C (60 bytes) |
Data | 60 | Basic product information, see Business Information section |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x02 |
Data Length | 1 | 0x00 |
Data | 0 | No data, indicating no additional information transmission |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x02 |
Data Length | 1 | 0x0E (14 bytes) |
Data | 14 | Power-on configuration information, see Business Information section |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.1.4 Get Current Audio Mode (Command: 0x03)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x03 |
Data Length | 1 | 0x00 |
Data | 0 | No data, indicating no additional information transmission |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x03 |
Data Length | 1 | 0x05 (5 bytes) |
Data | 5 | Audio mode, see Data Field section |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.1.5 Get Current User Configuration (Command: 0x04)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x04 |
Data Length | 1 | 0x00 |
Data | 0 | No data, indicating no additional information transmission |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x04 |
Data Length | 1 | 0x14 (20 bytes) |
Data | 14 | User configuration parameters, see Business Information section |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.1.6 Startup Completion Command (Command: 0x05)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x05 |
Data Length | 1 | 0x15 (21 bytes) |
Data | 15 | Startup status and application running parameters |
| | B0: 0 Startup successful, 1 Mode mismatch, other values Startup failed |
| | B1-BN: Application running parameters, see Business Information Description |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x05 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.2 Business Control and Query Commands (Can only be sent after startup is complete)
6.2.1 Report Application Status (Command: 0x20)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x20 |
Data Length | 1 | 0x14 (20 bytes) |
Data | 14 | Application running parameters, see Business Information Description |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x20 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x21 |
Data Length | 1 | 0x01 (1 byte) |
Data | 1 | Media control command, see media control field |
| | 0x00 Volume+ / Vol Up |
| | 0x01 Volume- / Vol Down |
| | 0x02 Play / PLAY |
| | 0x03 Next / NEXT |
| | 0x04 Previous / PREV |
| | 0x05 Fast Forward / FORWARD |
| | 0x06 Rewind / REWIND |
| | 0x07 Mute / MUTE |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
XU316 Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x01 |
Command | 1 | 0x21 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x22 |
Data Length | 1 | 0x02 (2 bytes) |
Data | 2 | Audio stream format and type, see Audio Stream Format and Type Field |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x01 |
Command | 1 | 0x22 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.2.4 Set Audio Mode (Command: 0x23)
MCU Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x23 |
Data Length | 1 | 0x05 (5 bytes) |
Data | 5 | Audio mode, see Audio Mode Field |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
XU316 Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x01 |
Command | 1 | 0x23 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.2.5 Send Playback Volume (Command: 0x24)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x24 |
Data Length | 1 | 0x02 (2 bytes) |
Data | 2 | Left channel: 0xFF Mute, 0-0dB -127: -127dB |
| | Right channel: 0xFF Mute, 0-0dB -127: -127dB |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x01 |
Command | 1 | 0x24 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.2.6 Send Recording Volume (Command: 0x25)
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x03 |
Command | 1 | 0x25 |
Data Length | 1 | 0x01 (1 byte) |
Data | 1 | 0xFF Mute, 0-0dB -127: -127dB |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0x55aa |
Version | 1 | 0x01 |
Command | 1 | 0x25 |
Data Length | 1 | 0x00 |
Data | 0 | No data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.3 MCU OTA Upgrade Commands (Pass-through Mode)
6.3.1 HID Start MCU OTA Upgrade Command
XU316 Sends: (HID Report ID1 Output Report 40 bytes)
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x01 |
Extended Bytes | 3 | FileSize |
FileSize | 1 | Length of data in the data field |
Data | 32 | Default 0 (this field is for possible extension data) |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x01 |
Data | 4 | |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.3.2 HID Send MCU Upgrade Data Packet
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x02 |
Extended Bytes | 3 | address: Indicates the address of the upgrade data (typically used to specify upgrade location or block) |
Data Length | 1 | Length of data in the data field |
Data | 32 | data |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x02 |
Data | 4 | |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
6.3.3 HID Send MCU Upgrade End Packet
XU316 Sends
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x03 |
Extended Bytes | 3 | Reserved (default 0) |
Data Length | 1 | Length of data in the data field |
Data | 32 | Reserved (default 0) |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
MCU Response
Field | Bytes | Description |
Header | 2 | 0xaa55 |
Control Byte | 1 | 0x03 |
Data | 4 | |
Checksum | 1 | Sum of all bytes from header, modulo 256 |
Field | Bytes | Description |
VID1 | 2 | USB Vendor ID (UAC1.0) |
PID1 | 2 | USB Product ID (UAC1.0) |
VID2 | 2 | USB Vendor ID (UAC2.0) |
PID2 | 2 | USB Product ID (UAC2.0) |
ManufactureName | 16 | USB Manufacture Name (string, max 16 bytes) |
ProductName | 16 | USB Product Name (string, max 16 bytes) |
SerialNumber | 16 | Product Serial Number (string, max 16 bytes) |
CRC | 4 | 32-bit CRC checksum calculated for all fields (VID1, PID1, VID2, PID2, ManufactureName, ProductName, SerialNumber) |
The MCU can determine whether to update the basic product information based on the CRC returned by the XU316.
Field | Bytes | Description |
Default Audio Mode | 5 | See Audio Mode Field Description |
Mute Time | 2 | 0-65535 (ms) |
Microphone Default Volume | 1 | See Microphone Volume Field Description |
DAC Left Channel Default Volume | 1 | See DAC Volume Field Description |
DAC Right Channel Default Volume | 1 | See DAC Volume Field Description |
CRC | 4 | 32-bit CRC checksum calculated for all fields (Default Audio Mode, Mute Time, Microphone Volume, DAC Left/Right Channel Volume) |
The MCU can determine whether to update the power-on configuration information based on the CRC returned by the XU316.
7.3 Application Running Parameters
Field | Bytes | Description |
Audio Mode | 5 | See Audio Mode Field Description |
Mute Time | 2 | 0-65535 (ms) |
Microphone Volume | 1 | See Microphone Volume Field Description |
DAC Left Channel Volume | 1 | See DAC Volume Field Description |
DAC Right Channel Volume | 1 | See DAC Volume Field Description |
CRC | 4 | 32-bit CRC checksum calculated for all fields (Audio Mode, Mute Time, Microphone Volume, DAC Left/Right Channel Volume) |
7.4 User Configuration Parameters
Field | Bytes | Description |
Audio Mode | 5 | See Audio Mode Field Description |
Mute Time | 2 | 0-65535 (ms) |
Microphone Volume | 1 | See Microphone Volume Field Description |
DAC Left Channel Volume | 1 | See DAC Volume Field Description |
DAC Right Channel Volume | 1 | See DAC Volume Field Description |
CRC | 4 | 32-bit CRC checksum calculated for all fields (Audio Mode, Mute Time, Microphone Volume, DAC Left/Right Channel Volume) |
8. Data Field Description
8.1 Restart Reason
Length | Description |
1 byte | 0x00 Power-on restart |
| 0x01 Mode switch restart |
| 0xFF Other reason restart |
8.2 Startup Options
Length | Description |
1 byte | 0x00 Use all default information |
| 0x01 Need to update basic product information |
| 0x02 Need to update power-on configuration information |
| 0x04 Need to update IO configuration information |
8.3 Audio Mode
Length | Function Bit | Description |
6 bytes | | |
BYTE 0 | Bit 7 | I2S Mode: 0: Master, 1: Slave |
| Bit 6 | Sync Mode: 0: Async, 1: Sync |
| Bit 5 | MIDI: 0: disable, 1: enable |
| Bit 4 | SPDIF in: 0: disable, 1: enable |
| Bit 3 | SPDIF out: 0: disable, 1: enable |
| Bit 2 | ADAT in: 0: disable, 1: enable |
| Bit 1 | ADAT out: 0: disable, 1: enable |
| Bit 0 | DSD out: 0: disable, 1: enable |
BYTE 1 | Bit 0-3 | AUDIO Sample Rate: |
| | 0: 44.1KHz, 1: 48KHz, 2: 88.2KHz, 3: 96KHz, |
| | 4: 176.4KHz, 5: 192KHz, 6: 352.8KHz, 7: 384KHz, |
| | 8: 705.6KHz, 9: 768KHz, 10: 1411.2KHz, 11: 1536KHz |
| Bit 4 | MQA: 0: disable, 1: enable |
| Bit 5 | Audio Class: 0: UAC 1.0, 1: USB UAC 2.0 |
| Bit 6-7 | AUDIO WIDTH: 0: 16bit, 1: 24bit, 2: 32bit |
BYTE 2-3 | Bit 0-5 | Input: 0: disable, x(>0): channel count |
| Bit 6-11 | Output: 0: disable, x(>0): channel count |
| Bit 12-15 | Other cfg |
BYTE 4 | | 0: USB MODE, 1: OPT MODE, 2: COAX MODE, 3: BT MODE, |
| | 4: HDMI ARC MODE, 5: WIFI MODE, 6: AIRPLAY MODE, 7: SPOTIFY MODE |
8.4 Microphone Volume
Length | Description |
1 byte | 0xFF Mute |
| 0x00-0xFE Defined by MCU and HID application |
8.5 DAC Volume
Length | Description |
1 byte | 0x00 Mute |
| 0x01-0xFF Defined by MCU and HID application |
8.6 Power-on Mode
Length | Description |
1 byte | 0x00 Default mode, uses power-on configuration parameters at startup |
| 0x01 Power-off memory mode, uses user configuration parameters from MCU at startup |
Length | Description |
1 byte | 0x00 Volume+/Vol Up |
| 0x01 Volume-/Vol Down |
| 0x02 Play/PLAY |
| 0x03 Next/NEXT |
| 0x04 Previous/PREV |
| 0x05 Fast Forward/FORWARD |
| 0x06 Rewind/REWIND |
| 0x07 Mute/MUTE |
Length | Description |
1 byte | 0x00 AUDIO_PCM_44100 |
| 0x01 AUDIO_PCM_48000 |
| 0x02 AUDIO_PCM_88200 |
| 0x03 AUDIO_PCM_96000 |
| 0x04 AUDIO_PCM_176400 |
| 0x05 AUDIO_PCM_192000 |
| 0x06 AUDIO_PCM_352800 |
| 0x07 AUDIO_PCM_384000 |
| 0x08 AUDIO_PCM_705600 |
| 0x09 AUDIO_PCM_768000 |
| 0x0A AUDIO_PCM_1441200 |
| 0x0B AUDIO_PCM_1536000 |
| 0x0C AUDIO_PCM_32000 |
| 0x0D AUDIO_PCM_64000 |
| 0x0E AUDIO_PCM_128000 |
| 0x0F AUDIO_PCM_256000 |
| 0x10 AUDIO_PCM_512000 |
| 0x11 AUDIO_DSD_64 |
| 0x12 AUDIO_DSD_128 |
| 0x13 AUDIO_DSD_256 |
| 0x14 AUDIO_DSD_512 |
| 0x15 AUDIO_DSD_1024 |
| 0x16 AUDIO_MQA_44100 |
| 0x17 AUDIO_MQA_88200 |
| 0x18 AUDIO_MQA_176400 |
| 0x19 AUDIO_MQA_352800 |
| 0x1A AUDIO_MQA_705600 |
| 0x1B AUDIO_MQA_1411200 |
| 0x1C AUDIO_MQA_2822400 |
| 0x1D AUDIO_MQA_5644800 |
| 0x1E AUDIO_MQA_48000 |
| 0x1F AUDIO_MQA_96000 |
| 0x20 AUDIO_MQA_192000 |
| 0x21 AUDIO_MQA_384000 |
| 0x22 AUDIO_MQA_768000 |
| 0x23 AUDIO_MQA_1536000 |
| 0x24 AUDIO_MQA_3072000 |
| 0x25 AUDIO_MQA_6144000 |
| 0x26 AUDIO_MQA_64000 |
| 0x27 AUDIO_MQA_128000 |
| 0x28 AUDIO_MQA_256000 |
| 0x29 AUDIO_MQA_512000 |
| 0x2A AUDIO_MQA_1024000 |
| 0x2B AUDIO_MQA_2048000 |
| 0x2C AUDIO_MQA_4096000 |
| 0x2D AUDIO_MQA_8192000 |
| 0xFF AUDIO_NO_USED |
Audio Type
Length | Description |
1 byte | 0x00 PCM |
| 0x01 Reserve |
| 0x02 MQA |
| 0x03 MQB |
| 0x04 MQA_Studio |
| 0x05 DSD |