Skip to content

Commit 869db44

Browse files
authored
Exit command causing hard fault on Silabs devices (project-chip#42759)
* [SL-UP] MATTER-5715: Exit command causing hard fault (project-chip#779) * stub exit command and print unsupported msg * Revert "stub exit command and print unsupported msg" This reverts commit 8422dec0e70b2e2ebfd44517c6c4fbb6b8e1e095. * refactor to reset system on exit call * use sizeof for print
1 parent 0c05aa1 commit 869db44

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

examples/platform/silabs/syscalls_stubs.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <string.h>
3131
#include <sys/stat.h>
3232

33+
#include <em_device.h>
34+
3335
#ifdef __cplusplus
3436
extern "C" {
3537
#endif
@@ -236,6 +238,24 @@ int __attribute__((weak)) _write(int file, const char * ptr, int len)
236238
}
237239
#endif // SILABS_LOG_OUT_UART
238240

241+
/**************************************************************************
242+
* @brief
243+
* Override exit to prevent hard fault
244+
*
245+
* @param[in] status
246+
* Exit status (not used).
247+
**************************************************************************/
248+
void __attribute__((weak)) exit(int status)
249+
{
250+
(void) status;
251+
static const char kExitMessage[] = "exit not supported, resetting system...\r\n";
252+
_write(0, kExitMessage, sizeof(kExitMessage) - 1);
253+
NVIC_SystemReset();
254+
while (1)
255+
{
256+
} // Unreachable, satisfies noreturn attribute
257+
}
258+
239259
#ifdef __cplusplus
240260
}
241261
#endif

0 commit comments

Comments
 (0)