OpenOCD Support
While PyOCD is the recommended and default programming interface for PY32F0xx development, OpenOCD is also supported for users who prefer it or have specific workflow requirements.
Files Location
OpenOCD configuration files are located in the tools/openocd/
directory:
openocd.cfg
- OpenOCD configuration file for PY32F0xx microcontrollersopenocd_program.sh
- Shell script for programming with OpenOCDREADME.md
- Documentation for OpenOCD setup
When to Use OpenOCD
Consider using OpenOCD if you:
- Have existing OpenOCD-based workflows
- Need specific OpenOCD features
- Are integrating with tools that expect OpenOCD
- Want to use OpenOCD-specific debugging features
Installation
Linux (Ubuntu/Debian)
sudo apt-get install openocd
macOS
brew install openocd
Windows
Download from the OpenOCD releases page.
Usage
Using the Configuration Files
-
Navigate to the OpenOCD directory:
cd tools/openocd/
-
Run OpenOCD with the provided configuration:
openocd -f openocd.cfg
-
In another terminal, use GDB to load your program:
arm-none-eabi-gdb target/thumbv6m-none-eabi/release/examples/blinky (gdb) target remote localhost:3333 (gdb) load (gdb) continue
Using the Programming Script
The openocd_program.sh
script provides a convenient way to program your device:
./tools/openocd/openocd_program.sh path/to/your/firmware.elf
Default PyOCD Workflow
For most users, we recommend sticking with the default PyOCD workflow:
# Install PyOCD (done automatically with make setup-venv)
pip install pyocd
# Use the simplified Makefile commands
make blinky # Build example
make flash-blinky # Build and flash
Troubleshooting
Connection Issues
If you're having connection problems with OpenOCD:
- Check your debugger connection
- Verify the correct configuration file is being used
- Make sure no other debugging session is active
- Try resetting your development board
Permission Issues (Linux)
You may need to add udev rules for your debugger:
sudo usermod -a -G dialout $USER
sudo udevadm control --reload-rules
sudo udevadm trigger
Log out and log back in for changes to take effect.
Configuration Details
The provided openocd.cfg
is configured specifically for PY32F0xx microcontrollers. If you need to modify it for your specific setup, refer to the OpenOCD documentation for:
- Interface configuration (ST-Link, J-Link, etc.)
- Target-specific settings
- Memory map customization
Switching Back to PyOCD
To switch back to the default PyOCD workflow:
make clean
make flash-blinky # Uses PyOCD by default
The Makefile uses PyOCD by default, so no configuration changes are needed.