Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2020-12-15 20:43:38 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-12-15 20:43:38 +0300
commit304510eb4d453a6ce882c420b21ae9b55d018b50 (patch)
tree3b56e0442eb2bcb376fc9d9ec396ca931b4943de /src/Hardware
parent6bb82cf378ae3cada270c4d1933876e6544b3d66 (diff)
Added extra software reset data, added CRC speed test
Diffstat (limited to 'src/Hardware')
-rw-r--r--src/Hardware/SoftwareReset.cpp22
-rw-r--r--src/Hardware/SoftwareReset.h6
2 files changed, 20 insertions, 8 deletions
diff --git a/src/Hardware/SoftwareReset.cpp b/src/Hardware/SoftwareReset.cpp
index 1ea56dd3..f1e7bdf7 100644
--- a/src/Hardware/SoftwareReset.cpp
+++ b/src/Hardware/SoftwareReset.cpp
@@ -80,11 +80,21 @@ void SoftwareResetData::Populate(uint16_t reason, const uint32_t *stk) noexcept
#endif
// Get the task name if we can. There may be no task executing, so we must allow for this.
const TaskHandle_t currentTask = xTaskGetCurrentTaskHandle();
- taskName = (currentTask == nullptr) ? 0 : LoadLE32(pcTaskGetName(currentTask));
+ taskName = (currentTask == nullptr) ? 0x656e6f6e : LoadLE32(pcTaskGetName(currentTask));
- if (stk != nullptr)
+ sp = reinterpret_cast<uint32_t>(stk);
+ if (stk == nullptr)
{
- sp = reinterpret_cast<uint32_t>(stk);
+ stackOffset = 0;
+ stackMarkerValid = 0;
+ spare = 0;
+ }
+ else
+ {
+ const char *stackLimit = (currentTask == nullptr) ? sysStackLimit : (const char*)currentTask + sizeof(TaskBase);
+ stackOffset = ((const char*)stk - stackLimit) >> 2;
+ stackMarkerValid = stackLimit[0] == 0xA5 && stackLimit[3] == 0xA5;
+ spare = 0;
for (uint32_t& stval : stack)
{
stval = (stk < &_estack) ? *stk++ : 0xFFFFFFFF;
@@ -150,10 +160,10 @@ void SoftwareResetData::Print(MessageType mtype, unsigned int slot) const noexce
// The task name may include nulls at the end, so print it as a string
const uint32_t taskNameWords[2] = { taskName, 0u };
reprap.GetPlatform().MessageF(mtype,
- "Software reset code 0x%04x HFSR 0x%08" PRIx32 " CFSR 0x%08" PRIx32 " ICSR 0x%08" PRIx32 " BFAR 0x%08" PRIx32 " SP 0x%08" PRIx32 " Task %s\n",
- resetReason, hfsr, cfsr, icsr, bfar, sp, (const char *)taskNameWords
+ "Software reset code 0x%04x HFSR 0x%08" PRIx32 " CFSR 0x%08" PRIx32 " ICSR 0x%08" PRIx32 " BFAR 0x%08" PRIx32 " SP 0x%08" PRIx32 " Task %s Freestk %u %s\n",
+ resetReason, hfsr, cfsr, icsr, bfar, sp, (const char *)taskNameWords, (unsigned int)stackOffset, (sp == 0) ? "n/a" : (stackMarkerValid) ? "ok" : "bad marker"
);
- if (sp != 0xFFFFFFFF)
+ if (sp != 0)
{
// We saved a stack dump, so print it
scratchString.Clear();
diff --git a/src/Hardware/SoftwareReset.h b/src/Hardware/SoftwareReset.h
index f0c93b64..6630694d 100644
--- a/src/Hardware/SoftwareReset.h
+++ b/src/Hardware/SoftwareReset.h
@@ -62,8 +62,10 @@ struct SoftwareResetData
uint32_t bfar; // bus fault address register
uint32_t sp; // stack pointer
uint32_t when; // value of the RTC when the software reset occurred
- uint32_t taskName; // first 4 bytes of the task name
- uint32_t spare[2]; // unused at present
+ uint32_t taskName; // first 4 bytes of the task name, or 'none'
+ uint32_t stackOffset; // how many spare words of stack the running task has
+ uint32_t stackMarkerValid : 1, // true if the stack low marker wasn't overwritten
+ spare : 31; // unused at present
// The stack length is set to 27 words because that is the most we can print in a single message using our 256-byte format buffer
uint32_t stack[27]; // stack when the exception occurred, with the link register and program counter at the bottom