Sfoglia il codice sorgente

Merge pull request #411 from hathach/fix-cast-align-warning

enable -Wcast-align
Ha Thach 5 anni fa
parent
commit
76bf96bcb0

+ 3 - 0
examples/device/net_lwip_webserver/Makefile

@@ -6,6 +6,9 @@ CFLAGS += \
   -DTCP_WND=2*TCP_MSS \
   -DTCP_WND=2*TCP_MSS \
   -DHTTPD_USE_CUSTOM_FSDATA=0
   -DHTTPD_USE_CUSTOM_FSDATA=0
 
 
+# TODO rndis_reports.c and net_device cause cast algin warnings
+CFLAGS += -Wno-error=cast-align
+
 INC += \
 INC += \
   src \
   src \
   $(TOP)/hw \
   $(TOP)/hw \

+ 3 - 5
examples/make.mk

@@ -63,11 +63,9 @@ CFLAGS += \
 	-Wwrite-strings \
 	-Wwrite-strings \
 	-Wsign-compare \
 	-Wsign-compare \
 	-Wmissing-format-attribute \
 	-Wmissing-format-attribute \
-	-Wunreachable-code
-
-# This causes lots of warning with nrf5x build due to nrfx code
-# CFLAGS += -Wcast-align
-
+	-Wunreachable-code \
+	-Wcast-align
+	
 # Debugging/Optimization
 # Debugging/Optimization
 ifeq ($(DEBUG), 1)
 ifeq ($(DEBUG), 1)
   CFLAGS += -Og -ggdb
   CFLAGS += -Og -ggdb

+ 2 - 2
hw/bsp/adafruit_clue/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCONFIG_GPIO_AS_PINRESET
   -DCONFIG_GPIO_AS_PINRESET
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/arduino_nano33_ble/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCONFIG_GPIO_AS_PINRESET
   -DCONFIG_GPIO_AS_PINRESET
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/circuitplayground_bluefruit/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCONFIG_GPIO_AS_PINRESET
   -DCONFIG_GPIO_AS_PINRESET
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/feather_nrf52840_express/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCONFIG_GPIO_AS_PINRESET
   -DCONFIG_GPIO_AS_PINRESET
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/feather_nrf52840_sense/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCONFIG_GPIO_AS_PINRESET
   -DCONFIG_GPIO_AS_PINRESET
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 3 - 0
hw/bsp/feather_stm32f405/board.mk

@@ -9,6 +9,9 @@ CFLAGS += \
   -DSTM32F405xx \
   -DSTM32F405xx \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
 
 
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
+
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 
 

+ 2 - 2
hw/bsp/nrf52840_mdk_dongle/board.mk

@@ -8,8 +8,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 0 - 2
hw/bsp/nutiny_sdk_nuc505/board.mk

@@ -19,13 +19,11 @@ SRC_C += \
   hw/mcu/nuvoton/nuc505/StdDriver/src/i2s.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/i2s.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/pwm.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/pwm.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/rtc.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/rtc.c \
-  hw/mcu/nuvoton/nuc505/StdDriver/src/sd.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/spi.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/spi.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/spim.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/spim.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/sys.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/sys.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/timer.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/timer.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/uart.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/uart.c \
-  hw/mcu/nuvoton/nuc505/StdDriver/src/usbd.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/wdt.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/wdt.c \
   hw/mcu/nuvoton/nuc505/StdDriver/src/wwdt.c
   hw/mcu/nuvoton/nuc505/StdDriver/src/wwdt.c
 
 

+ 2 - 2
hw/bsp/pca10056/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/pca10059/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/pca10100/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCONFIG_GPIO_AS_PINRESET \
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/raytac_mdbt50q_rx/board.mk

@@ -8,8 +8,8 @@ CFLAGS += \
   -DNRF52840_XXAA \
   -DNRF52840_XXAA \
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
   -DCFG_TUSB_MCU=OPT_MCU_NRF5X
 
 
-# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
-CFLAGS += -Wno-error=undef -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 # due to tusb_hal_nrf_power_event
 # due to tusb_hal_nrf_power_event
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))
 GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion)))

+ 2 - 2
hw/bsp/stm32f070rbnucleo/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DCFG_EXAMPLE_MSC_READONLY \
   -DCFG_EXAMPLE_MSC_READONLY \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F0
   -DCFG_TUSB_MCU=OPT_MCU_STM32F0
 
 
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx

+ 2 - 2
hw/bsp/stm32f072disco/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DCFG_EXAMPLE_MSC_READONLY \
   -DCFG_EXAMPLE_MSC_READONLY \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F0
   -DCFG_TUSB_MCU=OPT_MCU_STM32F0
 
 
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=unused-parameter
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=unused-parameter -Wno-error=cast-align
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F0xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F0xx

+ 3 - 0
hw/bsp/stm32f407disco/board.mk

@@ -9,6 +9,9 @@ CFLAGS += \
   -DSTM32F407xx \
   -DSTM32F407xx \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
 
 
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
+
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 
 

+ 3 - 0
hw/bsp/stm32f411disco/board.mk

@@ -9,6 +9,9 @@ CFLAGS += \
   -DSTM32F411xE \
   -DSTM32F411xE \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
 
 
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
+
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 
 

+ 2 - 2
hw/bsp/stm32f412disco/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DSTM32F412Zx \
   -DSTM32F412Zx \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
   -DCFG_TUSB_MCU=OPT_MCU_STM32F4
 
 
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=maybe-uninitialized
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F4xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F4xx

+ 2 - 2
hw/bsp/stm32f746nucleo/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DSTM32F746xx \
   -DSTM32F746xx \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7
 
 
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=shadow
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align -Wno-error=shadow
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx

+ 2 - 2
hw/bsp/stm32f767nucleo/board.mk

@@ -9,8 +9,8 @@ CFLAGS += \
   -DSTM32F767xx \
   -DSTM32F767xx \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7
 
 
-# mcu driver cause following warnings
-CFLAGS += -Wno-error=shadow
+# suppress warning caused by vendor mcu driver
+CFLAGS += -Wno-error=cast-align -Wno-error=shadow
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F7xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F7xx

+ 0 - 1
hw/bsp/stm32h743nucleo/board.mk

@@ -10,7 +10,6 @@ CFLAGS += \
   -DCFG_TUSB_MCU=OPT_MCU_STM32H7
   -DCFG_TUSB_MCU=OPT_MCU_STM32H7
 
 
 # mcu driver cause following warnings
 # mcu driver cause following warnings
-CFLAGS += -Wno-error=maybe-uninitialized
 
 
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32H7xx_HAL_Driver
 ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32H7xx_HAL_Driver
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32H7xx
 ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32H7xx

+ 1 - 1
src/common/tusb_common.h

@@ -106,7 +106,7 @@ static inline uint16_t tu_max16 (uint16_t x, uint16_t y) { return (x > y) ? x :
 static inline uint32_t tu_max32 (uint32_t x, uint32_t y) { return (x > y) ? x : y; }
 static inline uint32_t tu_max32 (uint32_t x, uint32_t y) { return (x > y) ? x : y; }
 
 
 // Align
 // Align
-static inline uint32_t tu_align_n(uint32_t value, uint32_t alignment)
+static inline uint32_t tu_align(uint32_t value, uint32_t alignment)
 {
 {
   return value & ((uint32_t) ~(alignment-1));
   return value & ((uint32_t) ~(alignment-1));
 }
 }

+ 4 - 1
src/portable/nuvoton/nuc505/dcd_nuc505.c

@@ -182,7 +182,10 @@ static void dcd_userEP_in_xfer(struct xfer_ctl_t *xfer, USBD_EP_T *ep)
   /* provided buffers are thankfully 32-bit aligned, allowing most data to be transfered as 32-bit */
   /* provided buffers are thankfully 32-bit aligned, allowing most data to be transfered as 32-bit */
   while (countdown > 3)
   while (countdown > 3)
   {
   {
-    ep->EPDAT = *(uint32_t *)xfer->data_ptr;
+    uint32_t u32;
+    memcpy(&u32, xfer->data_ptr, 4);
+
+    ep->EPDAT = u32;
     xfer->data_ptr += 4; countdown -= 4;
     xfer->data_ptr += 4; countdown -= 4;
   }
   }
   while (countdown--)
   while (countdown--)

+ 4 - 2
src/portable/nxp/transdimension/dcd_transdimension.c

@@ -273,7 +273,8 @@ typedef struct {
   dcd_qtd_t qtd[QHD_MAX] TU_ATTR_ALIGNED(32); // for portability, TinyUSB only queue 1 TD for each Qhd
   dcd_qtd_t qtd[QHD_MAX] TU_ATTR_ALIGNED(32); // for portability, TinyUSB only queue 1 TD for each Qhd
 }dcd_data_t;
 }dcd_data_t;
 
 
-static dcd_data_t _dcd_data CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048);
+CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(2048)
+static dcd_data_t _dcd_data;
 
 
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // CONTROLLER API
 // CONTROLLER API
@@ -478,7 +479,8 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
 
 
   // Force the CPU to flush the buffer. We increase the size by 32 because the call aligns the
   // Force the CPU to flush the buffer. We increase the size by 32 because the call aligns the
   // address to 32-byte boundaries.
   // address to 32-byte boundaries.
-  CleanInvalidateDCache_by_Addr((uint32_t*) buffer, total_bytes + 31);
+  // void* cast to suppress cast-align warning, buffer must be
+  CleanInvalidateDCache_by_Addr((uint32_t*) tu_align((uint32_t) buffer, 4), total_bytes + 31);
 
 
   //------------- Prepare qtd -------------//
   //------------- Prepare qtd -------------//
   qtd_init(p_qtd, buffer, total_bytes);
   qtd_init(p_qtd, buffer, total_bytes);