Skip to content

stm32l1: Use DBGMCU_IDCODE for part detection#2177

Open
anonymous0719 wants to merge 1 commit intoblackmagic-debug:mainfrom
anonymous0719:blackmagic-pr1
Open

stm32l1: Use DBGMCU_IDCODE for part detection#2177
anonymous0719 wants to merge 1 commit intoblackmagic-debug:mainfrom
anonymous0719:blackmagic-pr1

Conversation

@anonymous0719
Copy link

Otherwise STM32L152RC on stm32l152c-discovery is recognized with only 4k

Detailed description

This PR fixes incorrect device identification on the stm32l152c-discovery board.

Currently, STM32L152RC may be detected with an incorrect part_id, which leads to it being recognized with only 4k, causing the wrong memory layout/flash sizing to be used.

The fix is to populate target->part_id by reading the MCU's DBGMCU_IDCODE register (masked to the device ID field), instead of relying on ap->partno. This provides a more reliable and accurate identification for STM32L1 devices. I don’t have the stm32l152c-discovery board available to test locally, but the change is minimal and matches the downstream fix.


Also as some context: we’ve been developing a tool that scans downstream forks to find valuable commits that haven’t been merged back upstream, and your repo was one of the best examples we found. This commit stood out as a small but important fix, so we manually reviewed it and are submitting it here as a PR in case it’s useful for the upstream project.

If you feel this change is not desired or there’s a better upstream approach, we’d really appreciate any suggestions — both for this patch and for improving our tool’s filtering logic. Thanks for your review!

Your checklist for this pull request

Otherwise STM32L152RC on stm32l152c-discovery is recognized with only 4k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants