T4.1 software reset?

JSch

Member
Howdy forum,

Looking to perform software reset of Teensy 4.1. Looking in the forums, I've seen examples using
Code:
 _reboot_Teensyduino_()
and also incorporating into a macro, but in both cases I get undefined reference to `_reboot_Teensyduino_'.

Thoughts?

Much appreciated!
Jim
 
Along similar lines... is there a way to detect whether the reset was caused by software (ie. SCB_AIRCR reboot, firmware update, cold boot/power on)?

I'd like to perform a task *only* if when cold booted vs. using SCB_AIRCR to reset.
 
Along similar lines... is there a way to detect whether the reset was caused by software (ie. SCB_AIRCR reboot, firmware update, cold boot/power on)?

I'd like to perform a task *only* if when cold booted vs. using SCB_AIRCR to reset.

It's a little bit tricky since there are many different reset triggers. The CrashReport code checks most of them: https://github.com/PaulStoffregen/c...816f3f67a7a1a340/teensy4/CrashReport.cpp#L160
You might have to examine the values in SRC_SRSR for hot/cold reboots and see if there's a reliable way to distinguish between them.
 
This works here to distinguish a cold boot (power on boot) from a reset

Code:
bool isWarmBoot()
{
    static DMAMEM unsigned bootCheck; // DMAMEM is not zeroed during bootup

    if (bootCheck != 0xAAAA'AAAA)
    {
        bootCheck = 0xAAAA'AAAA;                         // some number
        arm_dcache_flush(&bootCheck, sizeof(bootCheck)); // dmamem is cached, force a write to memory
        return false;
    }
    return true;
}

void setup()
{
    while (!Serial) {}

    Serial.printf("%s \n", isWarmBoot() ? "Warm Boot" : "ColdBoot");
}

void loop()
{
}

DMAMEM is not zeroed at bootup, so checking for some magic number works. Chances that it boots up with 0xAAAA'AAAA by chance are not zero but, depending on your use this might be acceptable
 
Back
Top