OpenOCD with GD32 - Page 1
Forum section: electronics / general

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 26, 2021, 04:03:37 pm
content: HiI'm trying to use OpenOCD with a GD32E230, in Visual Studio Code.This looks like exactly what I need:https://review.openocd.org/c/openocd/+/6543But I cannot get it in any release downloads even the latest master branch build?https://github.com/openocd-org/openocd/releases/tag/latestThank you

author: RoGeorge
author_rank: Super Contributor
timestamp: October 27, 2021, 08:51:51 am
content: It says you should look for a binary at the board seller first.Code:==================Installing OpenOCD==================A Note to OpenOCD Users-----------------------If you would rather be working "with" OpenOCD rather than "on" it, youroperating system or JTAG interface supplier may provide binaries foryou in a convenient-enough package.Such packages may be more stable than git mainline, wherebleeding-edge development takes place. These "Packagers" producebinary releases of OpenOCD after the developers produces new "release"versions of the source code. Previous versions of OpenOCD cannot beused to diagnose problems with the current release, so users areencouraged to keep in contact with their distribution packagemaintainers or interface vendors to ensure suitable upgrades appearregularly.Users of these binary versions of OpenOCD must contact their Packager toask for support or newer versions of the binaries; the OpenOCDdevelopers do not support packages directly.A Note to OpenOCD Packagers---------------------------You are a PACKAGER of OpenOCD if you:- Sell dongles and include pre-built binaries;- Supply tools or IDEs (a development solution integrating OpenOCD);- Build packages (e.g. RPM or DEB files for a GNU/Linux distribution).As a PACKAGER, you will experience first reports of most issues.When you fix those problems for your users, your solution may helpprevent hundreds (if not thousands) of other questions from other users.If something does not work for you, please work to inform the OpenOCDdevelopers know how to improve the system or documentation to avoidfuture problems, and follow-up to help us ensure the issue will be fullyresolved in our future releases.That said, the OpenOCD developers would also like you to follow a fewsuggestions:- Send patches, including config files, upstream, participate in thediscussions;- Enable all the options OpenOCD supports, even those unrelated to yourparticular hardware;- Use "ftdi" interface adapter driver for the FTDI-based devices.

author: thinkfat
author_rank: Unknown
timestamp: October 27, 2021, 10:01:50 am
content: Quote from: simonlasnier on October 26, 2021, 04:03:37 pmThis patch is still under review. It's not in any release and not yet merged into master. You can git-clone the master branch and then cherry-pick this patch individually and rebuild it yourself.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 27, 2021, 10:41:10 am
content: Ok that explains it then.How do you get the git master and add the patch to it?Ok I managed that part, did aCode:git clone https://github.com/openocd-org/openocdand then aCode:git fetch https://review.openocd.org/openocd refs/changes/43/6543/5 && git checkout -b change-6543 FETCH_HEADThat seemed to work.Then how to compile? I am on windows.

author: bson
author_rank: Unknown
timestamp: October 28, 2021, 05:03:42 am
content: Don't know about Windows but on Linux/MacOS you run:./bootstrap./configuremakesudo make installIt doesn't seem to parallel build correctly, so something like "make -j12" won't work.You will likely encounter things missing when running the configure script. Things like libusb. Install and run again. Not sure how this works on Windows.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 28, 2021, 09:30:51 am
content: Gosh it's insane the amount of time necessary to get that bloody thing working.So I've got a compiled OpenOCD with the patch. I am using Visual Studio Code with the cortex-debug extension and the following config:Code:{"name": "CMSIS-DAP OpenOCD","cwd": "${workspaceRoot}","executable": "./debug/gd32-gcc-test.elf","request": "launch","type": "cortex-debug","servertype": "openocd","serverpath": "C:/Program Files/OpenOCD/bin/openocd.exe","configFiles": ["board/gd32e230-start.cfg"],"interface": "swd","device": "GD32E230","svdFile": "GD32E230.svd","runToEntryPoint": "main","armToolchainPath": "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin","preRestartCommands": ["load","continue"]}I get really weird things when GDB starts - the PC is set to 0x2000003a?!Anyways - then I run "load" and "continue" and everything seems fine, the PC goes back to where it should and the hardware automatically stops when it reaches main().I thought the preRestartCommands would run automatically? Not much info about it here:https://github.com/Marus/cortex-debug/wiki/Common-Configuration-Properties

author: bson
author_rank: Unknown
timestamp: October 31, 2021, 11:01:02 pm
content: "load" is for use when working with a non-remote GDB. It attempts to debug an executable locally."file" tells GDB to load a file and use it for symbols, but doesn't affect what's running. This is more useful when attaching to running firmware or a running process locally.I use something like this to flash:monitor reset haltmonitor flash write_image erase build_debug/image 0 elffile build_debug/image"monitor" sends a command to OpenOCD, which does the flashing.Usually when attaching to a running device I'll just halt with "monitor halt". (In fact, I have this in the gdbinit)In your case it seems like you might want something more basic, like:Code:"preRestartCommands": ["monitor halt",]"stop" might also work, but relies on GDB being able to determine the state of the target. If it can't it assumes it's already stopped and a "stop" command won't do anything.

author: uav
author_rank: Newbie
timestamp: April 02, 2024, 09:31:33 am
content: hi, I'm struggling with gd32e230 using gcc under linux,now it can NOT boot at all, could you please share a simple vscode project with gcc,many thanks