Hello,
I'm thinking of trying to access the ESP32 in the uBlox NINA module on a MKR WIFI 1010 via JTAG; has anyone been successful at doing this?
I can foresee one hardware issue, and I'd appreciate your thoughts on a possible solution.
The issue is that the needed JTAG signal TDI on GPIO12/pin 36 is used by the S2 SPI as MOSI.
But I think that I can make hardware and software mods to free this signal for TDI.
Hardware:
- Cut the net between NINA:GPIO12/pin 36 and SAMD:PA12_S2_TX_MOSI/pin 21.
- Cut the net between NINA:GPIO19/pin 21 and SAMD:PA14_S2_RTS_CS/pin23.
- Jumper NINA:GPIO19/pin 21 to SAMD:PA12_S2_TX_MOSI/pin 21.
So what this will do is remove the MOSI signal from NINA:GPIO12 and allow it to be used exclusively as JTAG TDI. And the MOSI signal from the SAM will now be applied to the NINA via GPIO19. The other JTAG signals can be isolated via the removal of jumpers.
Software:
The ESP32 will need to be changed to take the MOSI from GPIO19 rather than GPIO12. The change to SPIS.CPP is:
// SPISClass SPIS(VSPI_HOST, 1, 12, 23, 18, 5, 33);
SPISClass SPIS(VSPI_HOST, 1, 19, 23, 18, 5, 33); // DDW Free-up GPIO12 for JTAG TDI
The above change does not make use of the GPIO pin remapper so there shouldn't be a speed penalty.
And since GPIO19 had been used as the USART 0 hardware flow control, we may need to disable this mechanism. In the sketch.ino.cpp:
uart_set_hw_flow_ctrl((uart_port_t) CONFIG_CONSOLE_UART_NUM, UART_HW_FLOWCTRL_DISABLE, 0); // DDW
It's possible that the ESP32 primary bootloader may make use of this flow control mechanism before the primary WIFI gets control, so it may be necessary for the SAMD to assert this net low during the initial boot of the ESP32. But the SAMD can do this via the MOSI port pin.
The plan is to wire the four JTAG nets to the ESP-PROG interface, and then drive the interface via the debugger provided with the ESP toolset.
The motivation for this exercise is educational, and I'm tired of debugging the ESP32 with printf statements sent to a terminal via an Arduino bridge.
And if this works we might want to suggest to the Arduino developers to try to keep the NINA JTAG pins free in future projects.
And a question about forum etiquette: Should I post this question to the Hardware:MKRWIFI1010 category as well as the Development category? At the moment I've only posted to this Network category as the "rules" for cross-posting weren't clear to me.
Thanks for your thoughts on the matter.
Dale