I have modified a Teensy 4.1 to give me access to the JTAG pins on the IMXRT1062, it is connected to a Segger J-Link EDU with the following pins: VTref, GND, TDI,TMS,TCK,TDO.
I am having trouble uploading and debugging using platformio in VSCode. When I try and upload my code it shows the following and just hangs forever.
I am able to upload the hex file to the teensy using Seggers tools with no issues so I’m not quite sure what is wrong. I have tried various config settings with no luck. What is the best way to troubleshoot this?
When I use that platformio.ini, while having no debugger connected at all, JLink will at least complain.
Uploading .pio\build\teensy412\firmware.hex
SEGGER J-Link Commander V6.88b (Compiled Nov 27 2020 15:45:43)
DLL version V6.88b, compiled Nov 27 2020 15:44:11
J-Link Command File read successfully.
Processing script file...
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...FAILED: Cannot connect to J-Link.
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...FAILED: Failed to open DLL
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...FAILED: Failed to open DLL
Script processing completed.
Do you have an antivirus active that might interfere? Does temporarily disabling it change something?
J-Link connection not established yet but required for command.
Connecting to J-Link via USB…O.K.
Firmware: J-Link V11 compiled Nov 12 2020 10:07:08
Hardware version: V11.00
S/N: 261008241
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.309V
Target connection not established yet but required for command.
Device position in JTAG chain (IRPre,DRPre) : -1,-1 => Auto-detect
Second Command
SEGGER J-Link Commander V6.88b (Compiled Nov 27 2020 15:45:43)
DLL version V6.88b, compiled Nov 27 2020 15:44:11
Connecting to J-Link via USB…O.K.
Firmware: J-Link V11 compiled Nov 12 2020 10:07:08
Hardware version: V11.00
S/N: 261008241
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.309V
Device position in JTAG chain (IRPre,DRPre) : -1,-1 => Auto-detect
It seems perfectly fine. Also a note, when I try and upload with platformio it hangs indefinitely unless I click on upload again and tell it to “Terminate Task”
Okay I’ve also noticed that my teensy platform is one version behind the current one, but after updating I still get the update and no hangup, so that should be okay.
This all seems pretty good, the JLink tools can connect to the target. No idea why PlatformIO isn’t even able to call into them though.
As a last test, can you execute
C:\Users\<user>\.platformio\packages\tool-jlink\JLinkGDBServerCL.exe -singlerun -if jtag -select USB -device MIMXRT1062xxxxA -port 2331
and post the output? That should be the command with which the GDB server for debugging is opened.
If no output appears and the VSCode task appears to hang, my only recommendations are
restart VSCode
restart PC
Upgrade PlatformIO to latest core version. In PIO CLI pio upgrade --dev, then restart VSCode
uninstall instead of disable Antivirus. (I’ve had cases with Avast Antivirus where it still interfered although it was being “inactive”)
I have restarted VS code, updated platformio, reinstalled platformio, created a new project which is spaces free. None of these made a difference yet, but I have yet to uninstall virus protection/disable defender.
The custom debug tools almost work. It was able to flash the teensy once but then VS Code jumped to a random arduino lib and the arduino became unstable to where I couldn’t do anything and had to reflash it with JFlash. Not sure if that is a different issue or what.
I appreciate all the help… I’m still trying everything I can.
Well the base error is that PlatformIO doesn’t seem to be able to execute any commands from inside VSCode to the Jlink tools.
When I do “Start Debugging” in VSCode with the above platformio.ini, I do get the JLink output, telling me it failed to start (since no JLink is connected of course)
Please file a bug in Issues · platformio/platform-teensy · GitHub with reference to this thread, I have no idea why this hangs up. The standard platformio.ini from the first post should work.
As an extravangza test one could install VirtualBox + Ubuntu 20 + Guest extensions and test whether it works in that virtual machine, when the USB device is forwarded. But as said, the invocations work for me on my Windows 10 x64 system without problems.
with an upload.jlink file at the root of the project:
r
loadfile .pio\build\teensy41\firmware.hex
r
q
Thanks for helping @maxgerhardt
I’m still not sure what the underlying issue is, I doubt I will look into it much further but if a dev is interested I can work with them to figure it out.
How hard was the mod need to get this working, do you have pictures? I’ve put this off as I did not find any great guides as to the how to do it! hint hint
I have not seen anyone else do it with a Teensy 4/4.1 yet. The Teensy 3s are a bit easier to mod since they had debug pads on the board, but you still needed to remove the same chip. It requires good soldering skills, hot air station, microscope, magnet wire, etc. I am still in the early stages of the modification so it is a mess. I am waiting on a pcb to be made which should make this presentable.
Here are some pics.
The mod requires removing the MKL02Z32VFG4 to access the JTAG pads, connecting those to a J-Link, and reconnecting the chip to the other (non JTAG) pads to keep everything happy… And yes… that is the MKL02Z32VFG4 floating off to the right.
@datkins47 Let me know if you need guidance, if you decide to take it on.
credit due there, just wow! might wait before tackling that, love the teensy 4.1 with ethernet but not sure that’s ready for my solder blobbing skills, you thinking pcb to replace chip?
I designed a flex pcb that will be soldered in place of the chip and extrude out the right side of the board and breakout the pins so they can be jumpered over to the J-Link. It will involve de soldering the M0 chip, soldering the m0 to the flex pcb, and soldering the flex pcb back in place of the M0 on the Teensy. Then you have normal 2.54mm headers to jumper from.
I left the chip in the equation because it is handling a few things besides just programming, without it I believe the processor never starts up a DCDC converter. Also this way you can jumper the pins back to the chip and use it as normal.