blackmagic-debug / blackmagic

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

Nations N32G455 support #989

Open etet100 opened 2 years ago

etet100 commented 2 years ago

Hello. I'm looking for someone who can help me to add support for the Nations N32G455 (https://www.nationstech.com/en/pklmcus/). I was able to program flash memory using (https://github.com/stlink-org/stlink), in STMF1x mode, after creating configuration:

# Device Type: N32G455
# Reference Manual: RM(null)
#
chip_id 0x511
flash_type 2
flash_size_reg 0x1ffff7e0
flash_pagesize 0x800
sram_size 0x20000
bootrom_base 0x1ffff000
bootrom_size 0x4000
option_base 0x1ffff800
option_size 0x12
flags 2

Unfortunatelly, despite spending many ours testing, i wasn't able to start debugging. But my knowledge is very little, and I do everything by trial and error. I'm using hosted blackmagic and stlink v2 clone.

./blackmagic -t result is:

BMP hosted v1.7.1-349-g91a63fe
 for ST-Link V2/3, CMSIS_DAP, JLINK and LIBFTDI/MPSSE
Using 0483:3748 9 STMicroelectronics
 STM32 STLink
STLink firmware version: V2J39S7
Leaving MASS Mode
Running in Test Mode
Target voltage: 3.08V Volt
Speed set to  3.6000 MHz for SWD
Leaving MASS Mode
Read Core ID: 0x2ba01477
DPIDR 0x2ba01477 (v1 rev2)
RESET_SEQ failed
AP   0: IDR=24770011 CFG=00000000 BASE=e00ff003 CSW=23000040 (AHB-AP var1 rev2
Halt via DHCSR: success 01030003 after 62ms
ROM: Table BASE=0xe00ff000 SYSMEM=0x00000001, designer 43b Partno 4c4
0 0xe000e000: Generic IP component - Cortex-M4 SCS (System Control Space) (PIDR = 0x04000bb00c  DEVTYPE = 0x00 ARCHID = 0x0000)-> cortexm_probe
CPUID 0x410fc241 (M4 var 0 rev 1)
1 0xe0001000: Generic IP component - Cortex-M3 DWT (Data Watchpoint and Trace) (PIDR = 0x04003bb002  DEVTYPE = 0x00 ARCHID = 0x0000)
2 0xe0002000: Generic IP component - Cortex-M3 FBP (Flash Patch and Breakpoint) (PIDR = 0x04002bb003  DEVTYPE = 0x00 ARCHID = 0x0000)
3 0xe0000000: Generic IP component - Cortex-M3 ITM (Instrumentation Trace Module) (PIDR = 0x04003bb001  DEVTYPE = 0x00 ARCHID = 0x0000)
4 0xe0040000: Debug component - Cortex-M4 TPIU (Trace Port Interface Unit) (PIDR = 0x04000bb9a1  DEVTYPE = 0x11 ARCHID = 0x0000)
5 0xe0041000: Debug component - Cortex-M4 ETM (Embedded Trace) (PIDR = 0x04000bb925  DEVTYPE = 0x13 ARCHID = 0x0000)
ROM: Table END
*** 1 Unknown ARM Cortex-M Designer 43b Partno 4c4 M4
UweBonnes commented 2 years ago

Target/cortexm.c, only probes "Designer 43b Partno 4c3" for STM32 devices. Add a f1probe call or perhaps better a ch32probe call in the "else if (ap->ap_partno == 0x4c4) "branch and in that probe, verify/detect your device and set the values appropriate. See the git log entry when gd32 support was added and get some ideas there.

However the (ap->ap_partno == 0x4c4) branch already causes grieve. Wild probing often results in device hang-up. I think we need a way to give the scan command a hint for the device to look for just in case