Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changesets/flash-fix-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: patch
summary: add a FLASH_ST in .ld to keep the flash information that is not code
16 changes: 13 additions & 3 deletions Inc/HALAL/HardFault/HardfaultTrace.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#ifndef __HARD_FAULT_TRACE

#define __HARD_FAULT_TRACE
#include <string.h>
#include <stdint.h>
#include "stm32h7xx_ll_gpio_wrapper.h"
#include "stm32h7xx_ll_bus_wrapper.h"
#include "stm32h7xx_ll_tim_wrapper.h"
#define METADATA_FLASH_ADDR (0x080DFD00) // Metadata pool flash address
#define HF_FLASH_ADDR (0x080C0000U) // Hard_fault_flash address

#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t _metadata;
extern uint32_t _hf_log;
#ifdef __cplusplus
}
#endif

#define METADATA_FLASH_ADDR ((uint32_t) & _metadata) // Metadata pool flash address
#define HF_FLASH_ADDR ((uint32_t) & _hf_log) // Hard_fault_flash address
#define HF_FLAG_VALUE (0xFF00FF00U) // Flag to know if already is written information in the flash
#define METADATA_FLASH_SIZE (0X100U)
#define HARD_FAULT_FLASH_SIZE (0X200U)
Expand Down
1 change: 1 addition & 0 deletions Inc/ST-LIB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ template <auto&... devs> struct Board {

#ifdef HAL_IWDG_MODULE_ENABLED
Watchdog::check_reset_flag();
Hard_fault_check();
#endif
HAL_Init();
HALconfig::system_clock();
Expand Down
28 changes: 15 additions & 13 deletions STM32H723ZGTX_FLASH.ld
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ MEMORY
{
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K-128K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K-128K-128K
FLASH_ST (rx) : ORIGIN = 0x080C0000, LENGTH = 128K
FLASH_BT (rx) : ORIGIN = 0x080E0000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
Expand Down Expand Up @@ -189,28 +191,28 @@ SECTIONS
_edata = .; /* define a global symbol at data end */
} >DTCMRAM AT> FLASH
/*
this needs to be the last thing in FLASH
because the preceeding sections are appended after the one preceeding them
this is, if this were the first thing in FLASH
the sections below it would try to be placed afterwards
thus overflowing the FLASH
.hard_fault_log has to be the first thing in the FLASH_ST
*/

.hardfault_log 0x080C0000 :
.hardfault_log :
{
KEEP(*(.hardfault_log))
. = . + 0x200;
} >FLASH
. = ALIGN(4);
hf_log = .;
KEEP(*(.hardfault_log));
. += 0x200;
} >FLASH_ST

. = ALIGN(4);

.metadata_pool :
{
. = ABSOLUTE(0x080DFD00);
. = ALIGN(4);
metadata = .;
KEEP(*(.metadata_pool))
. += 0x100;
} >FLASH

} >FLASH_ST
PROVIDE(_metadata = metadata);
PROVIDE(_hf_log = hf_log);
/* Uninitialized data section */
. = ALIGN(4);
.bss (NOLOAD) :
Expand Down
27 changes: 26 additions & 1 deletion STM32H723ZGTX_RAM.ld
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
/* Entry Point */
ENTRY(Reset_Handler)


/* Highest address of the user mode stack */
_sstack = ORIGIN(DTCMRAM);
_estack = ORIGIN(DTCMRAM) + LENGTH(DTCMRAM); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200 ; /* required amount of heap */
Expand All @@ -52,7 +54,9 @@ MEMORY
{
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K-128K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K-128K - 128K
FLASH_ST (rx) : ORIGIN = 0x080C0000, LENGTH = 128K
FLASH_BT (rx) : ORIGIN = 0x080E0000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K
Expand Down Expand Up @@ -89,6 +93,8 @@ SECTIONS
.text :
{
. = ALIGN(4);
_stext = .;

*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
Expand All @@ -111,6 +117,14 @@ SECTIONS
. = ALIGN(4);
} >RAM_D1

.hardfault_stack (NOLOAD) : /*Stack memory to avoid memfault inside hardfault handler*/
{
. = ALIGN(8);
_hf_stack_start = .;
. += 0x400; /* 1 KB */
_hf_stack_end = .;
} >DTCMRAM

.ARM.extab (READONLY): { *(.ARM.extab* .gnu.linkonce.armextab.*) } >RAM_D1
.ARM (READONLY): {
__exidx_start = .;
Expand Down Expand Up @@ -183,6 +197,17 @@ SECTIONS
_edata = .; /* define a global symbol at data end */
} >DTCMRAM

/*
.hard_fault_log has to be the first thing in the FLASH_ST
*/

.hardfault_stack (NOLOAD) : /*Stack memory to avoid memfault inside hardfault handler*/
{
. = ALIGN(8);
_hf_stack_start = .;
. += 0x400; /* 1 KB */
_hf_stack_end = .;
} >DTCMRAM
/* Uninitialized data section */
. = ALIGN(4);
.bss :
Expand Down
1 change: 1 addition & 0 deletions Src/HALAL/HardFault/HardfaultTrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern GPIO_TypeDef* ports_hard_fault[];
extern uint16_t pins_hard_fault[];
extern uint8_t hard_fault_leds_count;
extern uint32_t _hf_log;

static void LED_Blink();
static void LED_init(void);
Expand Down
Loading