Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed STM32WB55 reading DEBUG IDCODE from the wrong address #1101

Merged
merged 3 commits into from
Mar 20, 2021
Merged
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
22 changes: 12 additions & 10 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,21 +1221,23 @@ int stlink_core_id(stlink_t *sl) {
int stlink_chip_id(stlink_t *sl, uint32_t *chip_id) {
int ret;

if (sl->core_id == STM32H7_CORE_ID) {
uint32_t cpu_id;
*chip_id = 0;
ret = -1;

// Read the CPU ID to determine where to read the core id from
if (stlink_read_debug32(sl, STLINK_REG_CM3_CPUID, &cpu_id))
cpu_id = 0;

// If the chip is an H7, read the chipid from the new address
if (sl->core_id == STM32H7_CORE_ID && cpu_id == STLINK_REG_CMx_CPUID_CM7) {
// STM32H7 chipid in 0x5c001000 (RM0433 pg3189)
ret = stlink_read_debug32(sl, 0x5c001000, chip_id);
} else {
// default chipid address
ret = stlink_read_debug32(sl, 0xE0042000, chip_id);
}

if (ret == -1) {
return(ret);
}

if (*chip_id == 0) {
// STM32H7 chipid in 0x5c001000 (RM0433 pg3189)
ret = stlink_read_debug32(sl, 0x5c001000, chip_id);
// default chipid address
ret = stlink_read_debug32(sl, 0xE0042000, chip_id);
}

if (*chip_id == 0) {
Nightwalker-87 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
5 changes: 5 additions & 0 deletions src/stlink-lib/reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

#define STLINK_REG_CM3_CPUID 0xE000ED00

#define STLINK_REG_CMx_CPUID_CM0 0x410CC200
#define STLINK_REG_CMx_CPUID_CM3 0x412FC230
#define STLINK_REG_CMx_CPUID_CM7 0x411FC272


#define STLINK_REG_CM3_FP_CTRL 0xE0002000 // Flash Patch Control Register
#define STLINK_REG_CM3_FP_COMPn(n) (0xE0002008 + n*4)
#define STLINK_REG_CM3_FP_CTRL_KEY (1 << 1)
Expand Down