OpenOCD on the Raspberry Pi inside a NumWorks calculator
In my previous post I added a Raspberry Pi Zero inside the calculator. Why not use also it to program/debug the calculator firmware ?
What I have done is basically to follow this adafruit tutorial.
I soldered only SWDIO to Raspberry Pi #24 and SWCLK to Raspberry Pi #25. This seems to be enough, and the reset button of the calculator is not far away if needed.
Using the following OpenOCD script, it is now possible to debug or program the calculator over the air !
source [find interface/raspberrypi-native.cfg]
transport select swd
bcm2835gpio_swd_nums 25 24
adapter_khz 1000
set CHIPNAME stm32f412
source [find target/stm32f4x.cfg]
In order for the Raspberry Pi to always stay powered, I added a small switch found in my junk pile:
Example session, OpenOCD side :
Open On-Chip Debugger 0.10.0+dev-00319-g8f1f912a (2018-03-04-23:37)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO config: tck = 11, tms = 25, tdi = 10, tdo = 9
BCM2835 GPIO nums: swclk = 11, swdio = 25
BCM2835 GPIO nums: swclk = 25, swdio = 24
adapter speed: 1000 kHz
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : JTAG and SWD modes enabled
Info : clock speed 2030 kHz
Info : SWD DPIDR 0x2ba01477
Info : stm32f412.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Example session, gdb side :
(gdb) file epsilon.elf
Reading symbols from epsilon.elf...done.
(gdb) target extended-remote raspberrypi:3333
Remote debugging using raspberrypi:3333
0x0800d912 in Ion::msleep (ms=ms@entry=10) at ion/src/device/device.cpp:27
27 for (volatile long i=0; i<8852*ms; i++) {