I'm observing an MbedOS hard fault when using the LocalFileSystem and wait(). I added a wait() command inside a loop that was writing multiple values to a CSV file. The hard fault seemed to occur when the wait() function was called.
LPC1768
GCC_ARM & Online Compiler
n/a
gcc-arm-none-eabi-7-2017-q4-major
mbed-cli version: 1.5.0
I wrote up a simple LocalFileSystem example for the Mbed Application board that writes 100 integer values to a .csv file:
#include "mbed.h"
LocalFileSystem local("local");
int main() {
FILE *fp = fopen("/local/test.csv","w");
for (int i = 0; i < 100; i++) {
fprintf(fp, "%d\n", i);
}
fclose(fp);
}
The above code works and a TEST.CSV file is created in the local filesystem with integer values 0-99. However, when I add a wait function to the for loop, the MbedOS Fault Handler is triggered:
#include "mbed.h"
LocalFileSystem local("local");
int main() {
FILE *fp = fopen("/local/test.csv","w");
for (int i = 0; i < 100; i++) {
fprintf(fp, "%d\n", i);
wait(0.05); // triggers ++ MbedOS Fault Handler ++
}
fclose(fp);
}
No values are stored into the csv file as the application doesn't get to fclose(fp);
Expected behavior
That the fault handler is not triggered and the for loop waits for 0.05 seconds, then saves a test.csv file with the 100 integer values.
Actual behavior
Output to the serial terminal of the Fault Handler error message:
++ MbedOS Fault Handler ++
FaultType: HardFault
Context:
R0 : 00000005
R1 : 100025AC
R2 : 00000122
R3 : 00000000
R4 : 00000005
R5 : 100025AC
R6 : 10002920
R7 : 10000288
R8 : 10000288
R9 : 00000000
R10 : 00000000
R11 : 00000000
R12 : 00002CD9
SP : 100025A8
LR : 00000CF1
PC : 00001794
xPSR : 01000000
PSP : 10002588
MSP : 10007FB8
CPUID: 412FC230
HFSR : 80000000
MMFSR: 00000000
BFSR : 00000000
UFSR : 00000000
DFSR : 00000002
AFSR : 00000000
SHCSR: 00000000
Mode : Thread
Priv : Privileged
Stack: PSP
Thread Info:
Current:
State: 00000002 EntryFn: 00001CF1 Stack Size: 00001000 Mem: 10001648 SP: 100025D0
Next:
State: 00000002 EntryFn: 00001CF1 Stack Size: 00001000 Mem: 10001648 SP: 100025D0
Wait Threads:
State: 00000083 EntryFn: 00003A8D Stack Size: 00000300 Mem: 10000F78 SP: 10001210
Delay Threads:
Idle Thread:
State: 00000001 EntryFn: 00001E79 Stack Size: 00000200 Mem: 10001278 SP: 10001420
-- MbedOS Fault Handler --
Sounds like it's probably the same root cause as https://github.com/ARMmbed/mbed-os/issues/6578 .
[Mirrored to Jira]
@ARMmbed/team-nxp Please review
[Mirrored to Jira]
@ARMmbed/team-nxp Any update on this?
[Mirrored to Jira]
Have you configure it?
I meet something like this
@maclobdell Is this on your radar?
@yennster thank you for raising this issue.Please take a look at the following comments:
Could you add some more detail to the description? A good description should be at least 25 words.
What target(s) are you using?
What toolchain(s) are you using?
What version of Mbed OS are you using (tag or sha)?
It would help if you could also specify the versions of any tools you are using?
How can we reproduce your issue?
NOTE: If there are fields which are not applicable then please just add 'n/a' or 'None'.This indicates to us that at least all the fields have been considered.
Please update the issue header with the missing information, the issue will not be mirroredto our internal defect tracking system or investigated until this has been fully resolved.
We've updated our automation, I will fix the requirements .
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2455
Most helpful comment
Sounds like it's probably the same root cause as https://github.com/ARMmbed/mbed-os/issues/6578 .
[Mirrored to Jira]