Question
USB related hardfault when connected to Linux but not Windows
I have a stm32f4 nucleo board. Under Windows, I started a project using CubeMX and did a bunch of development. Everything was working as expected.
I then moved to Linux (Ubuntu 19.04), and the device just started hard faulting constantly:
(gdb) bt
#0 HardFault_Handler ()
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Core/Src/stm32f4xx_it.c:42
#1 <signal handler called>
#2 0x00000000 in ?? ()
#3 0x08003fbc in HAL_DMA_Start_IT (hdma=0x0, SrcAddress=<optimized out>,
DstAddress=<optimized out>, DataLength=<optimized out>)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c:474
#4 0x08005a76 in ah_USBCDCWriteAsync (drv=0x1044, data=<optimized out>, len=0,
callback=<optimized out>) at /home/phil/dev/tros/port/common/mcu_stm32/bsp/ah_bspUSB.c:154
#5 0x080059a4 in USBCDCRecvHandler (pdev=0x8006bb5, Buf=<optimized out>, Len=0x20013d58)
at /home/phil/dev/tros/port/common/mcu_stm32/bsp/ah_bspUSB.c:78
#6 0x08004de8 in USBD_CDC_DataOut (pdev=0x20014d70, epnum=<optimized out>)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c:722
#7 0x0800450e in USBD_LL_DataOutStage (pdev=0x20014d70, epnum=<optimized out>,
pdata=<optimized out>)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c:342
#8 0x08000c7a in HAL_PCD_DataOutStageCallback (hpcd=<optimized out>, epnum=<optimized out>)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/USB_DEVICE/Target/usbd_conf.c:155
#9 0x0800118a in PCD_EP_OutXfrComplete_int (hpcd=hpcd@entry=0x2000149c <hpcd_USB_OTG_FS>,
epnum=536991708, epnum@entry=1)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c:2143
#10 0x0800138c in HAL_PCD_IRQHandler (hpcd=0x2000149c <hpcd_USB_OTG_FS>)
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c:1068
#11 0x08000ab0 in OTG_FS_IRQHandler ()
at /home/phil/dev/tros/port/common/mcu_stm32/vendor/ST/CubeProject/Core/Src/stm32f4xx_it.c:240The TLDR:
- I can build / flash on Linux, but the device constantly hard faults
- I can build / flash on Linux, boot into Windows and the device works as expected
- I can build / flash on Windows, and the device works as expected
- I can build / flash on Windows, boot into Linux and the device constantly hard faults
