Skip to main content
Associate II
October 4, 2025
Solved

Hard Fault during tx_sempahore_get()

  • October 4, 2025
  • 2 replies
  • 296 views

I have a custom board with a STMU5F7VJT, programmed over SWD, with an on board MMC and a usb connector. 

I am trying to access the onboard MMC with FileX and ThreadX. Using USBX, I can access the MMC just fine, and even format it from my computer, so MMC, ThreadX and DMA should be working fine. When trying to format the MCU through FileX however it hard faults during the synchronization deep in the ThreadX stack when calling tx_semaphore get() in the auto generated macro FX_STM32_MMC_WRITE_CPLT_NOTIFY().

Curiously, this hard fault only happens when the cpu is allowed to run. When manually stepping through, the hard fault never occurs. The hard fault is extremely cryptic. It fails within the function:

VOID _tx_thread_system_suspend(TX_THREAD *thread_ptr)
#ifndef TX_NOT_INTERRUPTABLE
{

At the line of the macro "#ifndef TX_NOT_INTERRUPTABLE before entering the function proper.

I've increased the stack sizes/memory pool to a ludicrous amount, double checked memory alligned buffers and all of my non-rtos interrupts are priority 6 or higher. I've turned down the speed of the MMC all the way down to 26MHz and that didn't work either. The hard fault analyzer and registers don't show a lot of useful information either, all I get out is another cryptic address in SRAM that does not seem to correlate to any surrounding or related variables. 

Best answer by mbarg.1

In my experience, 99% of this type of problem are due to stack overflow - did you check stack usage?

mike

2 replies

mbarg.1
mbarg.1Best answer
Senior III
October 4, 2025

In my experience, 99% of this type of problem are due to stack overflow - did you check stack usage?

mike

Andrew Neil
Super User
October 4, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.