Semihost_hardfault in FreeRTOS software timer creation

Hi all,
I have a strange problem. First some dtails:
Processor: MKV58F1M0xxx24 (NXP Arm Cortex-M7)
Compiler/IDE: MCUXpresso
Debugger: J-Link

Here is the relevant code:


/* Initialization function */
void vInitSupervisoryControlTask(void) {

    printf("In vInitSupervisoryControlTask\n");
    initEventGroups();
    vCreateTimers();

The CreateTimers function is as follows:


void vCreateTimers(void) {

    xTimerShutdownBrake = xTimerCreateStatic(
        "Shutdown & Brake", // Just a text name, not used by the RTOS kernel
        pdMS_TO_TICKS(TIMER_PERIOD_SHUTDOWN_BRAKE * 1000), // Period
        pdFALSE, // Auto-reload
        (void*)0, // ID (a count of the number of times the timer has expired)
        vCallbackShutdownBrake, // Callback function
        &xTimerBufferShutdownBrake // Address of a StaticTimer_t variable
    );
       
   
    xTimer10RPMRotation = xTimerCreateStatic(
        "10 RPM Rotation",
        pdMS_TO_TICKS(TIMER_PERIOD_PERIODIC_ROTATION * 1000),
        pdFALSE,                     // One-shot timer
        (void*)&xTimer10RPMData,     // Pass data for 10 RPM
        vCallbackPeriodicRotation,  // Callback function
        &xTimerBuffer10RPMRotation   // Static buffer
    );

    xTimer0RPMRotation = xTimerCreateStatic(
        "0 RPM Rotation",
        pdMS_TO_TICKS(TIMER_PERIOD_PERIODIC_ROTATION * 1000),
        pdFALSE,                     // One-shot timer
        (void*)&xTimer0RPMData,      // Pass data for 0 RPM
        vCallbackPeriodicRotation,  // Callback function
        &xTimerBuffer0RPMRotation    // Static buffer
    );

    // Ensure timers are created successfully
    if (xTimer10RPMRotation == NULL || xTimer0RPMRotation == NULL) {
        // Handle error: Timer creation failed
    }
    else {
        //NOTE: Printing here causes semihost_hardfault
//    printf("Timers created\n"); 
 //   vTaskDelay(pdMS_TO_TICKS(5000));
    }
}

At the moment I have only 4 tasks running but a lot more have been coded (I switch them off by not calling their init functions).

Why could there be a semihost_hardfault?

You can’t normally use semihosting with FreeRTOS as semihosting and the kernel use the same resources, plus semihosting holds up the processor.

What are you using semihosting for? Can you share the code for semihost_hardfault? Can you try removing the prints for testing?

Thank you Richard,
I really appreciate it.

The semihosting approach is the default approach we use for dev work. But from now on, when developing FreeRTOS applications, I will not use semihosting snymore thanks to Richard’s comment. BTW, the semihosting code is quite large (from MCUXpresso).