Skip to content

Commit

Permalink
flash/stm32l4x: support STM32U53/U54x devices
Browse files Browse the repository at this point in the history
STM32U53/U54x devices are similar to U57/U58x devices
with 2 flash banks up to 256 KB each

Change-Id: I774ef0df4dddac5f06bbfc2e6c3fc2e628d2249e
Signed-off-by: FBOSTM <[email protected]>
Signed-off-by: Tarek BOCHKATI <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7515
Tested-by: jenkins
Reviewed-by: Tomas Vanek <[email protected]>
  • Loading branch information
tarek-bochkati authored and tom-van committed Jul 25, 2024
1 parent 6554d17 commit 052a4a6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/flash/nor/stm32l4x.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ static const struct stm32l4_rev stm32g49_g4axx_revs[] = {
{ 0x1000, "A" },
};

static const struct stm32l4_rev stm32u53_u54xx_revs[] = {
{ 0x1000, "A" }, { 0x1001, "Z" },
};

static const struct stm32l4_rev stm32u57_u58xx_revs[] = {
{ 0x1000, "A" }, { 0x1001, "Z" }, { 0x1003, "Y" }, { 0x2000, "B" },
{ 0x2001, "X" }, { 0x3000, "C" }, { 0x3001, "W" },
Expand Down Expand Up @@ -428,6 +432,18 @@ static const struct stm32l4_part_info stm32l4_parts[] = {
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
{
.id = DEVID_STM32U53_U54XX,
.revs = stm32u53_u54xx_revs,
.num_revs = ARRAY_SIZE(stm32u53_u54xx_revs),
.device_str = "STM32U535/U545",
.max_flash_size_kb = 512,
.flags = F_HAS_DUAL_BANK | F_QUAD_WORD_PROG | F_HAS_TZ | F_HAS_L5_FLASH_REGS,
.flash_regs_base = 0x40022000,
.fsize_addr = 0x0BFA07A0,
.otp_base = 0x0BFA0000,
.otp_size = 512,
},
{
.id = DEVID_STM32G05_G06XX,
.revs = stm32g05_g06xx_revs,
Expand Down Expand Up @@ -2022,11 +2038,22 @@ static int stm32l4_probe(struct flash_bank *bank)
stm32l4_info->bank1_sectors = num_pages / 2;
}
break;
case DEVID_STM32U59_U5AXX:
case DEVID_STM32U53_U54XX:
case DEVID_STM32U57_U58XX:
/* if flash size is more than 1M the device is always dual bank
* otherwise check DUALBANK bit
case DEVID_STM32U59_U5AXX:
/* according to RM0456 Rev 4, Chapter 7.3.1 and 7.9.13
* U53x/U54x have 512K max flash size:
* 512K variants are always in DUAL BANK mode
* 256K and 128K variants can be in DUAL BANK mode if FLASH_OPTR:DUALBANK is set
* U57x/U58x have 2M max flash size:
* 2M variants are always in DUAL BANK mode
* 1M variants can be in DUAL BANK mode if FLASH_OPTR:DUALBANK is set
* U59x/U5Ax have 4M max flash size:
* 4M variants are always in DUAL BANK mode
* 2M variants can be in DUAL BANK mode if FLASH_OPTR:DUALBANK is set
* Note: flash banks are always contiguous
*/

page_size_kb = 8;
num_pages = flash_size_kb / page_size_kb;
stm32l4_info->bank1_sectors = num_pages;
Expand Down
1 change: 1 addition & 0 deletions src/flash/nor/stm32l4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#define DEVID_STM32L43_L44XX 0x435
#define DEVID_STM32C01XX 0x443
#define DEVID_STM32C03XX 0x453
#define DEVID_STM32U53_U54XX 0x455
#define DEVID_STM32G05_G06XX 0x456
#define DEVID_STM32G07_G08XX 0x460
#define DEVID_STM32L49_L4AXX 0x461
Expand Down

0 comments on commit 052a4a6

Please sign in to comment.