[Solved] UsageFault or HardFault when connect to target Cortex M4F

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [Solved] UsageFault or HardFault when connect to target Cortex M4F

    I am having a small demo project and a real project.

    With the small demo project, the SystemView works like a charm with FreeRTOS and XMC4500.

    However, when I use SystemView for my real project, at the moment I connect the SystemView PC Application to MCU, the system underwent a reset and after that the trace works again like a charm. When the 1000,000 limit is reached, the trace stops itself.

    My FreeRTOS ram is in PSRAM 0x10000000 - 0x10000. The .data and .bss is in 0x20000000 - 0x10000

    I then did try to see what kind of reset it was by giving each of the Cortex M4 exceptions a number from 1,2,3,4,5 and trap the fault by calling test(i) inside the exception handler with its own number as parameter.
    Debugger was connected then to the running target.

    static void test(int i)
    {
    int j = i;
    while(j);
    }

    This way I can tell that it is mostly UsageFault (and occasionally HardFault). These faults does not happen otherwise in my firmware.

    Indeed the source of fault is INVPC. Alternatively, it was Hardfault, where INVPC is also set.

    How can I avoid these two kind of resets when using SystemView?
    Images
    • UsageFault_Sysview.PNG

      22.42 kB, 628×364, viewed 974 times
    • INVPC.PNG

      20.01 kB, 570×204, viewed 818 times
    • hardfault.PNG

      46.83 kB, 1,223×690, viewed 884 times

    The post was edited 5 times, last by shenj ().

  • Hi,

    HardFaults/Resets are most commonly caused by stack overflows. SystemView may need ~200 Bytes on the stack.
    Make sure enough stack is available in every
    context (Task, Interrupt, Scheduler) which can create SystemView events.

    Best regards
    Johannes
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.