Skip to content

Add a panic() function

rahix requested to merge rahix/panic into master
commit 5d9c9be9a6ca463f2f4c1be668bb943033776f67
Author: Rahix <>
Date:   Fri Oct 4 09:50:14 2019 +0200

    fix(libcard10): Mark card10_reset() as noreturn
    card10_reset() won't ever return to where it was called from.  Telling
    the compiler this can help with program-flow analysis.
    Signed-off-by: Rahix <>

 lib/card10/card10.c | 5 ++++-
 lib/card10/card10.h | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

commit bd755446a46822718ffaf1043c023562e905edac
Author: Rahix <>
Date:   Fri Oct 4 13:02:30 2019 +0200

    feat(serial): Add function to switch serial to synchroneous
    In severe error conditions, asynchroneous prints will never work.  For
    such cases we need a way to make prints happen synchroneously again, the
    same way it works during early boot.  Add a
    `serial_return_to_synchroneous()` function which unconditionally
    switches the serial module to synchroneous mode.  Only use this function
    in unrecoverable error conditions!
    Signed-off-by: Rahix <>

 epicardium/modules/modules.h | 2 ++
 epicardium/modules/serial.c  | 5 +++++
 2 files changed, 7 insertions(+)

commit fffc289d5a5f6f00a9ff45da1a11e6b1db76a00c
Author: Rahix <>
Date:   Fri Oct 4 09:58:29 2019 +0200

    feat(epicardium): Add a panic() function
    In unrecoverable situations we should provide a common way to output the
    cause of the error and then reset the CPU.  The panic() function is
    mean to be exactly that.  It outputs the error-cause, stack-trace, and
    firmware revision, accompanied by a link to the issue-tracker to
    encourage people to report the error.  After a timeout of ~1.5s it
    resets the CPU and reboots.
    Future Work:
     - Right now, the stack-trace only has a depth of one which is the
       return address from where panic() was called.  In the future it might
       make sense to provide a deeper stack-trace if a robust implementation
       is possible.
     - Integration of @msgctl's faultscreen (!79) so users who don't have
       the serial console open at all times can also see what happened.
    Signed-off-by: Rahix <>

 epicardium/modules/ |  1 +
 epicardium/modules/modules.h   |  4 +++
 epicardium/modules/panic.c     | 63 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)

commit 0a33bfca975f66671ea84bc5d8b5f6bbd0af1563
Author: Rahix <>
Date:   Fri Oct 4 13:27:58 2019 +0200

    feat(epicardium): Use panic() for assertion failures
    Define `__assert_func()` so a failing `assert()` will trigger a panic.
    Signed-off-by: Rahix <>

 epicardium/modules/panic.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

commit 56f8b4937d5a6e7a2ba88c834e21ac308385dc01
Author: Rahix <>
Date:   Fri Oct 4 13:40:43 2019 +0200

    chore(epicardium): Switch from MXC_ASSERT to assert
    Newlib assert uses __assert_func and thus our panic() function while
    MXC_ASSERT uses a custom assertion logic.  Newlib assert is also more
    portable as it works in expression position while MXC_ASSERT only works
    as a statement.
    Signed-off-by: Rahix <>

 epicardium/FreeRTOSConfig.h | 7 +++----
 epicardium/modules/bhi.c    | 7 ++++---
 2 files changed, 7 insertions(+), 7 deletions(-)

Merge request reports