I've created an OpenOCD fork and added preliminary GD32E50x support in it, in 
the same style GD32E23x support was added: 
https://github.com/openocd-org/openocd/compare/master...CommunityGD32Cores:master
 

The patch detects the microcontroller and its flash banks (64 of it per 
datasheet) correctly, uses the right register addresses for DBG_ID and memory 
density information,  but still has some problems. When the core is halted, the 
microcontroller seems to reset after some while and the connection is 
reestablished. This then happens periodically..

```
Info : SWD DPIDR 0x0be12477
Info : gd32e50x.cpu: Cortex-M33 r0p4 processor detected
Info : gd32e50x.cpu: target has 8 breakpoints, 4 watchpoints
Info : gd32e50x.cpu: external reset detected
Info : starting gdb server for gd32e50x.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'telnet' connection on tcp/4444
target halted due to debug-request, current mode: Thread 
xPSR: 0x29000000 pc: 0x08000ba4 msp: 0x2001ffb8
..
error writing data: (null)
Polling target gd32e50x.cpu failed, trying to reexamine
SWD DPIDR 0x0be12477
gd32e50x.cpu: Cortex-M33 r0p4 processor detected
gd32e50x.cpu: target has 8 breakpoints, 4 watchpoints
```

Maybe someone can take a look at the patch? Previous patches did mention 
something about the watchdog and option bytes offsets being important, I'm not 
sure if they are correct in my patch.


---

** [tickets:#328] Support GD32E50x chips**

**Status:** new
**Milestone:** 0.11.0
**Labels:** gigadevice gd32 gd32e50x 
**Created:** Wed Dec 22, 2021 11:58 PM UTC by Maximilian Gerhardt
**Last Updated:** Wed Dec 22, 2021 11:58 PM UTC
**Owner:** nobody


In recent commits, such as 
[this](https://github.com/openocd-org/openocd/commit/64a3e7ba4f47c5340543d9a5cadd41bc45d93c93)
 or 
[this](https://github.com/openocd-org/openocd/commit/5a0b4889d0d46639b38effd24102f0d5fca1ca31),
 support for microcontrollers made by Gigadevice was expanded (GD32F1x0, 
GD32F3x0, GD32E23x). 

GigaDevice also manufacture the 
[GD32E50x](http://gd32mcu.com/en/download?kw=GD32E5) line of chips, which 
contain a Cortex-M33 core. I've bought a [GD32E350C-START 
board](https://www.aliexpress.com/item/1005003224840104.html) containing an 
GD32E503CET6 microcontroller. 

However, OpenOCD has no flashing support for this microcontroller. I've tried 
various configurations such as the `stm32f4` or `gd32e23x`. The closest one to 
nearly working seems the latter, which does

```
openocd -d2 -s C:\Users\Max\.platformio\packages\tool-openocd-gd32/scripts -f 
interface/cmsis-dap.cfg -c "transport select swd" -c "set CPUTAPID 0" -f 
target/gd32e23x.cfg -c "program {.pio\build\gd32e503c_start\firmware.elf}  
verify reset; shutdown;"
xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2021-12-07-17:33)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

swd
0
Info : CMSIS-DAP: SWD  supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x0be12477
Info : gd32e23x.cpu: Cortex-M33 r0p4 processor detected
Info : gd32e23x.cpu: target has 8 breakpoints, 4 watchpoints
Info : starting gdb server for gd32e23x.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0xf9000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Error: Cannot identify target as a stm32x
Error: auto_probe failed
embedded:startup.tcl:1136: Error: ** Programming Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 1201
at file "embedded:startup.tcl", line 1136
*** [upload] Error 1
```

The only tool capable of flashing is the [vendor GD-Link Programmer 
tool](http://gd32mcu.com/en/download?kw=GigaDevice+GD-Link+Programmer)

```
r>GD_Link_CLI.exe
GD_Link_CLI V1.2.0.10745.
Connected successfully.
SWD ID: 0xBE12477
Target Device: GD32E503CET6, Flash Size: 512KB, SRAM Size: 128KB
Type '?' for help
GD-Link>h
Halt operation completed successfully.
PC(R15) =  EFFFFFFE, MSP =  FFFFFFD8,
R0 =  00000000, R1 =  00000000, R2 =  00000000, R3 =  00000000,
R4 =  00000000, R5 =  00000000, R6 =  00000000, R7 =  00000000,
R8 =  FFFFFFFF, R9 =  FFFFFFFF, R10=  FFFFFFFF, R11=  FFFFFFFF,
R12=  FFFFFFFF, R13=  FFFFFFD8, R14=  FFFFFFB8,
xPSR =  F9000003, PSP =  00000000,
SpecialReg =  00000000,
GD-Link>erase
Erasing GD32E503CET6 ...
Erasing done. Total time needed: 3.188s
GD-Link>loadbin firmware.bin 0x8000000
Loading binary file...[0x08000000]
.
Memory write successfully. Total time needed: 0.859s
```

Please add GD32E50x support to OpenOCD, or let me know what other 
configurations I can use. I'd happy to contribute in any way.

(Note: While GigaDevice has an [openocd 
fork](https://github.com/GigaDevice-Semiconductor/openocd), it does not contain 
support for GD32E50x.)


---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.


Reply via email to