Skip to main content
AScha.3
Super User
December 7, 2023
Solved

Hard Fault on function start - but cannot debug

I have a problem, but dont know, how to solve...

when this function ( mp3dec_decode_frame(..) ) is used, get hard fault. ok, but cannot debug , because no step into function is possible, hard fault is always next step.

Now the prerequisites : this function i used to decode MP3 in my H743 project, no problems.

then copied to this H563 project, but now using rtos Azure (because forced to use this by STM)…

and now : not working anymore, even cannot debug, what happens there, because first is : jump to hard fault.

So maybe the stack is in nirwana, but i cannot see (understand ARM assembler) anything, that leads me to solve the problem.

See , here is the debug at starting the function:

AScha3_0-1701984656178.png

disassm shows here:

AScha3_1-1701984719271.png

(i see no problem...) stack is in mem:

AScha3_2-1701984805304.png

and this seem ok:

AScha3_3-1701984845368.png

so: how to find the reason for this hard fault ?

next step ...hard fault :

AScha3_4-1701984947201.png

cpu then:

AScha3_0-1701985234450.png

 

 

    This topic has been closed for replies.
    AScha.3
    AScha.3Best answer
    Super User
    December 13, 2023

    Yes, seems working now . 8)

    Problem was (probably) stack overgrown in the area of the usbX stack area...

    The mp3 decoder eating up 23KB stack, so i was just lucky to make a test with set to 24KB, then no hard fault.

    Other problem with sometimes error was the hardware: lines to sdcard too long (15cm) , curiously the fatfs i tried had less problems , or no problem at first. But after some days - also errors sometimes. Then i guessed, maybe its not the software and give fileX another try. With short wires (25mm) now reads at 200Mbit, about 20MB/s .

    I work on a nucleo-H563 with this, and agree: >> THREADX - it's super sensitive about the memory.

    + it should tell about, not just crash. :grimacing_face:

    I thing there is a stack monitoring - but dont know, what it is doing...can be set in tx_user.h

    #ifndef TX_USER_H
    #define TX_USER_H
    
    /* USER CODE BEGIN 1 */
    #define TX_ENABLE_STACK_CHECKING
    /* USER CODE END 1 */

    +

    >  I moved all file operations to my main application thread 

    I had same idea , named it "tx_app_main" , to know where i am  :)

     

    just my settings:

    FileX   20KB pool   , 4K stack. exfat enable , MAX_CACHE_SIZE_NB_BIT 9 ; map_size 128;

    MAX_FAT_CACHE_NB_BIT 4 ; MAX_SECTOR_CACHE_NB_BIT 4 ; 

    usbX   32K pool  , 24K sys stack, 4K app stack.

    threadX 60K pool , 24K app stack .

    and added small test thread : 1K stack . (blink LED , to "see" multitasking is running )

    if you know better settings, tell... :)

    If you feel a post has answered your question, please click on " Best Answer ".

    34 replies

    HTD
    Senior II
    December 13, 2023

    Oh, my fault, I forgot the stack grows backwards. So my stack is basically empty. There must be another cause of the crash. I disabled the media statistics and reduced the caches. It didn't help. My tests pass on ExFAT volumes, but crash on FAT32 volumes.