Closed
Description
I don't know if some other standard function are affected but it seems that every time we call mktime()
in a critical section, with GCC only, an hardfault is fired. Both standard and nano libs seems to be affected. I tried with the NUCLEO_F303RE and NUCLEO_F429ZI and the mbed-cli to compile the tests.
mbed compile -m NUCLEO_F303RE -t GCC_ARM
with this main.cpp
#include "mbed.h"
int main()
{
time_t t1, t2;
printf("begin\n");
struct tm timeinfo;
timeinfo.tm_wday = 4;
timeinfo.tm_mon = 0;
timeinfo.tm_mday = 1;
timeinfo.tm_year = 70;
timeinfo.tm_hour = 0;
timeinfo.tm_min = 0;
timeinfo.tm_sec = 5;
// Daylight Saving Time information is not available
timeinfo.tm_isdst = -1;
t1 = mktime(&timeinfo);
printf("t1: %ld\n", t1);
// __disable_irq();
// printf("printf is ok ?\n");
// __enable_irq();
//core_util_critical_section_enter();
__disable_irq();
t2 = mktime(&timeinfo);
__enable_irq();
//core_util_critical_section_exit();
printf("t2: %ld\n", t2);
printf("end\n");
}
and the output, same result on GCC v5.3 and v4.9.
begin
t1: 5
printf is ok ?
An other thing that can be related, with ARM and IAR compilers, we can't use printf() in critical section (which should be the normal behaviour, the serial_api use interrupts) but with GCC the text is printed.