2023-09-27 06:16 PM
Stats:
STM32CubeIDE
Version: 1.13.2
Build: 18220_20230914_1601 (UTC)
Windows 10 Enterprise
I have a project using STM32H743 and Azure RTOS, ThreadX, NetX, and FileX.
In the NetX portion during initialization of the netx thread, the code performs initiation of the LAN8742 device.
Here is the call stack tree in the debugger:
The hard fault occurs on line 131 in the lan8742.c code which is :
if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_SOFT_RESET) >= 0)
The Status registers show:
The fault is 100% repeatable.
The fault appeared after adding some code to a completely unrelated section
and the fault happens prior to any of the added code being executed. As far as I can tell
The only difference is that the added code has pushed the LAN8742.c code a
little farther down in the flash. I also noticed that some of the printf()'s for debug also
cause issues like mem faults and have to be commented out. I am not finished experimentation
with what causes the hard fault in the Lan8742 code but any comments at this pint are welcome.
Solved! Go to Solution.
2023-10-03 03:49 PM
This is true, but in this case not much help or at least not much different than inspecting the stack and the fault registers. But as it turns out the error always occurs on the same statement which was a strtok call. Further research shows the strtok call to not be thread safe. strtok_r() is and it works. The faults are not occurring anymore.