USB Standalone AzureRTOS STM32WBA
Hello,
As a lot of people here, i'm trying to implement USB in standalone mode (bare metal, no OS used).
- I'm using NUCLEO-STM32WBA65RI board.
- CubeDE 1.19
- CubeMX 6.15.0
still can't make it work. I'm looking for help. I checked a lot of forum posts, a lot of github pages.
I based myself on :
https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/dev/usbx/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_CDC_ACM_Standalone/USBX/App/app_usbx_device.c
and tried to implement the AzureRTOS USBX standalone version
Here is my Cube MX configuration :
Clock USB :

I only used X-CUBE-AZRTOS-WB and desactivated USBX :
Using buffer <10*1024 would rise a memory error flag in ux_device_stack_initialize() :
The rest is default configuration.

Then USB_OTG_HS : Device_Only and :

Then i generated the code,
I added :
if(MX_USBX_Device_Init() != HAL_OK)
{
for(;;);
}And inside of it :
/* USER CODE BEGIN MX_USBX_Device_Init1 */
USBX_APP_Device_Init();
/* USER CODE END MX_USBX_Device_Init1 */And inside of it :
/* USER CODE BEGIN USB_Device_Init_PreTreatment_1 */
/* Set Rx FIFO */
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);
/* Set Tx FIFO 0 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x10);
/* Set Tx FIFO 1 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x10);
/* Set Tx FIFO 2 */
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, 0x20);
/* USER CODE END USB_Device_Init_PreTreatment_1 */Inside of MX_USB_OTG_HS_PCD_Init() i added :
/* USER CODE BEGIN USB_OTG_HS_Init 1 */
memset(&hpcd_USB_OTG_HS, 0x0, sizeof(PCD_HandleTypeDef));
/* USER CODE END USB_OTG_HS_Init 1 */Inside of _ux_utility_time_get() i added :
/* USER CODE BEGIN _ux_utility_time_get */
time_tick = HAL_GetTick();
/* USER CODE END _ux_utility_time_get */ I also implemented the TX and RX function but my code is blocking before that.
Inside of MX_USB_OTG_HS_PCD_Init -> HAL_PCD_Init -> USB_CoreInit -> USB_CoreReset
do
{
count++;
if (count > HAL_USB_TIMEOUT)
{
return HAL_TIMEOUT;
}
} while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRSTDONE) == 0U);
Does anyone succeed to implement USBX with STM32WBA65 in bare metal ?
Thanks for your help,
Yvan

