Refactoring of startup code, mainly dealing with detection of unexpec… (#4275)
* Refactoring of startup code, mainly dealing with detection of unexpected restart/shutdown * Added g_FATFS_Obj initialization [Horus] * Fix normal startup * Use g_eeGeneral.unexpectedShutdown only on radios that have PWRMANAGE defined Fixes for radios that don't have power control. Other fixes * CLI test for new() * [Horus] Reboot protection reworked to also handle non-WDT events (cherry picked from commit fe9a52779d062e3f24639479273c906abe6e440b) Conflicts: radio/src/targets/horus/board.h * Reverting most of the changes * Cleanup * Added comment that explains apparent non usage of the wdt_disable() function * More cleanup * Missing include * Compilation fix
This commit is contained in:
committed by
Bertrand Songis
parent
bf15410bf1
commit
b3f4870da7
+59
-1
@@ -22,6 +22,7 @@
|
||||
#include "diskio.h"
|
||||
#include <ctype.h>
|
||||
#include <malloc.h>
|
||||
#include <new>
|
||||
|
||||
#define CLI_COMMAND_MAX_ARGS 8
|
||||
#define CLI_COMMAND_MAX_LEN 256
|
||||
@@ -302,6 +303,62 @@ int cliTestSD(const char ** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cliTestNew()
|
||||
{
|
||||
char * tmp = 0;
|
||||
serialPrint("Allocating 1kB with new()");
|
||||
CoTickDelay(100);
|
||||
tmp = new char[1024];
|
||||
if (tmp) {
|
||||
serialPrint("\tsuccess");
|
||||
delete[] tmp;
|
||||
tmp = 0;
|
||||
}
|
||||
else {
|
||||
serialPrint("\tFAILURE");
|
||||
}
|
||||
|
||||
serialPrint("Allocating 10MB with (std::nothrow) new()");
|
||||
CoTickDelay(100);
|
||||
tmp = new (std::nothrow) char[1024*1024*10];
|
||||
if (tmp) {
|
||||
serialPrint("\tFAILURE, tmp = %p", tmp);
|
||||
delete[] tmp;
|
||||
tmp = 0;
|
||||
}
|
||||
else {
|
||||
serialPrint("\tsuccess, allocaton failed, tmp = 0");
|
||||
}
|
||||
|
||||
serialPrint("Allocating 10MB with new()");
|
||||
CoTickDelay(100);
|
||||
tmp = new char[1024*1024*10];
|
||||
if (tmp) {
|
||||
serialPrint("\tFAILURE, tmp = %p", tmp);
|
||||
delete[] tmp;
|
||||
tmp = 0;
|
||||
}
|
||||
else {
|
||||
serialPrint("\tsuccess, allocaton failed, tmp = 0");
|
||||
}
|
||||
serialPrint("Test finished");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cliTest(const char ** argv)
|
||||
{
|
||||
if (!strcmp(argv[1], "new")) {
|
||||
return cliTestNew();
|
||||
}
|
||||
else if (!strcmp(argv[1], "std::exception")) {
|
||||
serialPrint("Not implemented");
|
||||
}
|
||||
else {
|
||||
serialPrint("%s: Invalid argument \"%s\"", argv[0], argv[1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cliTrace(const char ** argv)
|
||||
{
|
||||
if (!strcmp(argv[1], "on")) {
|
||||
@@ -509,7 +566,7 @@ void printTaskSwitchLog()
|
||||
uint32_t * tsl = new uint32_t[DEBUG_TASKS_LOG_SIZE];
|
||||
if (!tsl) {
|
||||
serialPrint("Not enough memory");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
memcpy(tsl, taskSwitchLog, sizeof(taskSwitchLog));
|
||||
uint32_t * p = tsl + taskSwitchLogPos;
|
||||
@@ -892,6 +949,7 @@ const CliCommand cliCommands[] = {
|
||||
{ "set", cliSet, "<what> <value>" },
|
||||
{ "stackinfo", cliStackInfo, "" },
|
||||
{ "meminfo", cliMemoryInfo, "" },
|
||||
{ "test", cliTest, "new | std::exception" },
|
||||
{ "trace", cliTrace, "on | off" },
|
||||
#if defined(PCBFLAMENCO)
|
||||
{ "read_bq24195", cliReadBQ24195, "<register>" },
|
||||
|
||||
Reference in New Issue
Block a user