pyocd / pyocd/pyOCD

Gdbserver reports "overlapping regions in memory map" to Gdb for stm32l4 Devices

Open
#980 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

When I use pyocd gdbserver --target stm32l432kcux to connect to my nucleo-l432kc board and connect arm-none-eabi-gdb with target extended :3333 afterwards, I get the "warning: Overlapping regions in memory map: ignoring" message. Then, it is impossible to use gdb to flash the device.

The same issue is present on the nucleo-l412-rb-p board but pyocd's gdbserver works flawlessly with an stm32l071kbu mcu which I have available for comparison here. Since pyocd uses DFPs to handle different targets and the stm32 DFPs are organized according to the device families, I suspect that this issue could be present on (all) stm32l4 devices but not on stm32l0 devices, caused by the stm32l4 DFP.

I have skimmed the DFP for the L0 and the L4 families and found memory information in the two .pdsc files. Below, some lines that looked interesting to me:

Keil.STM32L0xx_DFP.pdsc

    <subFamily DsubFamily="STM32L071">
        [...]
        <!-- *************************  Device 'STM32L071KBUx'  ***************************** -->
        <device Dname="STM32L071KBUx">
          <memory id="IROM1"                                   start="0x08000000" size="0x00020000" startup="1" default="1"/>
          <memory id="IRAM1"                                   start="0x20000000" size="0x00005000" init   ="0" default="1"/>
          [...]
        </device>

Keil.STM32L4xx_DFP.pdsc

      <subFamily DsubFamily="STM32L432">
        [...]
        <memory id="IRAM1"                                 start="0x20000000" size="0x0000C000" init="0" default="1"/>
        <memory id="IRAM2"                                 start="0x10000000" size="0x00004000" init="0" default="0"/>
        [...]
        <!-- *************************  Device 'STM32L432KCUx'  ***************************** -->
        <device Dname="STM32L432KCUx">
          <memory name="Main_Flash"  access="rx"   id="IROM1"     start="0x08000000" size="0x00040000" startup="1" default="1"/>
          <memory name="SRAM"        access="rwx"  id="IRAM1"     start="0x20000000" size="0x0000C000" init="0"    default="1"/>
          [...]
        </device>

Apparently, the memory regions are actually defined twice for the L4 family, once in the subFamily tag, once in the device child tag. In the description for the L0 family, this information is not present in the subFamily tag so that the memory regions are only defined once there. So it seems to me that pyocd is merging the memory tags from subFamily and device and forwards this (duplicate) information to gdb when requested.

Since I do not know the specification which the .pdsc files have to adhere to, I do not know if this is a bug in pyocd or in the pack archive for the L4 family (I assume the latter). Anyways, it would be nice if pyocd could only report the memory regions once to gdb so that flashing works successfully afterwards. Maybe, duplicate memory regions could be identified and only kept once? This could, if desired, be accompanied by a warning to the user or it could be done silently, especially if the id fields of the memory tags match like in this case here. This (comparably small?) fix could fix a whole device family.

If there is anything I could do to help with this issue, please let me know. If desired, I would try to fix it myself but I would like to know if such a PR would be welcome or if there are different plans to cope with this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with pyocd gdbserver --target stm32l432kcux and arm-none-eabi-gdb, then inspect how the Keil.STM32L0xx_DFP.pdsc and Keil.STM32L4xx_DFP.pdsc memory entries are processed. Compare the STM32L0 and STM32L4 paths and identify where duplicate regions reach GDB. Done means STM32L4 flashing works without the overlapping-regions warning while STM32L0 behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.