Error creating SAI1 and SAI2 using Peripherals tool

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error creating SAI1 and SAI2 using Peripherals tool

1,353 Views
mrecoskie
Contributor III

Hi,

Using MCUXpresso version 11.4 I am trying to create SAI1 and SAI2 for ISO audio streaming using the Peripherals tool.  Everything using the defaults.  After updating and compiling the code I receive the following error:

/Applications/MCUXpressoIDE_11.4.1_6260/ide/plugins/com.nxp.mcuxpresso.tools.macosx_11.4.0.202103011116/tools/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: ./source/generated/usb_device_composite.o: in function `USB_UpdateInterfaceSetting':

/Users/xyz/Documents/MCUXpressoIDE_11.4.1_6260/workspace/evkmimxrt1064_speaker_dev_audio_speaker_bm/evkmimxrt1064_mark_hello_world/Debug/../source/generated/usb_device_composite.c:857: undefined reference to `USB_DeviceInterface1AudioStreamingSetInterface'

My goal is to have a single USB Interface for multiple SAI.  Is using the 'Peripherals' tool the best way of accomplishing this?

Thanks.

Mark

 

Labels (1)
0 Kudos
11 Replies

1,319 Views
mrecoskie
Contributor III

Thanks Kerry.  

If you create 2 SAI through the 'Peripherals' Tool do you see the same error I receive?  

I receive no errors or warnings from the tool but I receive the compile error.  It seems this should exist for everyone.

 

0 Kudos

1,314 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie 

  Your first post error is related to the USB, not the SAI, so when you use two SAI, which detail error you have meets? In fact, When you configure the different SAI, it should no issues, maybe your configuration is wrong, you can post the screen of your  two SAI configuration and errors, I can help you to check it.

 

Best Regards,

Kerry

0 Kudos

1,304 Views
mrecoskie
Contributor III

Good point.  You are absolutely right.
The error is related to USB when configuring multiple ISO streaming endpoints for USB Audio.  Screenshots attached.

Screen Shot 2022-01-13 at 2.36.48 PM.png

Screen Shot 2022-01-13 at 2.36.35 PM.png

Screen Shot 2022-01-13 at 2.36.58 PM.png

Screen Shot 2022-01-13 at 2.38.52 PM.png

0 Kudos

1,298 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie ,

   Your last picture shows you lack the USB_DeviceInterface1AudioStreamingSetInterface, please check your code, whether you have that API  or not? After you modify the CFG configuration, you need to update the code. If the API already can be found, it should the related heard include issues, you can check your project path, whether you include the related path about your API file.

 

Wish it helps you!

Best Regards,

kerry

0 Kudos

1,293 Views
mrecoskie
Contributor III

Hi,

 

I have tried updating the code.  I was expecting the tool to provide the missing functions.  Is this not the case?

Mark

 

0 Kudos

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie ,

  Please upload your project, I want to check it.

 

Best Regards,

Kerry

0 Kudos

1,283 Views
mrecoskie
Contributor III

Attached is a quick project I created replicating the problem in the generated source code - usb_device_composite.c.  Thanks. 

0 Kudos

1,257 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie ,

   Sorry for my later reply!

   I find your code, usb_device_interface_0_audio_contol.c contains the USB_DeviceInterface4AudioStreamingSetInterface, 

So, I think you can copy this API, then set it for the interface1,2,3.

usb_status_t USB_DeviceInterface4AudioStreamingSetInterface(class_handle_t handle, uint8_t alternateSetting) {
    usb_status_t error = kStatus_USB_Success;
	
	/* if a supported alternated setting is used */
	if (alternateSetting <= USB_ALTERNATE_SETTING_1)
	{
		if (s_UsbDeviceComposite->currentInterfaceAlternateSetting[USB_INTERFACE_4_AUDIO_STREAMING_INDEX] == alternateSetting)
		{
			return error;
		}
        /* Data output alternate setting of the stream interface */
		if (USB_ALTERNATE_SETTING_1 == alternateSetting)
		{
			error = USB_DeviceAudioRecv(s_UsbDeviceComposite->interface0AudioControlHandle, 
										USB_AUDIO_SPEAKER_STREAM_ENDPOINT, &USB_Interface0AudioControlDataBuff[0],
										s_UsbDeviceAudioSpeaker->currentStreamOutMaxPacketSize);
			if (!feedbackValueUpdating)
			{
				*((uint32_t *)&usbAudioFeedBackBuffer[0]) = *((uint32_t *)&audioFeedBackBuffer[0]);
			}
            error |= USB_DeviceAudioSend(s_UsbDeviceComposite->interface0AudioControlHandle, 
								USB_AUDIO_SPEAKER_FEEDBACK_ENDPOINT, usbAudioFeedBackBuffer, 
								s_UsbDeviceAudioSpeaker->currentFeedbackMaxPacketSize);
		}
		else
		{
			error = USB_DeviceDeinitEndpoint(
				s_UsbDeviceComposite->deviceHandle,
				USB_AUDIO_SPEAKER_STREAM_ENDPOINT |
					(USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT));
		}
		/* usb host stops the speaker, so there is no need for feedback */
		if ((1U == s_UsbDeviceAudioSpeaker->startPlayFlag) &&
			(USB_ALTERNATE_SETTING_0 == alternateSetting))
		{
			s_UsbDeviceAudioSpeaker->stopFeedbackUpdate = 1U;
		}

		/* usb host start the speaker, discard the feedback for AUDIO_SPEAKER_FEEDBACK_DISCARD_COUNT
		 * times */
		if (USB_ALTERNATE_SETTING_1 == alternateSetting)
		{
			s_UsbDeviceAudioSpeaker->stopFeedbackUpdate   = 0U;
			s_UsbDeviceAudioSpeaker->feedbackDiscardFlag  = 1U;
			s_UsbDeviceAudioSpeaker->feedbackDiscardTimes = AUDIO_SPEAKER_FEEDBACK_DISCARD_COUNT;
		}
	} 
	else 
	{
		error = kStatus_USB_InvalidRequest;
	}
    return error;
}

I copy it, and use the related name in the usb_device_compoiste.c:

    case USB_INTERFACE_1_AUDIO_STEAMING1_INDEX:
        ret = USB_DeviceInterface1AudioSteaming1SetInterface(g_UsbDeviceComposite.interface0AudioControlHandle, alternateSetting);
        break;
    case USB_INTERFACE_2_AUDIO_STREAMING_INDEX:
        ret = USB_DeviceInterface2AudioStreamingSetInterface(g_UsbDeviceComposite.interface0AudioControlHandle, alternateSetting);
        break;
    case USB_INTERFACE_3_AUDIO_STREAMING_INDEX:
        ret = USB_DeviceInterface3AudioStreamingSetInterface(g_UsbDeviceComposite.interface0AudioControlHandle, alternateSetting);
        break;
    case USB_INTERFACE_4_AUDIO_STREAMING_INDEX:
        ret = USB_DeviceInterface4AudioStreamingSetInterface(g_UsbDeviceComposite.interface0AudioControlHandle, alternateSetting);
        break

Then build again, the issue is not happen, I think it is the CFG issues which didn't generate the related API.

You can try it on your side.

Best Regards,

Kerry

 

0 Kudos

1,344 Views
mrecoskie
Contributor III

Hi,

We are using the RT1064.  I have also configured USB via the 'Peripherals' tool.  

I am wondering if it's best to start by using the Perpherals tool or to build from a sample?  All samples I have looked at are for a single USB to SAI connection - not USB to all SAI1/SAI2/SAI3.

Thanks.

Mark

0 Kudos

1,330 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie 

   Unfortunately, I don't have that code, I just have the directly SAI code with CFG.

 https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/RT10xx-SAI-basic-and-SDCard-wave-file-play/ta-p/...

  To the USB, I think after you configure it, you can add the SAI code to the USB buffer, just refer to the SDK, I don't think the CFG can help you connect the SAI and the USB together, it still need the code to realize it, the CFG just helps you to initialize the SAI and the USB seperately.

 

Wish it helps you!

Best Regards,

Kerry

0 Kudos

1,347 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @mrecoskie 

  Do you want to use the RT106X UAC?

  If yes, I suggest you refer to the SDK code:

https://mcuxpresso.nxp.com/en/builder?hw=EVK-MIMXRT1060

 SDK_2_10_1_EVK-MIMXRT1060\boards\evkmimxrt1060\usb_examples\usb_device_audio_generator

 As you UAC need to use both SAI and USB, so you need to configure both the USB and SAI Peripherals.

 

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos