Skip to content

Commit 6d0587a

Browse files
jsiverskogmmahadevan108
authored andcommitted
mcux-sdk-middleware-usb: update to sdk 2.14.0
this is taken from [email protected]:nxp-mcuxpresso/mcux-sdk-middleware-usb.git, tag MCUX_2.14.0. Signed-off-by: Jacob Siverskog <[email protected]>
1 parent 7fe7d86 commit 6d0587a

File tree

95 files changed

+29518
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+29518
-26
lines changed

mcux/middleware/mcux-sdk-middleware-usb/ChangeLogKSDK.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
/*!
22
@page middleware_log Middleware Change Log
33

4-
@section USB USB stack for MCUXpresso SDK
5-
The current version of USB stack is 2.8.4.
4+
@section USB USB stack for MCUXpresso SDK
5+
The current version of USB stack is 2.9.0.
6+
- 2.9.0
7+
- Improvement:
8+
- Change ROOT2 as enabled by default in device stack.
9+
- Implement independent frequency adjustment for speaker and recorder of composite audio unified demos.
10+
- Fix vulnerability for host stack. CVE number: CVE-2023-38749
11+
- Delete deprecated enet driver function for enet adapter.
612
- 2.8.4
713
- Improvement:
814
- Add the new netc adatper for the new netc driver.

mcux/middleware/mcux-sdk-middleware-usb/device/usb_device_dci.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ static usb_status_t USB_DeviceTransfer(usb_device_handle handle,
264264
uint32_t length)
265265
{
266266
usb_device_struct_t *deviceHandle = (usb_device_struct_t *)handle;
267-
usb_status_t status;
268-
uint8_t endpoint = endpointAddress & USB_ENDPOINT_NUMBER_MASK;
269-
uint8_t direction = (endpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) >>
267+
usb_status_t status = kStatus_USB_Error;
268+
uint8_t endpoint = endpointAddress & USB_ENDPOINT_NUMBER_MASK;
269+
uint8_t direction = (endpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) >>
270270
USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT;
271271
OSA_SR_ALLOC();
272272

@@ -277,11 +277,16 @@ static usb_status_t USB_DeviceTransfer(usb_device_handle handle,
277277

278278
if (NULL != deviceHandle->controllerInterface)
279279
{
280+
if (endpoint >= USB_DEVICE_CONFIG_ENDPOINTS)
281+
{
282+
return kStatus_USB_InvalidParameter;
283+
}
284+
OSA_ENTER_CRITICAL();
280285
if (0U != deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy)
281286
{
287+
OSA_EXIT_CRITICAL();
282288
return kStatus_USB_Busy;
283289
}
284-
OSA_ENTER_CRITICAL();
285290
deviceHandle->epCallback[(uint8_t)((uint32_t)endpoint << 1U) | direction].isBusy = 1U;
286291
OSA_EXIT_CRITICAL();
287292
if (0U != (endpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK))
@@ -342,11 +347,11 @@ static usb_status_t USB_DeviceTransfer(usb_device_handle handle,
342347
static usb_status_t USB_DeviceControl(usb_device_handle handle, usb_device_control_type_t type, void *param)
343348
{
344349
usb_device_struct_t *deviceHandle = (usb_device_struct_t *)handle;
345-
usb_status_t status;
350+
usb_status_t status = kStatus_USB_InvalidHandle;
346351

347352
if (NULL == deviceHandle)
348353
{
349-
return kStatus_USB_InvalidHandle;
354+
return status;
350355
}
351356

352357
if (NULL != deviceHandle->controllerInterface)
@@ -377,7 +382,7 @@ static usb_status_t USB_DeviceResetNotification(usb_device_struct_t *handle,
377382
{
378383
uint32_t count;
379384
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
380-
usb_status_t status;
385+
usb_status_t status = kStatus_USB_Error;
381386
#endif
382387

383388
#if (defined(USB_DEVICE_CONFIG_USE_TASK) && (USB_DEVICE_CONFIG_USE_TASK > 0U))

mcux/middleware/mcux-sdk-middleware-usb/device/usb_device_ehci.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static usb_status_t USB_DeviceEhciEndpointUnstall(usb_device_ehci_state_struct_t
452452
static void USB_DeviceEhciFillSetupBuffer(usb_device_ehci_state_struct_t *ehciState, uint8_t ep)
453453
{
454454
uint8_t waitingSafelyAccess = 1U;
455-
uint8_t index = (ep * 2U) | USB_OUT;
455+
uint8_t index = ((uint8_t)((uint32_t)ep << 1U)) | USB_OUT;
456456

457457
/* Write 1U to clear corresponding bit in EPSETUPSR. */
458458
ehciState->registerBase->EPSETUPSR = 1UL << ep;
@@ -1269,7 +1269,7 @@ static usb_hsdcd_status_t USB_DeviceEhciIsrHSDCDCallback(void *handle, uint32_t
12691269
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
12701270
if (kStatus_USB_Success != USB_DeviceNotificationTrigger(ehciState->deviceHandle, &message))
12711271
{
1272-
return kStatus_USB_Error;
1272+
return kStatus_hsdcd_Error;
12731273
}
12741274
#else
12751275
(void)USB_DeviceNotificationTrigger(ehciState->deviceHandle, &message);
@@ -1447,7 +1447,7 @@ usb_status_t USB_DeviceEhciInit(uint8_t controllerId,
14471447
message.code = (uint8_t)kUSB_DeviceNotifyAttach;
14481448
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
14491449
if ((kStatus_USB_Success != USB_DeviceNotificationTrigger(ehciState->deviceHandle, &message)) ||
1450-
(kStatus_USB_Success != USB_HSDCD_Control(ehciState->dcdHandle, kUSB_DeviceHSDcdRun, NULL)))
1450+
(kStatus_hsdcd_Success != USB_HSDCD_Control(ehciState->dcdHandle, kUSB_DeviceHSDcdRun, NULL)))
14511451
{
14521452
return kStatus_USB_Error;
14531453
}
@@ -1526,7 +1526,7 @@ usb_status_t USB_DeviceEhciDeinit(usb_device_controller_handle ehciHandle)
15261526
#if (defined(USB_DEVICE_CONFIG_CHARGER_DETECT) && (USB_DEVICE_CONFIG_CHARGER_DETECT > 0U)) && \
15271527
(defined(FSL_FEATURE_SOC_USBHSDCD_COUNT) && (FSL_FEATURE_SOC_USBHSDCD_COUNT > 0U))
15281528
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
1529-
if (kStatus_USB_Success != USB_HSDCD_Deinit(ehciState->dcdHandle))
1529+
if (kStatus_hsdcd_Success != USB_HSDCD_Deinit(ehciState->dcdHandle))
15301530
{
15311531
return kStatus_USB_Error;
15321532
}
@@ -2177,19 +2177,23 @@ void USB_DeviceEhciIsrFunction(void *deviceHandle)
21772177
#if (defined(FSL_FEATURE_SOC_USBHSDCD_COUNT) && (FSL_FEATURE_SOC_USBHSDCD_COUNT > 0U)) && \
21782178
(defined(USB_DEVICE_CONFIG_CHARGER_DETECT) && (USB_DEVICE_CONFIG_CHARGER_DETECT > 0U))
21792179
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
2180-
if (kStatus_USB_Success != USB_HSDCD_Control(ehciState->dcdHandle, kUSB_DeviceHSDcdRun, NULL))
2180+
if (kStatus_hsdcd_Success != USB_HSDCD_Control(ehciState->dcdHandle, kUSB_DeviceHSDcdRun, NULL))
21812181
{
2182-
return kStatus_USB_Error;
2182+
#if (defined(DEVICE_ECHO) && (DEVICE_ECHO > 0U))
2183+
usb_echo("hsdcd run error\n");
2184+
#endif
21832185
}
21842186
#else
21852187
(void)USB_HSDCD_Control(ehciState->dcdHandle, kUSB_DeviceHSDcdRun, NULL);
21862188
#endif
21872189
#elif (defined(USB_DEVICE_CONFIG_CHARGER_DETECT) && (USB_DEVICE_CONFIG_CHARGER_DETECT > 0U)) && \
21882190
(defined(FSL_FEATURE_SOC_USB_ANALOG_COUNT) && (FSL_FEATURE_SOC_USB_ANALOG_COUNT > 0U))
21892191
#if (defined(USB_DEVICE_CONFIG_RETURN_VALUE_CHECK) && (USB_DEVICE_CONFIG_RETURN_VALUE_CHECK > 0U))
2190-
if (kStatus_USB_Success != USB_PHYDCD_Control(ehciState->dcdHandle, kUSB_DevicePHYDcdRun, NULL))
2192+
if (kStatus_phydcd_Error != USB_PHYDCD_Control(ehciState->dcdHandle, kUSB_DevicePHYDcdRun, NULL))
21912193
{
2192-
return kStatus_USB_Error;
2194+
#if (defined(DEVICE_ECHO) && (DEVICE_ECHO > 0U))
2195+
usb_echo("phydcd run error\n");
2196+
#endif
21932197
}
21942198
#else
21952199
(void)USB_PHYDCD_Control(ehciState->dcdHandle, kUSB_DevicePHYDcdRun, NULL);

mcux/middleware/mcux-sdk-middleware-usb/device/usb_device_khci.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,9 @@ usb_status_t USB_DeviceKhciCancel(usb_device_controller_handle khciHandle, uint8
14581458
usb_status_t USB_DeviceKhciControl(usb_device_controller_handle khciHandle, usb_device_control_type_t type, void *param)
14591459
{
14601460
usb_device_khci_state_struct_t *khciState = (usb_device_khci_state_struct_t *)khciHandle;
1461+
#if defined(USB_DEVICE_CONFIG_GET_SOF_COUNT) && (USB_DEVICE_CONFIG_GET_SOF_COUNT > 0U)
1462+
uint32_t *temp32;
1463+
#endif
14611464
uint16_t *temp16;
14621465
uint8_t *temp8;
14631466
uint8_t count;
@@ -1640,7 +1643,15 @@ usb_status_t USB_DeviceKhciControl(usb_device_controller_handle khciHandle, usb_
16401643
status = kStatus_USB_Success;
16411644
break;
16421645
#endif
1643-
1646+
#if defined(USB_DEVICE_CONFIG_GET_SOF_COUNT) && (USB_DEVICE_CONFIG_GET_SOF_COUNT > 0U)
1647+
case kUSB_DeviceControlGetCurrentFrameCount:
1648+
if (NULL != param)
1649+
{
1650+
temp32 = (uint32_t *)param;
1651+
*temp32 = (uint32_t)((khciState->registerBase->FRMNUMH << 8U) | (khciState->registerBase->FRMNUML));
1652+
}
1653+
break;
1654+
#endif
16441655
default:
16451656
/*no action*/
16461657
break;

mcux/middleware/mcux-sdk-middleware-usb/device/usb_device_lpcip3511.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,13 +2299,11 @@ usb_status_t USB_DeviceLpc3511IpControl(usb_device_controller_handle controllerH
22992299
case kUSB_DeviceControlRun:
23002300
lpc3511IpState->registerBase->DEVCMDSTAT |= (USB_LPC3511IP_DEVCMDSTAT_DCON_MASK);
23012301
lpc3511IpState->registerBase->DEVCMDSTAT &= ~(USB_LPC3511IP_DEVCMDSTAT_FORCE_NEEDCLK_MASK);
2302-
error = kStatus_USB_Success;
23032302
break;
23042303

23052304
case kUSB_DeviceControlStop:
23062305
lpc3511IpState->registerBase->DEVCMDSTAT |= USB_LPC3511IP_DEVCMDSTAT_FORCE_NEEDCLK_MASK;
23072306
lpc3511IpState->registerBase->DEVCMDSTAT &= (~USB_LPC3511IP_DEVCMDSTAT_DCON_MASK);
2308-
error = kStatus_USB_Success;
23092307
break;
23102308

23112309
case kUSB_DeviceControlEndpointInit:

mcux/middleware/mcux-sdk-middleware-usb/host/usb_host_devices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ static usb_status_t USB_HostProcessCallback(usb_host_device_instance_t *deviceIn
447447
temp = (void *)&deviceInstance->enumBuffer[0];
448448
configureDesc = (usb_descriptor_configuration_t *)temp;
449449

450+
/* clear the potential configuration information that is got for the previous configuration */
451+
(void)memset(&deviceInstance->configuration, 0, sizeof(deviceInstance->configuration));
450452
deviceInstance->configurationLen = USB_SHORT_FROM_LITTLE_ENDIAN_ADDRESS(configureDesc->wTotalLength);
451453
if (deviceInstance->configurationDesc != NULL)
452454
{

mcux/middleware/mcux-sdk-middleware-usb/host/usb_host_ehci.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,12 @@ static usb_status_t USB_HostEhciQhQtdListInit(usb_host_ehci_instance_t *ehciInst
21872187
dataAddress = *entryPointer; /* dataAddress variable means entry value here */
21882188
while ((0U != dataAddress) && (0U == (dataAddress & EHCI_HOST_T_INVALID_VALUE)))
21892189
{
2190+
#if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET > 0U))
2191+
entryPointer = (volatile uint32_t *)USB_HOST_MEMORY_DMA_2_CPU(dataAddress);
2192+
#else
21902193
entryPointer = (volatile uint32_t *)dataAddress;
2191-
dataAddress = *entryPointer;
2194+
#endif
2195+
dataAddress = *entryPointer;
21922196
}
21932197
#if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET > 0U))
21942198
*entryPointer = (uint32_t)USB_HOST_MEMORY_CPU_2_DMA(BaseQtdPointer);
@@ -2678,6 +2682,7 @@ static void USB_HostEhciLinkSitd(usb_host_ehci_instance_t *ehciInstance,
26782682
uint32_t frameInterval;
26792683
uint32_t shouldLinkFrame;
26802684
uint32_t currentFrame;
2685+
uint8_t sitdPointerIndex = 0U;
26812686
#if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET > 0U))
26822687
uint32_t convert_addr = 0U;
26832688
#endif
@@ -2766,11 +2771,12 @@ static void USB_HostEhciLinkSitd(usb_host_ehci_instance_t *ehciInstance,
27662771
#else
27672772
((uint32_t *)temp)[shouldLinkFrame] = ((uint32_t)sitdPointer | EHCI_HOST_POINTER_TYPE_SITD);
27682773
#endif
2769-
if (sitdPointer->nextSitdIndex == 0xFFU) /* 0xFF is invalid value */
2774+
sitdPointerIndex = sitdPointer->nextSitdIndex;
2775+
if (sitdPointerIndex == 0xFFU) /* 0xFF is invalid value */
27702776
{
27712777
break;
27722778
}
2773-
sitdPointer = &(ehciInstance->ehciSitdIndexBase[sitdPointer->nextSitdIndex]); /* next sitd */
2779+
sitdPointer = &(ehciInstance->ehciSitdIndexBase[sitdPointerIndex]); /* next sitd */
27742780

27752781
shouldLinkFrame += frameInterval;
27762782
currentFrame += frameInterval;
@@ -4643,8 +4649,13 @@ usb_status_t USB_HostEhciCreate(uint8_t controllerId,
46434649
ehciInstance->shedFirstQh->currentQtdPointer = EHCI_HOST_T_INVALID_VALUE;
46444650
ehciInstance->shedFirstQh->nextQtdPointer = EHCI_HOST_T_INVALID_VALUE;
46454651
ehciInstance->shedFirstQh->alternateNextQtdPointer = EHCI_HOST_T_INVALID_VALUE;
4652+
#if (defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET > 0U))
4653+
ehciInstance->shedFirstQh->horizontalLinkPointer =
4654+
(uint32_t)USB_HOST_MEMORY_CPU_2_DMA(((uint32_t)(ehciInstance->shedFirstQh) | EHCI_HOST_POINTER_TYPE_QH));
4655+
#else
46464656
ehciInstance->shedFirstQh->horizontalLinkPointer =
46474657
(uint32_t)((uint32_t)(ehciInstance->shedFirstQh) | EHCI_HOST_POINTER_TYPE_QH);
4658+
#endif
46484659

46494660
/* initialize periodic list */
46504661
temp = (void *)ehciInstance->ehciFrameList;

mcux/middleware/mcux-sdk-middleware-usb/include/usb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
/*! @brief Defines USB stack major version */
2828
#define USB_STACK_VERSION_MAJOR (2UL)
2929
/*! @brief Defines USB stack minor version */
30-
#define USB_STACK_VERSION_MINOR (8UL)
30+
#define USB_STACK_VERSION_MINOR (9UL)
3131
/*! @brief Defines USB stack bugfix version */
32-
#define USB_STACK_VERSION_BUGFIX (4U)
32+
#define USB_STACK_VERSION_BUGFIX (0U)
3333

3434
/*! @brief USB stack version definition */
3535
#define USB_MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))

0 commit comments

Comments
 (0)