Setting up ESP8266 for sample-based profiling and debugging

Written 2020-02-22

Tags:Espressif Xtensa ESP8266 

This weekend I finally got my ESP8266 working with OpenOCD's JTAG sample-based profiling. There were four problems, one with the Arduino Core, two with OpenOCD, and a similar bottleneck to ESP32.

First, the Arduino Core defaults all GPIO-capable pins into GPIO inputs. This very quickly disables the JTAG pins. The solution is simply:

pinMode(12,FUNCTION_0);//TDI
pinMode(13,FUNCTION_0);//TCK
pinMode(14,FUNCTION_0);//TMS
pinMode(15,FUNCTION_0);//TDO

Next, OpenOCD's reg command was returning no registers, because they were marked as exist=false. Also OpenOCD's profiler looks for a register, PC, but the ESP8266 only implemented pc, and OpenOCD's profiler is case-sensitive.

This is fixed in my OpenOCD port.