arm: async uart writes & fixes
This commit is contained in:
33
arm/crash.cc
33
arm/crash.cc
@@ -15,19 +15,19 @@ namespace {
|
||||
char addr[] = "00000000: ";
|
||||
int i = 0;
|
||||
itoa(reinterpret_cast<uint32_t>(begin), addr);
|
||||
UartSendCrash(addr);
|
||||
UartWriteCrash(addr);
|
||||
for (uint32_t* ptr = begin; direction > 0 ? ptr < end : ptr > end;
|
||||
ptr += direction, i++) {
|
||||
itoa(*ptr, number);
|
||||
UartSendCrash(number);
|
||||
UartWriteCrash(number);
|
||||
if (i % 4 == 3) {
|
||||
UartSendCrash("\r\n");
|
||||
UartWriteCrash("\r\n");
|
||||
itoa(reinterpret_cast<uint32_t>(ptr + 1), addr);
|
||||
UartSendCrash(addr);
|
||||
UartWriteCrash(addr);
|
||||
}
|
||||
}
|
||||
if (i % 4 != 3) {
|
||||
UartSendCrash("\r\n");
|
||||
UartWriteCrash("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void StackTrace(uint32_t* sp) {
|
||||
continue;
|
||||
}
|
||||
itoa(*ptr, number);
|
||||
UartSendCrash(number);
|
||||
UartWriteCrash(number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,16 +68,16 @@ struct Armv6mRegs {
|
||||
void CrashHandler(Armv6mRegs* regs) {
|
||||
char number[] = "00000000\r\n";
|
||||
|
||||
UartSendCrash("\r\n\r\nCra$h!!\r\n- xpsr: 0x");
|
||||
UartWriteCrash("\r\n\r\nCra$h!!\r\n- xpsr: 0x");
|
||||
itoa(regs->xpsr, number);
|
||||
UartSendCrash(number);
|
||||
UartSendCrash("- pc: 0x");
|
||||
UartWriteCrash(number);
|
||||
UartWriteCrash("- pc: 0x");
|
||||
itoa(regs->pc, number);
|
||||
UartSendCrash(number);
|
||||
UartSendCrash("- lr: 0x");
|
||||
UartWriteCrash(number);
|
||||
UartWriteCrash("- lr: 0x");
|
||||
itoa(regs->lr, number);
|
||||
UartSendCrash(number);
|
||||
UartSendCrash("- Stack trace:\r\n");
|
||||
UartWriteCrash(number);
|
||||
UartWriteCrash("- Stack trace:\r\n");
|
||||
StackTrace(reinterpret_cast<uint32_t*>(regs->sp));
|
||||
|
||||
while (1) {
|
||||
@@ -103,10 +103,13 @@ __attribute__((naked)) void HardFaultHandler() {
|
||||
"mrs lr, msp \n"
|
||||
"push {r0-r3, lr} \n"
|
||||
"push {r4-r7} \n"
|
||||
:
|
||||
: "r"(gpio0));
|
||||
asm volatile(
|
||||
"mrs r0, msp \n"
|
||||
"mov r1, %1 \n"
|
||||
"mov r1, %0 \n"
|
||||
"blx r1 \n"
|
||||
:
|
||||
: "r"(gpio0), "r"(CrashHandler));
|
||||
: "r"(CrashHandler));
|
||||
}
|
||||
} // namespace crash
|
||||
|
||||
Reference in New Issue
Block a user