AnsweredAssumed Answered

HardFault with lwip+freeRTOS and STM32f745

Question asked by wagner.tobias on Apr 18, 2016
Latest reply on Aug 16, 2016 by thant.myo
I'm using the lwip stack in combination with FreeRTOS for a http server (Netconn API) and modbus TCP (FreeModbus).
I'm using the lwip stack and FreeRTOS from the "STM32Cube_FW_F7_V1.3.0".
Evriting works great for 10-20 min but after that time the processor crashes with a HardFault.
The HardFault happens in the function tcp_output at the line
"if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) {".
The processor wants to load "seg->tcphdr->seqno" and "useg->tcphdr->seqno" but one pointer is not valid and the processor crashes at the address "0800d50a" with a HardFault and the flag unaligned memory access is set.
I activated the lwip_stats and get 60 errors at the memp[6].
In the lwipopts.h the SYS_LIGHTWEIGHT_PROT ist set and I teset different configuration in the lwipopts.h but noting helped.
Where can the problem come from?

Here my disassembly:
1010              if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) {
0800d4fc:   ldr r3, [r4, #12]
0800d4fe:   ldr r0, [r3, #4]
0800d500:   bl 0x80097d4 <lwip_ntohl>
0800d504:   mov r6, r0
0800d506:   ldr.w r3, [r8, #12]
0800d50a:   ldr r0, [r3, #4]
0800d50c:   bl 0x80097d4 <lwip_ntohl>
0800d510:   subs r0, r6, r0
0800d512:   cmp r0, #0
0800d514:   bge.n 0x800d546 <tcp_output+526>
1012                struct tcp_seg **cur_seg = &(pcb->unacked);