From ea7d270146054d9fb42d8a9a6288bfc44a19298e Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 22 Oct 2022 23:15:30 +1100 Subject: [PATCH] Dump PC in assert failure --- source/Core/BSP/Pinecilv2/Pins.h | 1 + source/Core/BSP/Pinecilv2/Setup.cpp | 9 --------- .../risc-v/Core/Include/riscv_encoding.h | 1 + .../drivers/bl702_driver/startup/interrupt.c | 17 ++++++++++++++++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/source/Core/BSP/Pinecilv2/Pins.h b/source/Core/BSP/Pinecilv2/Pins.h index 3baf060c..6037c1f9 100644 --- a/source/Core/BSP/Pinecilv2/Pins.h +++ b/source/Core/BSP/Pinecilv2/Pins.h @@ -8,6 +8,7 @@ #ifndef BSP_PINE64_PINS_H_ #define BSP_PINE64_PINS_H_ #include "bl702_adc.h" +#include "bl702_pwm.h" #include "hal_gpio.h" #define KEY_B_Pin GPIO_PIN_28 diff --git a/source/Core/BSP/Pinecilv2/Setup.cpp b/source/Core/BSP/Pinecilv2/Setup.cpp index 26f7872c..d3775aea 100644 --- a/source/Core/BSP/Pinecilv2/Setup.cpp +++ b/source/Core/BSP/Pinecilv2/Setup.cpp @@ -159,12 +159,3 @@ void setupFUSBIRQ() { CPU_Interrupt_Enable(GPIO_INT0_IRQn); gpio_irq_enable(FUSB302_IRQ_Pin, ENABLE); } - -void vAssertCalled(void) { - MSG((char *)"vAssertCalled\r\n"); - PWM_Channel_Disable(PWM_Channel); - gpio_set_mode(PWM_Out_Pin, GPIO_INPUT_PD_MODE); - - while (1) - ; -} diff --git a/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/risc-v/Core/Include/riscv_encoding.h b/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/risc-v/Core/Include/riscv_encoding.h index 4987ac26..973ec86c 100644 --- a/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/risc-v/Core/Include/riscv_encoding.h +++ b/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/risc-v/Core/Include/riscv_encoding.h @@ -221,6 +221,7 @@ #define rdtime() read_csr(time) #define rdcycle() read_csr(cycle) #define rdinstret() read_csr(instret) +#define get_pc() read_csr(mepc) #endif diff --git a/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/startup/interrupt.c b/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/startup/interrupt.c index e23b18d2..65ef20a2 100644 --- a/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/startup/interrupt.c +++ b/source/Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/startup/interrupt.c @@ -173,6 +173,21 @@ const pFunc __Vectors[] __attribute__((section(".init"), aligned(64))) = { WIFI_IPC_PUBLIC_IRQHandler_Wrapper, /* 16 + 63 */ }; +#include "riscv_encoding.h" +void vAssertCalled(void) { + MSG((char *)"vAssertCalled\r\n"); + unsigned long epc; + epc = get_pc(); + MSG("mepc:0x%08x\r\n", (uint32_t)epc); + +// PWM_Channel_Disable(PWM_Channel); +// gpio_set_mode(PWM_Out_Pin, GPIO_INPUT_PD_MODE); + + while (1) + ; +} + + void Trap_Handler(void) { unsigned long cause; @@ -184,7 +199,7 @@ void Trap_Handler(void) cause = read_csr(mcause); MSG("mcause=%08x\r\n", (uint32_t)cause); - epc = read_csr(mepc); + epc = get_pc(); MSG("mepc:%08x\r\n", (uint32_t)epc); tval = read_csr(mtval); MSG("mtval:%08x\r\n", (uint32_t)tval);