Question
sw4stm32 doesn't like the project generated by STMCubeMx v5.3
Specifically, for a STM32F723, with the HS USB PHY enabled, it's giving me an error in
HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t dma)
{
uint32_t USBx_BASE = (uint32_t)USBx;
uint32_t *pSrc = (uint32_t *)src;
uint32_t count32b, i;
if (dma == 0U)
{
count32b = ((uint32_t)len + 3U) / 4U;
for (i = 0U; i < count32b; i++)
{
USBx_DFIFO((uint32_t)ch_ep_num) = *((__packed uint32_t *)pSrc);
pSrc++;
}
}
return HAL_OK;
}... where it's the __packed that's causing the problem. The same thing is true for the USB_ReadPacket immediately below the above in stm32f7xx_ll_usb.c
I'm not sure what the effect of removing the __packed will be (presumably it's there for a reason!) but after freshly generating the project, a build produces:
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c: In function 'USB_WritePacket':
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:958:53: error: expected ')' before 'uint32_t'
USBx_DFIFO((uint32_t)ch_ep_num) = *((__packed uint32_t *)pSrc);
^~~~~~~~
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:958:64: error: expected ')' before 'pSrc'
USBx_DFIFO((uint32_t)ch_ep_num) = *((__packed uint32_t *)pSrc);
^~~~
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c: In function 'USB_ReadPacket':
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:987:16: error: expected ')' before 'uint32_t'
*(__packed uint32_t *)pDest = USBx_DFIFO(0U);
^~~~~~~~
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:987:5: warning: statement with no effect [-Wunused-value]
*(__packed uint32_t *)pDest = USBx_DFIFO(0U);
^~~~~~~~~~~~~~~~~~~
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:987:27: error: expected ';' before 'pDest'
*(__packed uint32_t *)pDest = USBx_DFIFO(0U);
^~~~~
../Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:980:12: warning: unused variable 'USBx_BASE' [-Wunused-variable]
uint32_t USBx_BASE = (uint32_t)USBx;
^~~~~~~~~
make: *** [Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.o] Error 1Removing the __packed attribute from both calls makes it compile cleanly.
