andreas.se
Posts: 1
Joined: Sat Oct 12, 2019 10:29 am

RPi4 changes - JTAG, UART and OpenOCD not working

Sat Oct 12, 2019 11:07 am

Hi all,

The main problem we are facing is that the Raspberry Pi 4 seems to have a different way of configuring and using JTAG and UART than the Raspberry Pi versions before. When succeeding in configuring JTAG using Videocore boot configurations, it is still not possible to use OpenOCD for some unclear reason. And thus it is very hard and tedious to debug the UART problem. Maybe somebody has already a running OpenOCD setup and can share this or knows how to deal with these problems.

Let's start with a bit background of how we started out. When we are working with the Raspberry Pi 3, it is possible to boot up simple bare metal code to set up the GPIO pins for the alternate functions UART TX and RX and JTAG in a standard way. We combined code from different sources and adjusted it a bit and it works well for what we need. The code we use is this: https://github.com/kth-step/EmbExp-Box_ ... -jtag-boot.
(It is probably the same with the versions before, modulo the different peripheral base addresses, but we did not try this approach on a previous version.)

Now we first looked at existing bare metal code bases that work with RPi4 so that we don't miss some basic configuration that we are not aware of. We tried with this one for example and out RPi4 blinks the LED as this code suggests: https://github.com/BrianSidebotham/arm- ... -2/armc-09

After getting a stable boot environment from this code, we added code to setup the UART and JTAG pins accordingly and also (later) took into account the new way of configuring pull-up/down resistors and used code from this repository for the job: https://github.com/RPi-Distro/raspi-gpio

At this point, OpenOCD could still not connect to the ARMv8 cores. In fact, it could even not even detect a JTAG chain. So we digged more and finally found this blogpost which uses the Videocore boot config.txt to enable JTAG (enable_jtag_gpio=1) and a comment refers to the correct core addresses: https://metebalci.com/blog/bare-metal-r ... i-3b-jtag/

Now OpenOCD can connect but it shows "Mode: Failed" when a core is halted and it behaves weirdly. When disconnecting and reconnecting OpenOCD at this point, it does not connect properly again until the board is rebooted. This also indicates that something is wrong. When looking and more verbose OpenOCD outputs, it comes clear that the debug interface's response to a halt command is already uncomplete or similar.

Our questions are the following:
  • Did somebody already use gdb to debug the Raspberry Pi 4 over JTAG? Or with properly working OpenOCD? If yes, how? This would resolve half of the issue I guess. :)
  • What is different about RPi4 when it comes to enabling JTAG such that it requires intervention of the videocore? Are we missing something?
  • Did somebody get one of the UARTs to talk by using bare metal code on RPi4? If yes, how?
  • Does the RPi4 miss the mini UART identified as UART1? Are now all UARTs in the system of type PL011 like UART0 used to be? Or are we just missing a setup step similar to JTAG before?
Best Regards.

Return to “Bare metal, Assembly language”