I am using RL-RTX with uVision IDE.
Just recently I ran into a weird issue. The only way I can describe it, is by the following way:
When I compile a C/C++ code I typically click on "Start/Stop Debug Session" after it is done compiling. At this time I see the uVision IDE flashing the microcontroller with the compiled software (using a status bar). After this is done the uVision IDE is ready to for me to click on "Run" to execute the firmware on the target. When I click on "Run" the target executes the firmware as expected. I can tell this by LEDs, LCD, and key inputs. At this time I want to restart and run the firware again, so I click on "Stop". Next, I click on "Reset" and follow this with a click on "Run" again. At this this point the ARM Cortex-M3 generates a 'hard fault exception". This exception is at the following line of code:
LDR r0,[r4, #0x00]
This line of code happens to be in the RTX library. I do not have access to this code, but from the Disassembly I can tell that it is part of the RTX library. See below:
_malloc_internal: PUSH {r4-r8, lr} MOV r4,r0 MOV r6,r1 MOV r7,r2 BL.W 0x080003E4 CMP r0,r4 MOV r5,r0 BLS 0x0800046A CBZ r7,0x08000412 ADD r0,r6,#0x0C NOP.W LDR r4,[r6,#0x04] MOV r1,r6 CBZ r4,0x08000454 LDR r0,[r4,#0x00]
Having typed all of this I was wondering why this is suddenly happening? Why is it only happening when I reset the target and run again? The RTX libraries are precompiled, so nothing changes there.
Has anyone ran into an issue like this?
Check which instruction caused the hardware fault. I’m assuming Load/Store instruction to certain address. Could be a problem with the memory controller setup.
Does the program run correctly without the debugger also after forcing a reset?