I have the Jetson Orin devkit 64G and I was wondering if is there is any guidance on getting usb audio gadget to work. It appears that all other ubuntu packages for jetson like IGX have the g_audio module included with the kernel but not the Jetson l4t.
Not sure but it seems like the error is reported if the ko files are copied to the system from another system. Please try to enable the corresponding configs and rebuild kernel.
Yes I have tried using the guide and built everything but it doesn’t seem to build these modules and I have to explicitly build them. See below
Build and install:
cd $HOME
mkdir kernel_customization
cd kernel_customization
wget https://developer.nvidia.com/downloads/embedded/l4t/r36_release_v4.3/sources/public_sources.tbz2
tar -xvf public_sources.tbz2
cd Linux_for_Tegra/source/
tar xf kernel_src.tbz2
tar xf kernel_oot_modules_src.tbz2
tar xf nvidia_kernel_display_driver_source.tbz2
vi usb_audio_fragment.config
cat usb_audio_fragment.config
# usb_audio_fragment.config
# USB Audio dependencies
CONFIG_USB_SUPPORT=y
CONFIG_USB_GADGET=y
CONFIG_SND=y
CONFIG_USB_CONFIGFS=m
# USB Audio modules
CONFIG_USB_U_AUDIO=m
CONFIG_USB_F_UAC1=m
CONFIG_USB_F_UAC2=m
cd kernel/kernel-jammy-src
scripts/kconfig/merge_config.sh -m arch/arm64/configs/defconfig ../../usb_audio_fragment.config
Using arch/arm64/configs/defconfig as base
Merging ../../usb_audio_fragment.config
#
# merged configuration written to .config (needs make)
#
cp .config arch/arm64/configs/defconfig
grep -E '^(CONFIG_USB_F_UAC1|CONFIG_USB_F_UAC2|CONFIG_USB_U_AUDIO)' arch/arm64/configs/defconfig
CONFIG_USB_U_AUDIO=m
CONFIG_USB_F_UAC1=m
CONFIG_USB_F_UAC2=m
cd ../../
make -C kernel
...
================================================================================
Kernel Image: /home/jetson/kernel_customization/Linux_for_Tegra/source/kernel/kernel-jammy-src/arch/arm64/boot/Image
Kernel sources compiled successfully.
================================================================================
export INSTALL_MOD_PATH=/
sudo -E make install -C kernel
sudo cp kernel/kernel-jammy-src/arch/arm64/boot/Image /boot/Image
export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
make modules
...
make[1]: Leaving directory '/home/jetson/kernel_customization/Linux_for_Tegra/source/nvdisplay'
================================================================================
Display driver compiled successfully.
================================================================================
find . -name "*.ko" | grep -E "f_uac|u_audio"
# Looks like uac or audio modules were not built !
export INSTALL_MOD_PATH=/
sudo -E make modules_install
sudo nv-update-initrd
export KERNEL_HEADERS=$PWD/kernel/kernel-jammy-src
make dtbs
...
================================================================================
DTBs compiled successfully.
================================================================================
sudo cp kernel-devicetree/generic-dts/dtbs/* /boot/dtb
sudo systemctl reboot -i
After reboot:
vi create_usb_audio.sh
chmod +x create_usb_audio.sh
sudo ./create_usb_audio.sh
Checking and loading required modules...
Loading module: libcomposite
insmod /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/libcomposite.ko
Loading module: u_audio
modprobe: FATAL: Module u_audio not found in directory /lib/modules/5.15.148-tegra
Failed to load module: u_audio
Error: Failed to load essential module u_audio. Exiting.
# Looks like modules are not built, lets force creation
kernel_customization/Linux_for_Tegra/source/kernel/kernel-jammy-src
make ARCH=arm64 CONFIG_USB_F_UAC1=m CONFIG_USB_F_UAC2=m CONFIG_USB_U_AUDIO=m M=drivers/usb/gadget/function modules
CC [M] drivers/usb/gadget/function/u_audio.o
CC [M] drivers/usb/gadget/function/f_uac1.o
LD [M] drivers/usb/gadget/function/usb_f_uac1.o
CC [M] drivers/usb/gadget/function/f_uac2.o
LD [M] drivers/usb/gadget/function/usb_f_uac2.o
MODPOST drivers/usb/gadget/function/Module.symvers
CC [M] drivers/usb/gadget/function/u_ether.mod.o
LD [M] drivers/usb/gadget/function/u_ether.ko
CC [M] drivers/usb/gadget/function/u_serial.mod.o
LD [M] drivers/usb/gadget/function/u_serial.ko
CC [M] drivers/usb/gadget/function/usb_f_accessory.mod.o
LD [M] drivers/usb/gadget/function/usb_f_accessory.ko
CC [M] drivers/usb/gadget/function/usb_f_acm.mod.o
LD [M] drivers/usb/gadget/function/usb_f_acm.ko
CC [M] drivers/usb/gadget/function/usb_f_ecm.mod.o
LD [M] drivers/usb/gadget/function/usb_f_ecm.ko
CC [M] drivers/usb/gadget/function/usb_f_ecm_subset.mod.o
LD [M] drivers/usb/gadget/function/usb_f_ecm_subset.ko
CC [M] drivers/usb/gadget/function/usb_f_eem.mod.o
LD [M] drivers/usb/gadget/function/usb_f_eem.ko
CC [M] drivers/usb/gadget/function/usb_f_fs.mod.o
LD [M] drivers/usb/gadget/function/usb_f_fs.ko
CC [M] drivers/usb/gadget/function/usb_f_mass_storage.mod.o
LD [M] drivers/usb/gadget/function/usb_f_mass_storage.ko
CC [M] drivers/usb/gadget/function/usb_f_ncm.mod.o
LD [M] drivers/usb/gadget/function/usb_f_ncm.ko
CC [M] drivers/usb/gadget/function/usb_f_obex.mod.o
LD [M] drivers/usb/gadget/function/usb_f_obex.ko
CC [M] drivers/usb/gadget/function/usb_f_rndis.mod.o
LD [M] drivers/usb/gadget/function/usb_f_rndis.ko
CC [M] drivers/usb/gadget/function/usb_f_serial.mod.o
LD [M] drivers/usb/gadget/function/usb_f_serial.ko
CC [M] drivers/usb/gadget/function/u_audio.mod.o
LD [M] drivers/usb/gadget/function/u_audio.ko
CC [M] drivers/usb/gadget/function/usb_f_uac1.mod.o
LD [M] drivers/usb/gadget/function/usb_f_uac1.ko
CC [M] drivers/usb/gadget/function/usb_f_uac2.mod.o
LD [M] drivers/usb/gadget/function/usb_f_uac2.ko
# Great!, the modules are built, lets copy them
sudo cp -v drivers/usb/gadget/function/*.ko /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/ && sudo chmod 644 /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/*.ko && sudo depmod -a
'drivers/usb/gadget/function/u_audio.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/u_audio.ko'
'drivers/usb/gadget/function/u_ether.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/u_ether.ko'
'drivers/usb/gadget/function/usb_f_accessory.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_accessory.ko'
'drivers/usb/gadget/function/usb_f_acm.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_acm.ko'
'drivers/usb/gadget/function/usb_f_ecm.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_ecm.ko'
'drivers/usb/gadget/function/usb_f_ecm_subset.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_ecm_subset.ko'
'drivers/usb/gadget/function/usb_f_eem.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_eem.ko'
'drivers/usb/gadget/function/usb_f_fs.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_fs.ko'
'drivers/usb/gadget/function/usb_f_mass_storage.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_mass_storage.ko'
'drivers/usb/gadget/function/usb_f_ncm.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_ncm.ko'
'drivers/usb/gadget/function/usb_f_obex.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_obex.ko'
'drivers/usb/gadget/function/usb_f_rndis.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_rndis.ko'
'drivers/usb/gadget/function/usb_f_serial.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_serial.ko'
'drivers/usb/gadget/function/usb_f_uac1.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_uac1.ko'
'drivers/usb/gadget/function/usb_f_uac2.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_uac2.ko'
'drivers/usb/gadget/function/u_serial.ko' -> '/lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/u_serial.ko'
sudo depmod -a
Create gadget:
sudo ./create_usb_audio.sh create
Creating USB Audio Gadget...
Loading required modules...
Loading module: libcomposite
insmod /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/libcomposite.ko
Loading module: u_audio
insmod /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/u_audio.ko
Loading module: usb_f_uac1
insmod /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_uac1.ko
Loading module: usb_f_uac2
insmod /lib/modules/5.15.148-tegra/kernel/drivers/usb/gadget/function/usb_f_uac2.ko
Enabling gadget with UDC: 3550000.usb
./create_usb_audio.sh: line 153: echo: write error: No such device
Warning: Failed to enable gadget with UDC
Verifying final configuration:
libcomposite: Loaded successfully
u_audio: Loaded successfully
usb_f_uac1: Loaded successfully
usb_f_uac2: Loaded successfully
Checking USB device status...
Warning: USB device not found in system yet
sudo dmesg| tail
[ 16.934062] rtk_btusb: btusb_notify: hci0 evt 3
[ 16.983169] NET: Registered PF_ALG protocol family
[ 17.115688] NVRM rpcRmApiControl_dce: NVRM_RPC_DCE: Failed RM ctrl call cmd:0x731341 result 0xffff:
[ 17.143722] [drm] Initialized nvidia-drm 0.0.0 20160202 for 13800000.display on minor 1
[ 17.145700] nv_platform 13800000.display: [drm] Cannot find any crtc or sizes
[ 19.395358] ACK 04 d4
[ 19.396679] ACK 04 d4
[ 19.413641] IPv6: ADDRCONF(NETDEV_CHANGE): wlP1p1s0: link becomes ready
[ 19.772714] rfkill: input handler disabled
[ 146.683876] udc 3550000.usb: failed to start g1: -19
Error reproduced:
[ 146.683876] udc 3550000.usb: failed to start g1: -19
Script create_usb_audio.sh for reference:
#!/bin/bash
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Global variables
GADGET_NAME="g1"
CONFIGFS_ROOT="/sys/kernel/config"
GADGET_DIR="$CONFIGFS_ROOT/usb_gadget/$GADGET_NAME"
REQUIRED_MODULES=(
"libcomposite"
"u_audio"
"usb_f_uac1"
"usb_f_uac2"
)
# Function to check if configfs is mounted
check_configfs() {
if ! mount | grep -q "^configfs on $CONFIGFS_ROOT"; then
echo "Mounting configfs..."
mount -t configfs none "$CONFIGFS_ROOT"
if [ $? -ne 0 ]; then
echo "Error: Failed to mount configfs"
return 1
fi
fi
return 0
}
# Function to perform cleanup
cleanup() {
echo "Cleaning up USB gadget..."
if [ -d "$GADGET_DIR" ]; then
# Ensure we're in the gadget directory
cd "$GADGET_DIR" || exit 1
# Disable UDC first
if [ -f "UDC" ]; then
echo "" > UDC
fi
# Remove function link
rm -f configs/c.1/uac1.0 2>/dev/null
# Remove directories in reverse order
rm -rf functions/uac1.0 2>/dev/null
rm -rf configs/c.1/strings/0x409 2>/dev/null
rm -rf configs/c.1 2>/dev/null
rm -rf strings/0x409 2>/dev/null
# Return to parent and remove gadget directory
cd ..
rmdir "$GADGET_NAME" 2>/dev/null
fi
echo "Cleanup completed"
}
# Function to load module with verification
load_module() {
local module=$1
if ! lsmod | grep -q "^$module "; then
echo "Loading module: $module"
modprobe $module -v
sleep 1 # Give the module time to initialize
if ! lsmod | grep -q "^$module "; then
echo "Failed to load module: $module"
return 1
fi
else
echo "Module $module is already loaded"
fi
return 0
}
# Function to create gadget
create_gadget() {
echo "Creating USB Audio Gadget..."
# Check and mount configfs
if ! check_configfs; then
echo "Error: ConfigFS not available"
exit 1
fi
# Load required modules
echo "Loading required modules..."
for module in "${REQUIRED_MODULES[@]}"; do
if ! load_module $module; then
echo "Warning: Failed to load module $module"
# Continue anyway as some modules might be built into the kernel
fi
done
# Create gadget directory
mkdir -p "$GADGET_DIR" || exit 1
cd "$GADGET_DIR" || exit 1
# USB device configuration
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # Version 1.0.0
echo 0x0200 > bcdUSB # USB 2.0
# Device info
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "NVIDIA" > strings/0x409/manufacturer
echo "USB Audio Gadget" > strings/0x409/product
# Create configuration
mkdir -p configs/c.1/strings/0x409
echo "UAC1 Config" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
# Create UAC1 function with error checking
mkdir -p functions/uac1.0
if [ -d "functions/uac1.0" ]; then
# Try to set audio parameters with error checking
if [ -f "functions/uac1.0/sample_rate" ]; then
echo 48000 > functions/uac1.0/sample_rate
fi
if [ -f "functions/uac1.0/channels" ]; then
echo 2 > functions/uac1.0/channels
fi
if [ -f "functions/uac1.0/bits_per_sample" ]; then
echo 16 > functions/uac1.0/bits_per_sample
fi
else
echo "Warning: Failed to create UAC1 function directory"
fi
# Link function to configuration with error checking
ln -s functions/uac1.0 configs/c.1/ 2>/dev/null
if [ ! -L "configs/c.1/uac1.0" ]; then
echo "Warning: Failed to create function symlink"
fi
# Find and verify UDC
UDC=$(ls /sys/class/udc | head -n1)
if [ -z "$UDC" ]; then
echo "Error: No UDC available"
cleanup
exit 1
fi
# Enable the gadget with error checking
echo "Enabling gadget with UDC: $UDC"
echo "$UDC" > UDC
sleep 1
# Verify gadget is enabled
CURRENT_UDC=$(cat UDC)
if [ -z "$CURRENT_UDC" ]; then
echo "Warning: Failed to enable gadget with UDC"
else
echo "Gadget enabled successfully with UDC: $CURRENT_UDC"
fi
# Show final status
echo -e "\nVerifying final configuration:"
for module in "${REQUIRED_MODULES[@]}"; do
if lsmod | grep -q "^$module "; then
echo "$module: Loaded successfully"
else
echo "$module: Not loaded (might be built into kernel)"
fi
done
# Check if gadget appears in USB devices
echo -e "\nChecking USB device status..."
if lsusb | grep -q "1d6b:0104"; then
echo "USB device found in system"
else
echo "Warning: USB device not found in system yet"
fi
}
# Function to check status
check_status() {
echo "=== USB Audio Gadget Status ==="
echo -e "\n1. ConfigFS Mount Status:"
if mount | grep -q "^configfs on $CONFIGFS_ROOT"; then
echo "✓ ConfigFS is mounted"
else
echo "✗ ConfigFS is not mounted"
fi
echo -e "\n2. Gadget Status:"
if [ -d "$GADGET_DIR" ]; then
echo "✓ Gadget exists at $GADGET_DIR"
if [ -f "$GADGET_DIR/UDC" ]; then
UDC_STATUS=$(cat "$GADGET_DIR/UDC")
if [ -n "$UDC_STATUS" ]; then
echo "✓ Gadget is active on UDC: $UDC_STATUS"
else
echo "✗ Gadget is inactive (no UDC assigned)"
fi
fi
echo -e "\nGadget Configuration:"
if [ -f "$GADGET_DIR/idVendor" ]; then
echo "- Vendor ID: 0x$(cat $GADGET_DIR/idVendor)"
fi
if [ -f "$GADGET_DIR/idProduct" ]; then
echo "- Product ID: 0x$(cat $GADGET_DIR/idProduct)"
fi
echo -e "\nAudio Configuration:"
if [ -f "$GADGET_DIR/functions/uac1.0/sample_rate" ]; then
echo "- Sample Rate: $(cat $GADGET_DIR/functions/uac1.0/sample_rate) Hz"
fi
if [ -f "$GADGET_DIR/functions/uac1.0/channels" ]; then
echo "- Channels: $(cat $GADGET_DIR/functions/uac1.0/channels)"
fi
if [ -f "$GADGET_DIR/functions/uac1.0/bits_per_sample" ]; then
echo "- Bits per Sample: $(cat $GADGET_DIR/functions/uac1.0/bits_per_sample)"
fi
else
echo "✗ No gadget exists at $GADGET_DIR"
fi
echo -e "\n3. Required Modules Status:"
for module in "${REQUIRED_MODULES[@]}"; do
if lsmod | grep -q "^$module "; then
echo "✓ $module: Loaded"
else
echo "✗ $module: Not loaded"
fi
done
echo -e "\n4. USB Device Status:"
if lsusb | grep -q "1d6b:0104"; then
echo "✓ USB device found in system (1d6b:0104)"
echo -e "\nDevice in lsusb:"
lsusb | grep "1d6b:0104"
else
echo "✗ USB device not found in system"
fi
echo -e "\n5. System Audio Status:"
if command -v aplay >/dev/null; then
echo "ALSA Audio Devices:"
aplay -l
else
echo "aplay not available - can't check audio devices"
fi
}
# Show usage information
usage() {
echo "Usage: $0 [command]"
echo "Commands:"
echo " create - Create new USB audio gadget"
echo " cleanup - Remove existing USB audio gadget"
echo " recreate - Remove existing gadget and create new one"
echo " status - Show current gadget status"
exit 1
}
# Main script
case "$1" in
"create")
create_gadget
;;
"cleanup")
cleanup
;;
"recreate")
cleanup
create_gadget
;;
"status")
check_status
;;
*)
usage
;;
esac
make ARCH=arm64 defconfig
make ARCH=arm64 menuconfig # Selected the UAC1 and UAC2 (had to make the USB gadget a module)
make ARCH=arm64 savedefconfig
cp defconfig arch/arm64/configs/defconfig
cd ../../
make -C kernel
...
Above has built the correct modules without having to force it, I have followed rest of the instructions but even now I get the same error at the end:
[ 62.712439] udc 3550000.usb: failed to start g1: -19
Looks like there is number of similar topics that were closed without resolution
I’m really hoping we can resolve this @DaneLLL because this is quite expensive device and I need it specifically for USB audio which seem to be not working
Hi,
Since we don’t have much experience in the function, would see if other users can check and share experience.
Jetpack 6.2 is wit kernel 5.15 and Jetpack 5.1.5 is with kernel 5.10. And you may try to enable the same configs on K5.10, to check whether enabling the configs works on different kernel version.
Hi,
The error looks identical on K5.10 and K5.15. Would suggest add prints in the driver code to check why it returns failed to start g1: -19. May check what -19 means.
I’ve now also tried the ubuntu provided image which has the audio modules available in their image. There is a legacy audio module called g_audio which is handling creation of usb audio device without having to run bash scripts, just running modprobe g_audio should bring up a device and it should immediately be visible via connected usb-c cable on other device. This works on raspberry pi perfectly.
Hi,
Will check it with our team. It looks to be an additional function since it is not enabled in default upstream kernel. We don’t much experience in the function and need other users to share experience.
Thanks. There are other “gadget” functions enabled by default, but not this one. Someone had to make a decision to not include it, while it’s an industry standard. All Ubuntu images have the audio gadget included in the mainstream kernel, and so does Raspberry Pi. For some reason, this feature was skipped from tegra-xudc by the looks of it. Can you advise how I can claim a refund for this device based on this thread?
Hi,
If the developer kit is physically broken, you may ask for RMA. Please try like:
[playback]
// get index of the audio device:
$ aplay -l
(...skip)
card 2: M [Plantronics Blackwire C220 M], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
// run the command. hw:2,0 is card 2, device 0
$ aplay -Dhw:2,0 test_stereo_44100Hz_16bit_PCM.wav