You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/02/24 11:09:13 UTC
[mynewt-core] branch master updated (a1f8dfc -> 55e774c)
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.
from a1f8dfc hw/sensor: fix possible null dereference in sensor_set_thresh() If stt is NULL return error to before dereferencing it.
new 4dd102a kernel/os/arch: Store M33-MTB state for core dump
new bc29392 hw/scripts: Small improvements for MTB display
new 27b289b hw/scripts: Allow GDB script for MTB to be used on crash dumps
new 57e5063 hw/scripts: Fix MTB with no colorama
new 55e774c hw/bsp/dialog: Stop MTB in Default_Handler
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/arch/cortex_m33/gcc_startup_da1469x.S | 7 +++
hw/scripts/micro-trace-buffer.py | 28 +++++++---
kernel/os/src/arch/cortex_m33/os_fault.c | 64 +++++++++++++++++-----
3 files changed, 76 insertions(+), 23 deletions(-)
[mynewt-core] 02/05: hw/scripts: Small improvements for MTB display
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit bc29392e78e84c49363eb569b307db1d04b2a806
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Feb 5 13:28:55 2021 +0100
hw/scripts: Small improvements for MTB display
- MTB display is not stopped when non existing memory is accessed,
this may happen when execution reaches address 0 for example
- script was no displaying instructions starting from point when
exception occurred to exception handler
---
hw/scripts/micro-trace-buffer.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/hw/scripts/micro-trace-buffer.py b/hw/scripts/micro-trace-buffer.py
index 80df78e..5abc402 100644
--- a/hw/scripts/micro-trace-buffer.py
+++ b/hw/scripts/micro-trace-buffer.py
@@ -99,11 +99,14 @@ class MicroTraceBuffer(gdb.Command):
self._print(f" ~A~0x{addr:08x}: ~D~{asm}")
def _disassemble(self, start: int, end: int):
- disasm = self._arch.disassemble(start, end)
- for instr in disasm:
- addr = instr["addr"]
- asm = instr["asm"].expandtabs(8)
- self._describe_instr(addr, asm)
+ try:
+ disasm = self._arch.disassemble(start, end)
+ for instr in disasm:
+ addr = instr["addr"]
+ asm = instr["asm"].expandtabs(8)
+ self._describe_instr(addr, asm)
+ except gdb.MemoryError:
+ print(f"Error disassembling 0x{start:08x}-0x{end:08x}")
print()
def _cmd_decode(self):
@@ -154,10 +157,10 @@ class MicroTraceBuffer(gdb.Command):
if mtb_pkt_src & 0xff000000 == 0xff000000:
self._print(f"~X~Exception return (LR: 0x{mtb_pkt_src:08x}, "
f"ret address: 0x{mtb_pkt_dst:08x})")
+ print()
+ continue
else:
self._print(f"~X~Exception entry (ret address: 0x{mtb_pkt_src:08x})")
- print()
- continue
# on 1st entry in trace buffer, disassemble source of the branch
if exec_begin is None:
@@ -173,6 +176,9 @@ class MicroTraceBuffer(gdb.Command):
self._disassemble(exec_begin, exec_end)
+ if bit_a != 0:
+ self._print(f"~X~Exception started")
+
# disassemble target of last branch
self._disassemble(mtb_pkt_dst, mtb_pkt_dst)
[mynewt-core] 01/05: kernel/os/arch: Store M33-MTB state for core
dump
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 4dd102a4209a846e858c1b9c4dd684b6bf7fda0c
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Feb 5 11:45:53 2021 +0100
kernel/os/arch: Store M33-MTB state for core dump
When Micro Trace Buffer is part of the core dump, few registers
that are vital to correctly interpret buffer start position are
not available during crash analyzes.
This stores copy of those registers to RAM that is stored in crash file,
so MTB can be viewed in crash dumps.
---
kernel/os/src/arch/cortex_m33/os_fault.c | 64 ++++++++++++++++++++++++--------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/kernel/os/src/arch/cortex_m33/os_fault.c b/kernel/os/src/arch/cortex_m33/os_fault.c
index 7ad71d7..c8caa41 100644
--- a/kernel/os/src/arch/cortex_m33/os_fault.c
+++ b/kernel/os/src/arch/cortex_m33/os_fault.c
@@ -116,7 +116,52 @@ trap_to_coredump(struct trap_frame *tf, struct coredump_regs *regs)
regs->pc = tf->ef->pc;
regs->psr = tf->ef->psr;
}
+
+struct mtb_state {
+ uint32_t mtb_position_reg;
+ uint32_t mtb_master_reg;
+ uint32_t mtb_flow_reg;
+ uint32_t mtb_base_reg;
+} mtb_state_at_crash;
+#endif
+
+static void
+mtb_stop(void)
+{
+ /*
+ * Stop MTB if implemented so interrupt handler execution is not recorded.
+ * Store MTB registers in mtb_state_at_crash so it can be used for
+ * crash analyzes.
+ */
+ asm volatile (".syntax unified \n"
+ " ldr r1, =0xe00ff000 \n"
+ " ldr r2, [r1, #0x1c] \n"
+ " tst r2, #1 \n"
+ " beq 1f \n"
+ " bic r2, #0x00ff \n"
+ " bic r2, #0x0f00 \n"
+ " add r1, r2 \n"
+ " ldr r2, [r1, #4] \n"
+ " bic r2, #0x80000000 \n"
+ " str r2, [r1, #4] \n"
+#if MYNEWT_VAL(OS_COREDUMP)
+ " str r2, [%[mtbs], #4]\n"
+ " ldr r2, [r1] \n"
+ " str r2, [%[mtbs]] \n"
+ " ldr r2, [r1, #8] \n"
+ " str r2, [%[mtbs], #8]\n"
+ " ldr r2, [r1, #12] \n"
+ " str r2, [%[mtbs], #12]\n"
+#endif /* MYNEWT_VAL(OS_COREDUMP) */
+ " 1: \n"
+ :
+#if MYNEWT_VAL(OS_COREDUMP)
+ : [mtbs] "r" (&mtb_state_at_crash)
+#else
+ :
#endif
+ : "r1", "r2");
+}
void
__assert_func(const char *file, int line, const char *func, const char *e)
@@ -126,6 +171,9 @@ __assert_func(const char *file, int line, const char *func, const char *e)
#endif
int sr;
+ /* Stop MTB if implemented so interrupt handler execution is not recorded */
+ mtb_stop();
+
OS_ENTER_CRITICAL(sr);
(void)sr;
console_blocking_mode();
@@ -165,21 +213,7 @@ os_default_irq(struct trap_frame *tf)
#endif
/* Stop MTB if implemented so interrupt handler execution is not recorded */
- asm volatile (".syntax unified \n"
- " ldr r1, =0xe00ff000 \n"
- " ldr r2, [r1, #0x1c] \n"
- " tst r2, #1 \n"
- " beq 1f \n"
- " bic r2, #0x00ff \n"
- " bic r2, #0x0f00 \n"
- " add r1, r2 \n"
- " ldr r2, [r1, #4] \n"
- " bic r2, #0x80000000 \n"
- " str r2, [r1, #4] \n"
- " 1: \n"
- :
- :
- : "r1", "r2");
+ mtb_stop();
console_blocking_mode();
console_printf("Unhandled interrupt (%ld), exception sp 0x%08lx\n",
[mynewt-core] 05/05: hw/bsp/dialog: Stop MTB in Default_Handler
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 55e774c49cebbd07c4023759267c41497e29e618
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Tue Feb 16 15:17:00 2021 +0100
hw/bsp/dialog: Stop MTB in Default_Handler
Default handler simply loops waiting for debugger or watchdog.
MTB is not turned off it this event to keep useful information
in MBT buffer and not just infinite loop trace.
---
.../src/arch/cortex_m33/gcc_startup_da1469x.S | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/bsp/dialog_da1469x-dk-pro/src/arch/cortex_m33/gcc_startup_da1469x.S b/hw/bsp/dialog_da1469x-dk-pro/src/arch/cortex_m33/gcc_startup_da1469x.S
index c5e1281..c535071 100644
--- a/hw/bsp/dialog_da1469x-dk-pro/src/arch/cortex_m33/gcc_startup_da1469x.S
+++ b/hw/bsp/dialog_da1469x-dk-pro/src/arch/cortex_m33/gcc_startup_da1469x.S
@@ -272,6 +272,13 @@ Reset_Handler:
/* Default interrupt handler */
.type Default_Handler, %function
Default_Handler:
+#if MYNEWT_VAL(MCU_MTB_ENABLE)
+ /* Disable MTB, otherwise it will quickly fill up buffer with infinite loop branch. */
+ ldr r1, =MTB_POSITION_REG
+ ldr r2, [r1, #4]
+ bic r2, #0x80000000
+ str r2, [r1, #4]
+#endif
ldr r1, =SYS_CTRL_REG
ldrh r2, [r1, #0]
orrs r2, r2, #0x80 /* DEBUGGER_ENABLE */
[mynewt-core] 03/05: hw/scripts: Allow GDB script for MTB to be
used on crash dumps
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 27b289b548260a50b25d7e8785788387a1b85efb
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Feb 5 13:22:16 2021 +0100
hw/scripts: Allow GDB script for MTB to be used on crash dumps
If 'mtb_state_at_crash' symbol is present in core dump MTB script
can be used on crash dump files to see what lead to crash.
---
hw/scripts/micro-trace-buffer.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/scripts/micro-trace-buffer.py b/hw/scripts/micro-trace-buffer.py
index 5abc402..8806e73 100644
--- a/hw/scripts/micro-trace-buffer.py
+++ b/hw/scripts/micro-trace-buffer.py
@@ -37,6 +37,12 @@ class MicroTraceBuffer(gdb.Command):
def __init__(self):
super(MicroTraceBuffer, self).__init__("mtb", gdb.COMMAND_STATUS, gdb.COMPLETE_NONE)
+ try:
+ mtb_state_at_crash = gdb.lookup_symbol("mtb_state_at_crash")[0]
+ if mtb_state_at_crash is not None and int(gdb.parse_and_eval('mtb_state_at_crash.mtb_base_reg')) != 0:
+ self._mtb_base_addr = int(gdb.parse_and_eval('mtb_state_at_crash').address)
+ except gdb.error:
+ pass
if colorama:
self._colors = {"A": colorama.Fore.BLUE,
"D": colorama.Fore.RESET,
[mynewt-core] 04/05: hw/scripts: Fix MTB with no colorama
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 57e50635a1fc9c348c463a03547a9d12536ebd0e
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Feb 8 10:49:35 2021 +0100
hw/scripts: Fix MTB with no colorama
This manually sets colorama variable to None when colorama
packed import fails.
---
hw/scripts/micro-trace-buffer.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/scripts/micro-trace-buffer.py b/hw/scripts/micro-trace-buffer.py
index 8806e73..d90467d 100644
--- a/hw/scripts/micro-trace-buffer.py
+++ b/hw/scripts/micro-trace-buffer.py
@@ -18,7 +18,7 @@
try:
import colorama
except ImportError:
- pass
+ colorama = None
import re