AnsweredAssumed Answered

USB Audio class driver failing to submit IRP (INVALID_ARG error code).

Question asked by abodhe on Jan 19, 2018

I am working on proprietary USB Mic software development and we are using nucleus USB device drivers for Audio class.

I am trying to record the audio samples from the proprietary USB mic using device driver provided by nucleus.


To record audio samples I am following below mention steps,


  1. Open the device using DVC_Dev_ID_Open (dev_id , AUDIO_LABEL, 1, &handle).
  2. Read the device function settings (channel, device type, sample_size etc.)
  3. Read the device frequency settings (freq type, freq count, freq list)
  4. Open the record session (IOCTL : USBH_AUDIO_OPEN_RECORD_SESSION), I set the double buffer to false in Audio device settings structure.
  5. Attach the record callback (IOCTL : USBH_AUDIO_REGISTER_RECORD_CALLBACK)
  6. Then start the recording (IOCTL : USBH_AUDIO_RECORD_SOUND) with following settings,
    1. AudOpParam.buffer : 14688 byte buffer
    2. AudOpParam.loopback_buffer: NULL
    3. AudOpParam.samples: 1440 (5 packets)
    4. AudOpParam.max_samples: 14688
    5. AudOpParam.sampling_rate: 48000
    6. AudOpParam.event: 0
    7. AudOpParam.channels: 2 (STEREO)
    8. AudOpParam.handle: 0 (Not sure what supposed to be)
    9. AudOpParam.padding[0]: 0


After starting recording the samples, USB stack is calling attached callback but with status NU_USB_INVLD_ARG (-3804) and length (0), when I debug further more I found that, in function hwctrl_handle_iso_irp(file nu_usbh_hwctrl_imp.c) NU_USB_DEVICE_Get_Port_Number is returning NU_USB_INVALID_ARG when NU_AUDH_Record_Single_Buffer() is submitting device IRP (nu_usb_audio_imp.c) .


Please refer the below code,


NU_USB_IRP_Get_Pipe (irp, &pipe);

NU_USB_PIPE_Get_Device (pipe, &device);




status = NU_USB_DEVICE_Get_Parent (device, &parent);


if (status != NU_SUCCESS)

return status;


NU_USB_DEVICE_Get_Speed (parent, &speed);

device = parent;


while (speed != USB_SPEED_HIGH);


NU_USB_DEVICE_Get_Function_Addr (parent, &hub_addr);


status = NU_USB_DEVICE_Get_Port_Number (device, &port_num);



Since the do..while loop is not able to find the HIGH_SPEED device till HUB device so NU_USB_DEVICE_Get_Port_Number is returning NU_USB_INVLD_ARG(-3804) status.


Note : Mic device is FULL_SPEED device not a HIGH_SPEED device.


Call Stack:


NU_USB_DEVICE_Get_Port_Number() at nu_usb_device_ext.c:889 0x800352e8 

hwctrl_handle_iso_irp() at nu_usbh_hwctrl_imp.c:5,429 0x8002f7d8

USBH_HWCTRL_Tgt_Submit_Irp() at nu_usbh_hwctrl_ext.c:947 0x8002af5c         

DVC_Dev_Ioctl() at dvc_common.c:2,059 0x8000e9f4     

NU_USB_HW_Submit_IRP() at nu_usb_hw_ext.c:465 0x800f643c

NU_USB_Submit_IRP() at nu_usb_stack_ext.c:880 0x80035fb0   

NU_AUDH_Record_Single_Buffer() at nu_usbh_audio_imp.c:2,148 0x800475ac  

TCC_Task_Shell() at tcc_common.c:872 0x80006698