Skip to content

Commit

Permalink
stm32h743xx_udb: Remove UDB bootloader version memory section for gen…
Browse files Browse the repository at this point in the history
…eric HIC

The UDB IF needs to know the UDB BL version. This version is different
from the DAPLINK_VERSION, it is a string that contains info about the
last git commit, local modifications and can be injected through a CI
pipeline.

However, this doesn't need to be in the generic STM32H743xx HIC and this
frees up additional flash.
  • Loading branch information
gaborcsapo authored and mbrossard committed Aug 4, 2023
1 parent 45bca9a commit 981e606
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 2 additions & 0 deletions records/board/stm32h743xx_udb_bl.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
common:
macros:
- UDB
includes:
- source/board/udb/include/udb_version.h
sources:
Expand Down
10 changes: 5 additions & 5 deletions source/board/udb/include/udb.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

MEMORY
{
m_cfgrom_bl (RW) : ORIGIN = DAPLINK_ROM_CONFIG_ADMIN_START, LENGTH = DAPLINK_ROM_CONFIG_ADMIN_SIZE
m_udb_bl_version_rom (RW) : ORIGIN = DAPLINK_ROM_UDB_BL_VERSION_START, LENGTH = DAPLINK_ROM_UDB_BL_VERSION_SIZE
}

SECTIONS
{
.cfgrom_bl :
.udb_bl_version_rom :
{
KEEP(*(cfgrom_bl))
KEEP(*(udb_bl_version_rom))
FILL(0xffffffff)
. = ORIGIN(m_cfgrom_bl) + LENGTH(m_cfgrom_bl) - 4;
. = ORIGIN(m_udb_bl_version_rom) + LENGTH(m_udb_bl_version_rom) - 4;
/* Need some contents in this section or it won't be copied to bin or hex. The CRC will
* be placed here by post_build_script.py. */
LONG(0x55555555)
} > m_cfgrom_bl
} > m_udb_bl_version_rom
}

#include "stm32h743xx.ld"
4 changes: 2 additions & 2 deletions source/board/udb/source/udb_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#endif // defined(UDB_VERSION_BASE) && defined(UDB_BUILD_NUMBER)

#define UDB_BOOTLOADER_VERSION UDB_BUILD_VERSION
#define UDB_BOOTLOADER_VERSION_SECTION_ADDR DAPLINK_ROM_CONFIG_ADMIN_START
#define UDB_BOOTLOADER_VERSION_SECTION_ADDR DAPLINK_ROM_UDB_BL_VERSION_START
#define BOOTLOADER_CFG_MAGIC_KEY (0x5a5a5a5a)
#define BOOTLOADER_MAX_VERSION_LENGTH UDB_VERSION_MAX_LENGTH

Expand Down Expand Up @@ -63,7 +63,7 @@ COMPILER_ASSERT(sizeof(UDB_BOOTLOADER_VERSION) < BOOTLOADER_MAX_VERSION_LENGTH);
COMPILER_ASSERT(sizeof(bootloader_version_t) < DAPLINK_SECTOR_SIZE);

#ifdef DAPLINK_BL
static volatile bootloader_version_t config_rom_bl __attribute__((section("cfgrom_bl"))) =
static volatile bootloader_version_t udb_bl_version __attribute__((section("udb_bl_version_rom"))) =
{
.magic_key = BOOTLOADER_CFG_MAGIC_KEY,
.version = UDB_BOOTLOADER_VERSION,
Expand Down
21 changes: 16 additions & 5 deletions source/hic_hal/stm32/stm32h743xx/daplink_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

/* Device sizes */

#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_STM32H743_DTCM_START 0x20000000
#define DAPLINK_STM32H743_DTCM_SIZE 0x00020000
Expand All @@ -45,17 +43,30 @@

/* ROM sizes */

#define DAPLINK_ROM_START 0x08000000
#define DAPLINK_ROM_BL_START 0x08000000
#define DAPLINK_ROM_BL_SIZE 0x00020000 // 128 kB bootloader -- 1 sector

#define DAPLINK_ROM_CONFIG_ADMIN_START 0x08020000
#define DAPLINK_ROM_CONFIG_ADMIN_SIZE 0x00020000 // 1 sector
#ifdef UDB
#define DAPLINK_ROM_SIZE 0x000A0000 // has to be a multiple of the sector size, only bank 1 is used

#define DAPLINK_ROM_UDB_BL_VERSION_START 0x08020000
#define DAPLINK_ROM_UDB_BL_VERSION_SIZE 0x00020000 // 1 sector to keep everything else sector aligned

#define DAPLINK_ROM_IF_START 0x08040000
#define DAPLINK_ROM_IF_SIZE 0x00040000 // 2 sectors

#define DAPLINK_ROM_CONFIG_USER_START 0x08080000
#define DAPLINK_ROM_CONFIG_USER_SIZE 0x00020000 // 1 sector
#else
#define DAPLINK_ROM_SIZE 0x00080000 // has to be a multiple of the sector size, only bank 1 is used

#define DAPLINK_ROM_IF_START 0x08020000
#define DAPLINK_ROM_IF_SIZE 0x00040000 // 2 sectors

#define DAPLINK_ROM_CONFIG_USER_START 0x08060000
#define DAPLINK_ROM_CONFIG_USER_SIZE 0x00020000 // 1 sector
#endif

/* RAM sizes */

Expand All @@ -79,7 +90,7 @@
#define DAPLINK_ROM_APP_START DAPLINK_ROM_IF_START
#define DAPLINK_ROM_APP_SIZE DAPLINK_ROM_IF_SIZE
#define DAPLINK_ROM_UPDATE_START DAPLINK_ROM_BL_START
#define DAPLINK_ROM_UPDATE_SIZE (DAPLINK_ROM_BL_SIZE + DAPLINK_ROM_CONFIG_ADMIN_SIZE)
#define DAPLINK_ROM_UPDATE_SIZE (DAPLINK_ROM_BL_SIZE + DAPLINK_ROM_UDB_BL_VERSION_SIZE)

#else

Expand Down

0 comments on commit 981e606

Please sign in to comment.