diff --git a/records/board/stm32h743xx_udb_if.yaml b/records/board/stm32h743xx_udb_if.yaml index a641cf669c..74f4fef299 100644 --- a/records/board/stm32h743xx_udb_if.yaml +++ b/records/board/stm32h743xx_udb_if.yaml @@ -27,4 +27,4 @@ common: - source/board/udb/lib/nlbacktrace/source - source/board/udb/lib/nlutilities/source - source/board/udb/source - - source/board/udb/usb + - source/board/udb/usb \ No newline at end of file diff --git a/records/hic_hal/stm32h743xx.yaml b/records/hic_hal/stm32h743xx.yaml index f839951b75..1b3ece8f3f 100644 --- a/records/hic_hal/stm32h743xx.yaml +++ b/records/hic_hal/stm32h743xx.yaml @@ -12,7 +12,8 @@ common: - DAPLINK_NO_ASSERT_FILENAMES - OS_CLOCK=240000000 - OS_ROBIN_ENABLE=1 - - SECTOR_BUFFER_SIZE=32 + - SECTOR_BUFFER_SIZE=32 # this is a small write buffer used in settings_rom.c + - DAPLINK_RELOCATE_SECTOR_BUF # this is relocating another sector buffer in iap_flash_intf.c which has to hold an entire sector and doesn't fit into our default DTCM RAM includes: - source/hic_hal/stm32/hal/STM32H7xx_HAL_Driver - source/hic_hal/stm32/hal/STM32H7xx_HAL_Driver/Inc @@ -39,7 +40,7 @@ tool_specific: sources: hic_hal: - source/hic_hal/stm32/stm32h743xx/armcc - make_armcc: + armcc: misc: ld_flags: - --predefine="-Isource/hic_hal/stm32/stm32h743xx" @@ -52,7 +53,7 @@ tool_specific: sources: hic_hal: - source/hic_hal/stm32/stm32h743xx/armcc - make_gcc_arm: + gcc_arm: misc: ld_flags: # for some reason GCC links in the non-thumb version, @@ -61,3 +62,5 @@ tool_specific: sources: hic_hal: - source/hic_hal/stm32/stm32h743xx/gccarm + linker_file: + - source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld \ No newline at end of file diff --git a/source/board/udb/include/udb.ld b/source/board/udb/include/udb.ld index e5e7e79a1d..d2940bad8a 100644 --- a/source/board/udb/include/udb.ld +++ b/source/board/udb/include/udb.ld @@ -18,4 +18,4 @@ SECTIONS } > m_cfgrom_bl } -#include "daplink.ld" +#include "stm32h743xx.ld" diff --git a/source/daplink/daplink.h b/source/daplink/daplink.h index 75ae62c6c5..0868f5f4da 100644 --- a/source/daplink/daplink.h +++ b/source/daplink/daplink.h @@ -43,7 +43,9 @@ COMPILER_ASSERT(DAPLINK_ROM_CONFIG_USER_START + DAPLINK_ROM_CONFIG_USER_SIZE == // RAM check COMPILER_ASSERT(DAPLINK_RAM_APP_START == DAPLINK_RAM_START); COMPILER_ASSERT(DAPLINK_RAM_APP_START + DAPLINK_RAM_APP_SIZE == DAPLINK_RAM_SHARED_START); +#ifndef DAPLINK_RELOCATE_SECTOR_BUF COMPILER_ASSERT(DAPLINK_RAM_SHARED_START + DAPLINK_RAM_SHARED_SIZE == DAPLINK_RAM_START + DAPLINK_RAM_SIZE); +#endif #define DAPLINK_BUILD_KEY_IF 0x9B939E8F #define DAPLINK_BUILD_KEY_BL 0x9B939D93 diff --git a/source/daplink/drag-n-drop/iap_flash_intf.c b/source/daplink/drag-n-drop/iap_flash_intf.c index 40cf0da17e..ca7b274cef 100644 --- a/source/daplink/drag-n-drop/iap_flash_intf.c +++ b/source/daplink/drag-n-drop/iap_flash_intf.c @@ -87,7 +87,12 @@ static bool current_page_set; static uint32_t current_page; static uint32_t current_page_write_size; static uint32_t crc; + +#ifdef DAPLINK_RELOCATE_SECTOR_BUF +static uint8_t sector_buf[DAPLINK_SECTOR_SIZE] __attribute__((section("sector_buf_section"))); +#else static uint8_t sector_buf[DAPLINK_SECTOR_SIZE]; +#endif static error_t init() { diff --git a/source/hic_hal/stm32/stm32h743xx/daplink_addr.h b/source/hic_hal/stm32/stm32h743xx/daplink_addr.h index 44217cddd6..78753bd85a 100644 --- a/source/hic_hal/stm32/stm32h743xx/daplink_addr.h +++ b/source/hic_hal/stm32/stm32h743xx/daplink_addr.h @@ -27,8 +27,16 @@ #define DAPLINK_ROM_START 0x08000000 #define DAPLINK_ROM_SIZE 0x000A0000 // has to be a multiple of the sector size, only bank 1 is used, the datasheet says under table 7 in the notes section that the memory boundary is limited to this on each bank -#define DAPLINK_RAM_START 0x24000000 // Execute from AXI SRAM, because it's powered on by default and the app is quite large due to the sector_buf static variable that is used to hold one sector (128Kb) -#define DAPLINK_RAM_SIZE 0x00080000 // divisible by DAPLINK_MIN_WRITE_SIZE +#define DAPLINK_STM32H743_DTCM_START 0x20000000 +#define DAPLINK_STM32H743_DTCM_SIZE 0x00020000 + +#define DAPLINK_STM32H743_AXISRAM_START 0x24000000 +#define DAPLINK_STM32H743_AXISRAM_SIZE 0x00060000 + +#define DAPLINK_RAM_START (DAPLINK_STM32H743_DTCM_START) + +#define DAPLINK_RAM_SECTOR_BUFFER_START (DAPLINK_STM32H743_AXISRAM_START) // sector_buf static variable is too big for DTCM (128kB), so let's put it into AXI-SRAM +#define DAPLINK_RAM_SECTOR_BUFFER_SIZE 0x00020000 /* Flash Programming Info */ @@ -51,11 +59,11 @@ /* RAM sizes */ -#define DAPLINK_RAM_APP_START DAPLINK_RAM_START -#define DAPLINK_RAM_APP_SIZE (DAPLINK_RAM_SIZE - DAPLINK_MIN_WRITE_SIZE) // leave space for RAM_SHARED +#define DAPLINK_RAM_APP_START DAPLINK_STM32H743_DTCM_START // Execute app from DTCM +#define DAPLINK_RAM_APP_SIZE (DAPLINK_STM32H743_DTCM_SIZE - DAPLINK_MIN_WRITE_SIZE) // leave space for RAM_SHARED #define DAPLINK_RAM_SHARED_START (DAPLINK_RAM_APP_START + DAPLINK_RAM_APP_SIZE) -#define DAPLINK_RAM_SHARED_SIZE (DAPLINK_RAM_SIZE - DAPLINK_RAM_APP_SIZE) // fill the rest of RAM +#define DAPLINK_RAM_SHARED_SIZE (DAPLINK_STM32H743_DTCM_SIZE - DAPLINK_RAM_APP_SIZE) /* Current build */ diff --git a/source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld b/source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld new file mode 100644 index 0000000000..536fb2c03b --- /dev/null +++ b/source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld @@ -0,0 +1,16 @@ +#include "daplink_addr.h" + +MEMORY +{ + m_sector_buf (RW) : ORIGIN = DAPLINK_RAM_SECTOR_BUFFER_START, LENGTH = DAPLINK_RAM_SECTOR_BUFFER_SIZE +} + +SECTIONS +{ + .sector_buf_section (NOLOAD) : + { + KEEP(*(sector_buf_section)) + } > m_sector_buf +} + +#include "daplink.ld" \ No newline at end of file