Skip to content

Commit

Permalink
stm32h743xx_hic: Reshuffle RAM on stm32h743xx
Browse files Browse the repository at this point in the history
Execute out of DTCM and put the sector_buf named 128kB buffer into
AXI-SRAM because there isn't enough space in DTCM. This change should
make execution faster.
  • Loading branch information
gaborcsapo authored and mbrossard committed Aug 4, 2023
1 parent ef98b1e commit 45bca9a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion records/board/stm32h743xx_udb_if.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions records/hic_hal/stm32h743xx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -61,3 +62,5 @@ tool_specific:
sources:
hic_hal:
- source/hic_hal/stm32/stm32h743xx/gccarm
linker_file:
- source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld
2 changes: 1 addition & 1 deletion source/board/udb/include/udb.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ SECTIONS
} > m_cfgrom_bl
}

#include "daplink.ld"
#include "stm32h743xx.ld"
2 changes: 2 additions & 0 deletions source/daplink/daplink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions source/daplink/drag-n-drop/iap_flash_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
18 changes: 13 additions & 5 deletions source/hic_hal/stm32/stm32h743xx/daplink_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand All @@ -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 */

Expand Down
16 changes: 16 additions & 0 deletions source/hic_hal/stm32/stm32h743xx/stm32h743xx.ld
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 45bca9a

Please sign in to comment.