spflanze wrote on Tuesday, March 15, 2016:
The -O1 optimization produces this assembly code:
StartThreadUART_Rx:
08002098: StartThreadUART_Rx+0 push {r4, r5, r6, lr}
0800209a: StartThreadUART_Rx+2 sub sp, #16
0800209c: StartThreadUART_Rx+4 sub.w r3, sp, #12224 ; 0x2fc0
080020a0: StartThreadUART_Rx+8 movs r2, #0
080020a2: ...tThreadUART_Rx+10 str.w r2, [r3, #-60]
159 { xQueueReceiveResult = xQueueReceive( QueueUART_RxHandle, (void *)&rxchar, portMAX_DELAY );
080020a6: ...tThreadUART_Rx+14 ldr r5, [pc, #128] ; (0x8002128 <StartThreadUART_Rx+144>)
161 HAL_UART_DMAResumeStat = HAL_UART_DMAResume( &huart2 );
080020a8: ...tThreadUART_Rx+16 ldr r6, [pc, #128] ; (0x800212c <StartThreadUART_Rx+148>)
159 { xQueueReceiveResult = xQueueReceive( QueueUART_RxHandle, (void *)&rxchar, portMAX_DELAY );
080020aa: ...tThreadUART_Rx+18 movs r3, #0
080020ac: ...tThreadUART_Rx+20 mov.w r2, #4294967295
080020b0: ...tThreadUART_Rx+24 add.w r1, sp, #15
080020b4: ...tThreadUART_Rx+28 ldr r0, [r5, #0]
080020b6: ...tThreadUART_Rx+30 bl 0x8006984 <xQueueGenericReceive>
The Bus Fault happens just as before at …Rx+10.
Is it possible this is a GCC bug?