Skip to main content
Visitor II
January 9, 2025
Question

Hard fault while sending huge data through ethernet

  • January 9, 2025
  • 5 replies
  • 5701 views

"We are facing a hard fault issue in our code when sending a large amount of data. Occasionally, it runs properly, but most of the time, it goes into a hard fault after sending approximately 10,000 bytes. The image data we are sending is around 40 KB. Interestingly, sending 'Hello World' in a loop works successfully without any faults. I have also tried increasing the lwIP options sizes through a trial-and-error approach, but the issue persists. I have been struggling with this problem for the past 20 days and have not been able to resolve it. I am using the STM32H723VGT6 microcontroller. Please help me resolve this issue."

    This topic has been closed for replies.

    5 replies

    Super User
    January 9, 2025

    @utkarshchaurasiya36 wrote:

    I have been struggling with this problem for the past 20 days and have not been able to resolve it.


    So what have you tried in those 20 days?

    What have you discovered?

     

    Debugging Hard Faults:

    https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/tac-p/708193/highlight/true#M51

     

    LwIP Debugging:

    https://community.st.com/t5/stm32-mcus/using-the-itm-console-for-printf-redirects-and-lwip-debug/ta-p/723472

     

    PS:

     


    @utkarshchaurasiya36 wrote:

    Occasionally, it runs properly, but most of the time, it goes into a hard fault after sending approximately 10,000 bytes.."


    If it does work occasionally, that could suggest a timing issue somewhere...
     

    Some general debugging tips:

    https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/tac-p/706966/highlight/true#M49

     

    Visitor II
    January 13, 2025
    HARD FAULT STACK-
    "cam_bsnet Debug [STM32 C/C++ Application]
    cam_bsnet.elf [cores: 0]
    Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)
    HardFault_Handler() at stm32h7xx_it.c:113 0x8002070
    <signal handler called>() at 0xfffffffd
    ethernet_input() at ethernet.c:113 0x8023328
    tcpip_thread_handle_msg() at tcpip.c:174 0x801714e
    tcpip_thread() at tcpip.c:148 0x8017102
    pxPortInitialiseStack() at port.c:214 0x8012ab0
    arm-none-eabi-gdb (13.2.90.20230627)
    ST-LINK (ST-LINK GDB server)"
    Super User
    January 13, 2025

    So look into the code at that point to see what's going on.

    Visitor II
    January 13, 2025

    Duplicate - merged. Please don't create new threads on the same topic.


    "We are facing a hard fault issue in our code when sending a large amount of data. Occasionally, it runs properly most of the time, but sometimes it goes into a hard fault /mem handler fault after sending approximately a few bytes. The image data we are sending is around 10 KB. Interestingly, sending 'Hello World' in a loop works successfully without any faults. I have also tried increasing the lwIP option sizes through a trial-and-error approach, but the issue persists. I have been struggling with this problem for the past 5 days and cannot resolve it. I am using the STM32H723VGT6 microcontroller. Please help me resolve this issue."

    Graduate II
    January 14, 2025

    I have put the lwIP heap and pbuf pool into AXI SRAM / D1, maybe try that.

    You won't run out of memory that quick - but I have actually no idea how the OS or you are handling the lwIP pool memory...

     

    Visitor II
    January 16, 2025

    I am working on a project using the STM32H723VGT6 controller with the DP83848VV Ethernet IC (MII interface) and FreeRTOS. I need assistance optimizing the lwipopts file settings to send large data (e.g., 40 KB images) efficiently over Ethernet.

    I have attached a screenshot of my current settings, but I believe some values might not be configured correctly. Could you please suggest the best values for key LWIP options like TCP_MSS, TCP_WND, PBUF_POOL_SIZE, etc., to handle large data transmission smoothly? Please suggest the best value and look on the screenshot which I attached.11.png

     

    12.png

     

    13.png

     

    14.png

     

    15.png

     

    16.png

     

    17.png

     

    18.png

     

    19.png

     

    Thank you for your guidance!

    Visitor II
    January 17, 2025

    I have been trying to solve the same problem for a few days.

    I can read 21500 bytes of ethernet tcp data correctly in Keil. But I still can't do it in STM32CubeIde. If I can solve it, I will share

    Visitor II
    January 17, 2025

    yes, please can you please share lwipots.c file