Skip to main content
MauFanGilaMedical
Associate III
Question

HardFault_Handler when enable LWIP and touchgfx

Hello guys.

 

I've bought Riverdi 12.1” board that mounts STM32H757XIH6.

 

I developed graphic part and I use uSD, and USB Mass-Storage without any problems.

 

I use FreeRTOS and FatFS.

 

Now it's time to use Ethernet, so I bought PoE - Riverdi, enabled LWIP library following instructions on the video How to use Ethernet on Riverdi STM32 Embedded Displays || PoE Add-on.

 

I set MX in this way:

MauFanGilaMedical_0-1746012830072.pngMauFanGilaMedical_1-1746012861994.png

 

MauFanGilaMedical_2-1746012895732.pngMauFanGilaMedical_3-1746012927438.png

The linker script

 

MauFanGilaMedical_4-1746012987404.png

ethernetif.c

MauFanGilaMedical_5-1746013035117.png

 

I compiled and I connect ethernet cable and it seems work poperly because if I ping I obtain right answer,

 

but! sometimes processor goes to HardFault

 

I've writed simple TCP server that accept connection on port 100 and send "Hello" every second.

 

MauFanGilaMedical_7-1746013397900.png

 

When I try to connect with TERA TERM it goes immediately on HardFault.

 

MauFanGilaMedical_8-1746013683113.png

 

Here the code of ethernet_input

 

MauFanGilaMedical_9-1746013734859.png

 

 

Can someone Help me ?

 

Thankyou in advance

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    This topic has been closed for replies.

    11 replies

    TDK

    Cuold be insufficient stack size.

    Look at the ethhdr pointer and ensure it's valid. If it's not, set up a hardware watchpoint to see where and when it's changed.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    MauFanGilaMedical
    Associate III

    what do you intend ?  set up a hardware watchpoint to see where and when it's changed

    how can I see whene it's changed ?

    MauFanGilaMedical
    Associate III

    Yes @TDK I watch the address: is 0x28000045

     

    MauFanGilaMedical_1-1746016800628.png

     

     

    and ethhdr->type is 0x24001b64

     

    MauFanGilaMedical_2-1746016856829.png

     

    how to increase stack size for tcpip_thread ? maybe TCPIP_THREAD_STACKSIZE ?

     

    MauFanGilaMedical_0-1746017312561.png

     

     

     

     

    MauFanGilaMedical
    Associate III

    MauFanGilaMedical_0-1746018284243.png

     

    it seems msg->msg.inp.p point to invalid address: 0x28 ... 

     

    MauFanGilaMedical_1-1746018424563.png

     

    No RAM @ 0x28...

    MauFanGilaMedical_2-1746018478517.png

     

     

     

     

    MauFanGilaMedical
    Associate III

    Another question that I want to higlight, counld be that I have not enabled D-Cache ?

     

    MauFanGilaMedical_0-1746023204862.png

     

    TDK

    Here's how to set a watchpoint:

    https://community.st.com/t5/stm32cubeide-mcus/how-to-add-the-watchpoint/m-p/310217/highlight/true#M16720

    You want to watch for the pointer to change, so add &ethhdr as the expression.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    MauFanGilaMedical
    Associate III

    Watchpoint is disabled maybe ethhdr is a local variable 

     

    MauFanGilaMedical_0-1746425125783.png

     

    GaetanGodart
    ST Employee

    Hello @MauFanGilaMedical ,

     

    Have you increase the stack size from STM32CubeMX as you show on one of your messages ?

    Are you able to make the PoE (and ethernet in general) work without TouchGFX (or other implementations) ?

    Can you check that the types on line 113 match, also check that ethhdr->type is properly initialized ?

    Have you enabled your watchpoint ?

    Not enabling D cache should not be an issue.

    You could also ask for help on the Riverdi forum, maybe they have more informations.

     

    Regards,

    Gaetan GodartSoftware engineer at ST (TouchGFX)
    MauFanGilaMedical
    Associate III

    When I go to HardFault I shot the stack and see if one thread stack overlap the next but I don't see this situation

     

    MauFanGilaMedical_1-1746430421121.png

     

    MauFanGilaMedical_0-1746430380489.png

     

    MauFanGilaMedical
    Associate III

    Today it goes to HardFault from __ISB or __DSB:

     

    Stack for __DSB

     

    MauFanGilaMedical_2-1746450766626.png

     

     

    MauFanGilaMedical_5-1746450838659.png

     

     

    MauFanGilaMedical_4-1746450812591.png

     

     

     

    And stack for __ISB

     

    MauFanGilaMedical_7-1746451154312.png

     

    MauFanGilaMedical_8-1746451174105.png

    If could be helpful the CFRS is IMPRECISERR

     

     

    MauFanGilaMedical_9-1746454861812.pngMauFanGilaMedical_10-1746454877469.png

     

    MauFanGilaMedical_11-1746455064228.png

     

     

    MauFanGilaMedical
    Associate III

    I observe that memp_memory_RX_POOL_base is at 0x30000400 and its size is 18,38KB, so memp_memory_RX_POOL_base spans in 0x30000400..30004BCC.

     

    Starting from this I set LWIP_RAM_HEAP_POINTER to 0x30005000 because I suspect that memp_memory_RX_POOL_base overlaps LWIP_RAM_HEAP_POINTER.

     

    MauFanGilaMedical_0-1747043448244.png

     

    Then I go to MPU and increase MPU Region 1 Size from 16K to 64K because it started from 0x30000400 and its size is 0x30005000-0x30000400+14KB

     

    MauFanGilaMedical_1-1747043546431.png

     

    Subsequently I increase INTERFACE_THREAD_STACK_SIZE from 350 to 1KB ..

     

    MauFanGilaMedical_2-1747043744474.png

    And I increase that stack of Server thread from 1KB to 10KB (even if I want to undersand how to reduce it to a minimum necessary size)

     

    With this change the Server works without MCU crash... I observed one/two crashes and I'm still investigating.

     

    I notice that when I send packets from PC to MCU sometimes MCU crashes