From 5c73b3e6e903e3007ec3f4586b4b19dca734a7ef Mon Sep 17 00:00:00 2001 From: supperthomas <78900636@qq.com> Date: Thu, 18 Feb 2021 06:23:53 +0800 Subject: [PATCH] add the FAQ about hardfault --- bsp/nrf5x/README.md | 52 +++++++++++++++++++++++++++++++- bsp/nrf5x/nrf52840/board/Kconfig | 4 +-- bsp/nrf5x/nrf52840/board/board.c | 3 -- bsp/nrf5x/nrf52840/board/board.h | 4 +-- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/bsp/nrf5x/README.md b/bsp/nrf5x/README.md index db1540a4d8..c29ba56473 100644 --- a/bsp/nrf5x/README.md +++ b/bsp/nrf5x/README.md @@ -132,4 +132,54 @@ nrf5x 下面提供一种擦写softdevice的方法。在keil中选择softdevice Erase的FLASH算法,这个时候就烧写之前可以擦除之前的softdevice。 -![image-20201017194935643](docs/images/softdevice_erase.png) \ No newline at end of file +![image-20201017194935643](docs/images/softdevice_erase.png) + + + +### 2.如果在使用softdevice的时候,连上手机时候出现一些hardfault + +如下所示: + +``` +psr: 0x8100000f +r00: 0x00000000 +r01: 0x200034e6 +r02: 0x00000000 +r03: 0x200034dc +r04: 0x200034dc +r05: 0x00000000 +r06: 0x200034e6 +r07: 0xdeadbeef +r08: 0xdeadbeef +r09: 0xdeadbeef +r10: 0xdeadbeef +r11: 0xdeadbeef +r12: 0x00000000 + lr: 0x000369af + pc: 0x00036972 +hard fault on handler + +``` + +这个hardfault发生在SOFTDEVICE内部,由于代码不开源,这边尝试了修改如下函数,可以不触发hardfault。 + +``` +rt_hw_interrupt_disable PROC + EXPORT rt_hw_interrupt_disable + ;MRS r0, PRIMASK + ;CPSID I + BX LR + ENDP + +;/* +; * void rt_hw_interrupt_enable(rt_base_t level); +; */ +rt_hw_interrupt_enable PROC + EXPORT rt_hw_interrupt_enable + ;MSR PRIMASK, r0 + BX LR + ENDP +``` + + + diff --git a/bsp/nrf5x/nrf52840/board/Kconfig b/bsp/nrf5x/nrf52840/board/Kconfig index c49ae1f44f..71e7595048 100644 --- a/bsp/nrf5x/nrf52840/board/Kconfig +++ b/bsp/nrf5x/nrf52840/board/Kconfig @@ -314,8 +314,8 @@ menu "On-chip Peripheral Drivers" endif config BSP_USING_SPI bool "Enable SPI" - select RT_USING_PIN - default y + select RT_USING_SPI + default n if BSP_USING_SPI config NRFX_SPI_ENABLED diff --git a/bsp/nrf5x/nrf52840/board/board.c b/bsp/nrf5x/nrf52840/board/board.c index 2ba3214bfa..5bd27ac8fc 100644 --- a/bsp/nrf5x/nrf52840/board/board.c +++ b/bsp/nrf5x/nrf52840/board/board.c @@ -53,9 +53,6 @@ void SysTick_Configuration(void) void rt_hw_board_init(void) { rt_hw_interrupt_enable(0); - // sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE); - /* Activate deep sleep mode */ - SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SysTick_Configuration(); diff --git a/bsp/nrf5x/nrf52840/board/board.h b/bsp/nrf5x/nrf52840/board/board.h index 5357cca291..a3ccadfa36 100644 --- a/bsp/nrf5x/nrf52840/board/board.h +++ b/bsp/nrf5x/nrf52840/board/board.h @@ -21,8 +21,8 @@ extern int __bss_end__; #define HEAP_BEGIN ((void *)&__bss_end__) #endif -#define HEAP_SIZE 16*1024 -#define HEAP_END (HEAP_BEGIN + HEAP_SIZE) + +#define HEAP_END (MCU_SRAM_END_ADDRESS) void rt_hw_board_init(void);