I am trying to program PSoC 4100 family (for testing I also use CY8CKIT-059 PSoC 5LP) over Raspberry Pi 4 model B using OpenOCD. I have never used OpenOCD, so can someone help me understand how I can do that and what I should look out for. Thank you.

  • \$\begingroup\$ Are you trying to interface with the eval board, or directly with the chip, from your raspberry pi? \$\endgroup\$ Commented Apr 25, 2023 at 7:34
  • \$\begingroup\$ Final product directly with the chip, but for the process of learning how to use openocd I use CY8CKIT-059 PSoC 5LP develpment board. \$\endgroup\$
    – Urban
    Commented Apr 25, 2023 at 13:12
  • \$\begingroup\$ ok, so directly to the chip! \$\endgroup\$ Commented Apr 25, 2023 at 13:15
  • 1
    \$\begingroup\$ It may not be an immediate priority but consider giving the openocd manual a read (openocd.org/doc/pdf/openocd.pdf) Even if its a little bit at a time. The sections that affect you are only a fraction of the whole document usually. It is very flexible software and knowing its features will greatly expand your toolbelt as an engineer. I learned the hard way, by getting very frustrated at the thing, and wish I had just read the manual to begin with! \$\endgroup\$ Commented Apr 25, 2023 at 15:12

1 Answer 1


Look inside /usr/share/openocd. Words in italics refer to the subfolders of that:

OpenOCD has so-called board scripts (TCL, of all languages!), which describe how to interface with some hardware. In your case, you'll need to make a board configuration that describes your hardware board's pins and which target it uses.

You want something like


set WORKAREASIZE your_POC_s_RAM_in_Bytes
source [find interface/rpi4.cfg]
source [find target/psoc5lp.cfg]

as you can guess, the first source line loads a script that defines the interface, the second one a script that defines the properties of the target chip and how to use it.

The hard part, the target script, already exists.

The interface does not. Chances are you can just copy the target/raspberrypi-native.cfg and change the peripheral_base address to be correct for the RPi4b's GPIO. (0xFE000000 probably? Don't nail me on that, you need to look that up.)

The speed_coeffs seem wrong for the RPI4's clock rate, you'll have to recompute them (or find someone else's openocd interface script where they did that for you). If in doubt, being slow doesn't hurt, so take maybe a quarter of the first number and 50 as the second number.

The remaining lines (adapter gpio tck -chip …) need to reflect the pads on the chip that you want to connect your JTAG lines to. (note that pad number != pin header pin number, you need to work with the schematic / IO-table here).

After you set all things correctly, openocd -f /path/to/your/myboard.cfg should establish a connection to your chip.

You can then use e.g. gdb to load your ELF image:

openocd -f /path/to/your/myboard.cfg &
$> arm-none-eabi-gdb my_image.elf
(gdb) target extended-remote localhost:3333
(gdb) monitor reset halt # Resets the chip and puts it in halting
(gdb) load # To load the EFI image into RAM, **OR**
(gdb) monitor flash write my_image.elf
  • \$\begingroup\$ This comment was very helpful. It turns out that interface/raspberrypi-native.cfg was good enought. I just had to add "transport select swd" and "adapter speed 500" and it worked. I connected to it via telnet. How can I load my elf file via telnet. \$\endgroup\$
    – Urban
    Commented Apr 26, 2023 at 11:28
  • \$\begingroup\$ I don't know. I wouldn't use telnet, but use gdb, and explain how you do that in the answer. \$\endgroup\$ Commented Apr 26, 2023 at 11:48
  • \$\begingroup\$ I tried to use gdb but it did not work. After command load {my .elf image file} I get a message: " Loading section .cyconfigece, size 0x4c lma 0x80000540 Loading section .cyloadermeta, size 0x40 lma Oxf0000000 Loading section .cyboot loader, size 0x2a00 lma 0x0 Loading section .text, size 0x49e lma 0x2a00 Loading section .eh_frame, size 0x4 lma 0x2ea0 Loading section .rodata, size 0x6c lma 0x2ea4 Loading section .data, size 0x78 lma 0x2f10 Loading section .cyloadablemeta, size 0x40 lma 0x3ffc0 Error finishing flash operation " \$\endgroup\$
    – Urban
    Commented Apr 26, 2023 at 12:20
  • \$\begingroup\$ I don't know what goes wrong there, but I'm pretty sure you wouldn't want to do all these operations manually, and as long as you don't know what goes wrong, you couldn't avoid it by speaking directly to openocd, either. \$\endgroup\$ Commented Apr 26, 2023 at 12:25
  • \$\begingroup\$ After using the second option: monitor flash write_image my_image.elf I got the error message "auto_probe failed" \$\endgroup\$
    – Urban
    Commented Apr 26, 2023 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.