Skip to content

Unclear how to use CONFIG_USB_DEVICE_UAC_AS_PART (AEGHB-1067) #505

@JVKran

Description

@JVKran

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Hi there,

I think that I would have to do the following things in order to use the usb_device_uac component in a project that's already using TinyUSB.

  1. Set CONFIG_USB_DEVICE_UAC_AS_PART=y.
  2. Configure other Kconfig items such as CONFIG_UAC_SPEAKER_CHANNEL_NUM.
  3. Define a custom tusb_config.h and include "uac_descriptors.h" and "tusb_config_uac.h".
  4. Link it with this CMake.
# Determine whether tinyusb is fetched from component registry or from local path
idf_build_get_property(build_components BUILD_COMPONENTS)
if(tinyusb IN_LIST build_components)
    set(tinyusb_name tinyusb) # Local component
else()
set(tinyusb_name espressif__tinyusb) # Managed component
endif()

idf_component_get_property(tusb_lib ${tinyusb_name} COMPONENT_LIB)
target_include_directories(${tusb_lib} PUBLIC "${PROJECT_DIR}/main/tusb" "${UAC_PATH}/tusb_uac")
target_sources(${tusb_lib} PUBLIC "${PROJECT_DIR}/main/tusb/usb_descriptors.c")

cmake_policy(SET CMP0079 NEW)
target_link_libraries(${tusb_lib} PRIVATE ${COMPONENT_LIB})
  1. Increase CONFIG_TOTAL_LEN with CFG_TUD_AUDIO * TUD_AUDIO_DEVICE_DESC_LEN.
  2. Create ITF_NUM's and EP_NUM's.
enum {
  EPNUM_MSC_OUT = 0x01,
  EPNUM_MSC_IN,
  EPNUM_AUDIO_OUT,
  EPNUM_AUDIO_FB,
  EPNUM_AUDIO_IN,
}

enum {
  ITF_NUM_MSC = 0,
  ITF_NUM_AUDIO_CONTROL,
  ITF_NUM_AUDIO_STREAMING_SPK,
  ITF_NUM_AUDIO_STREAMING_MIC,
  ITF_NUM_TOTAL
};

#define CONFIG_TOTAL_LEN    (TUD_CONFIG_DESC_LEN + TUD_MSC_DESC_LEN + CFG_TUD_AUDIO * TUD_AUDIO_DEVICE_DESC_LEN)

uint8_t const desc_fs_configuration[] = {
    TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
    TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 0, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
    TUD_AUDIO_DESCRIPTOR(ITF_NUM_AUDIO_CONTROL, 6, EPNUM_AUDIO_OUT, (0x80 | EPNUM_AUDIO_IN), (0x80 | EPNUM_AUDIO_FB)),
};
  1. Initialize in the main.
tinyusb_msc_storage_init_sdmmc
tinyusb_msc_storage_mount
tinyusb_driver_install
tusb_cdc_acm_init
uac_device_config_t config = {
        .skip_tinyusb_init = true,
        .output_cb = uac_device_output_cb,
        .cb_ctx = NULL,
        .spk_itf_num = ITF_NUM_AUDIO_STREAMING_SPK,
    };
    uac_device_init(&config);

The problem

However, I keep getting this output. Without the audio endpoint, it works fine!

process_set_config 1064: ASSERT FAILED
process_control_request 804: ASSERT FAILED
usbd_control_xfer_cb 161: ASSERT FAILED
process_set_config 1064: ASSERT FAILED
process_control_request 804: ASSERT FAILED
usbd_control_xfer_cb 161: ASSERT FAILED
I (00:00:06.767) battery: VBAT = 4124mV, CHRG-STAT = 0.
I (00:00:06.768) main: VBAT = 4124mV, CHRG-STAT = 0.
I (00:00:06.768) battery: VBAT = 4124mV, CHRG-STAT = 0.
I (00:00:06.771) main: VBAT = 4124mV, CHRG-STAT = 0.
process_set_config 1064: ASSERT FAILED
process_control_request 804: ASSERT FAILED

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions