blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.29k stars 774 forks source link

puya: add support for PY32F002B #2000

Open silbe opened 1 week ago

silbe commented 1 week ago

Detailed description

The PY32F002B series uses different DBGMCU IDCODE values and there does not seem to be a register containing RAM and flash size.

While the procedure for preparing flash access (copying parameters from factory-programmed EPPARAx registers to flash peripheral registers) is the same, the bit allocation inside the registers is slightly different.

The structure and values of the DBGMCU IDCODE register are undocumented but the vendor SDK splits it into DEV_ID and REV_ID fields. We use the DEV_ID fields of the IDCODE values observed on PY32F002AW15U and PY32F002BF15P6 to distinguish between the two families. An internet search shows that at least the PY32F002BW15 uses the same value as the PY32F002BF15P6. The full IDCODE values are retained as comments to make it easier to fix the code later if it turns out the DEV_ID/REV_ID split is incorrect.

Your checklist for this pull request

Closing issues

silbe commented 1 week ago

Rebased on main, fixed style issue shown by clang-format. No functional code changes; test still successful.