Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 1 month ago.
Hard crash when using fopen
Hey all,
I've done a search looking for this crash, but I've not seen anything resembling what I've seen. I'm currently on the mbed desktop app, with a target of the LPC1768 (latest firmware) and building against mbed-os 5.12.0
I've created a simple program, based off the 'blinky' sample and have added a simple 'fopen' command. Which gives me a hard crash:
edit: This is also running from Mbed Studio. copying the file to the device works fine.
output from com port
=============================== SYSTEM INFO ================================ Mbed OS Version: 51200 CPU ID: 0x412fc230 Compiler ID: 1 Compiler Version: 6110004 RAM0: Start 0x10000000 Size: 0x8000 RAM1: Start 0x2007c000 Size: 0x8000 ROM0: Start 0x0 Size: 0x80000 ++ MbedOS Fault Handler ++ FaultType: HardFault Context: R0 : 00000001 R1 : 100013DC R2 : 80000000 R3 : 00004E74 R4 : 1000140C R5 : 00004E73 R6 : 1000176C R7 : 100022C4 R8 : 00004E82 R9 : 00004E6C R10 : 00000000 R11 : 00000000 R12 : 0000360D SP : 100013D8 LR : 00006B9D PC : 00006BA2 xPSR : 21000000 PSP : 100013B8 MSP : 10007FD0 CPUID: 412FC230 HFSR : 80000000 MMFSR: 00000000 BFSR : 00000000 UFSR : 00000000 DFSR : 00000002 AFSR : 00000000 Mode : Thread Priv : Privileged Stack: PSP -- MbedOS Fault Handler -- ++ MbedOS Error Info ++ Error Status: 0x80FF013D Code: 317 Module: 255 Error Message: Fault exception Location: 0x5103 Error Value: 0x6BA2 Current Thread: main Id: 0x10001A44 Entry: 0x53C5 StackSize: 0x1000 StackMem: 0x100004F8 SP: 0x10007F74 For more info, visit: https://mbed.com/s/error?error=0x80FF013D&osver=51200&core=0x412FC230&comp=1&ver=6110004&tgt=LPC1768 -- MbedOS Error Info --
And the codebase is fairly trivial:
main.cpp
/* mbed Microcontroller Library * Copyright (c) 2018 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #include "mbed.h" #include "stats_report.h" LocalFileSystem local("local"); DigitalOut led1(LED1); DigitalOut led2(LED2); #define SLEEP_TIME 250 // (msec) #define PRINT_AFTER_N_LOOPS 20 // main() runs in its own thread in the OS int main() { SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); FILE* pfp = fopen("/local/config.ini", "r"); int count = 0; while (true) { // Blink LED and wait 0.5 seconds led1 = !led1; wait_ms(SLEEP_TIME); if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { // Following the main thread wait, report on the current system status sys_state.report_state(); led2 = !led2; count = 0; } ++count; } }
1 Answer
6 years, 1 month ago.
Hello Ash,
I tested your code (copy & pasted to a new mbed-os-example-blinky
program) with both Mbed OS 5.13.2 and Mbed OS 5.12.0. However, I was not able to reproduce the reported run time error on my LPC1768 board updated to the latest firmware.
Hey there,
I tried to update the question yesterday, but wasn't able to. The Big Missing Piece (tm) to the question was that I was also running this through Mbed Studio via the debug/run tools.
I'm assuming that something funky is going on with where the running executable is loaded.
posted by 08 Aug 2019
I originally thought this may have been an issue in debugging via mbed studio, but I'm now seeing this in running code, using mbed OS 5.13
posted by Ash Matheson 12 Aug 2019