tcl/interface: support for Raspberry Pi 5

Make sure raspberrypi-native.cfg cannot be used on RPi5.

Add raspberrypi5-gpiod.cfg which uses linuxgpiod adapter driver.
Issue a warning if PCIe is in power save mode.

While on it, re-format warnings issued from Tcl to look similar
to LOG_WARNING() output.

Change-Id: If19b0350bd5fff83d9a0c65999e33b161fb6957a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/8333
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
This commit is contained in:
Tomas Vanek 2024-06-11 16:40:29 +02:00
parent 67be8188bb
commit ad87fbd1cf
3 changed files with 51 additions and 12 deletions

View File

@ -10,6 +10,12 @@
# Do not forget the GND connection, e.g. pin 20 of the GPIO header.
#
if { [info exists GPIO_CHIP] } {
set _GPIO_CHIP $GPIO_CHIP
} else {
set _GPIO_CHIP 0
}
# GPIO 25 (pin 22) previously used for TMS/SWDIO is pulled-down by default.
# The JTAG/SWD specification requires pull-up at the target board
# for either signal. Connecting the signal pulled-up on the target
@ -19,23 +25,23 @@ echo "Warn : TMS/SWDIO moved to GPIO 8 (pin 24). Check the wiring please!"
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 24 19 21
adapter gpio tck -chip 0 11
adapter gpio tms -chip 0 8
adapter gpio tdi -chip 0 10
adapter gpio tdo -chip 0 9
adapter gpio tck -chip $_GPIO_CHIP 11
adapter gpio tms -chip $_GPIO_CHIP 8
adapter gpio tdi -chip $_GPIO_CHIP 10
adapter gpio tdo -chip $_GPIO_CHIP 9
# Each of the SWD lines need a gpio number set: swclk swdio
# Header pin numbers: 23 24
adapter gpio swclk -chip 0 11
adapter gpio swdio -chip 0 8
adapter gpio swclk -chip $_GPIO_CHIP 11
adapter gpio swdio -chip $_GPIO_CHIP 8
# If you define trst or srst, use appropriate reset_config
# Header pin numbers: TRST - 26, SRST - 18
# adapter gpio trst -chip 0 7
# adapter gpio trst -chip $_GPIO_CHIP 7
# reset_config trst_only
# adapter gpio srst -chip 0 24
# adapter gpio srst -chip $_GPIO_CHIP 24
# reset_config srst_only srst_push_pull
# or if you have both connected,

View File

@ -37,9 +37,9 @@ proc get_max_cpu_clock { default } {
return $clock
}
echo "WARNING: Host CPU clock unknown."
echo "WARNING: Using the highest possible value $default kHz as a safe default."
echo "WARNING: Expect JTAG/SWD clock significantly slower than requested."
echo "Warn : Host CPU clock unknown."
echo "Warn : Using the highest possible value $default kHz as a safe default."
echo "Warn : Expect JTAG/SWD clock significantly slower than requested."
return $default
}
@ -56,9 +56,13 @@ if {[string match *bcm2711* $compat]} {
} elseif {[string match *bcm2835* $compat] || [string match *bcm2708* $compat]} {
set clocks_per_timing_loop 6
set speed_offset 32
} elseif {[string match *bcm2712* $compat]} {
echo "Error: Raspberrypi Pi 5 has moved GPIOs to PCIe connected RP1 chip."
echo "Error: Native GPIO handling is not supported, use 'raspberrypi5-gpiod.cfg'"
shutdown
} else {
set speed_offset 32
echo "WARNING: Unknown type of the host SoC. Expect JTAG/SWD clock slower than requested."
echo "Warn : Unknown type of the host SoC. Expect JTAG/SWD clock slower than requested."
}
set clock [get_max_cpu_clock 2000000]

View File

@ -0,0 +1,29 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Config for Raspberry Pi 5 used as a bitbang adapter.
# https://www.raspberrypi.com/documentation/computers/raspberry-pi.html
# Raspberry Pi 5 is not compatible with bcm2835gpio native GPIO driver.
# The linuxgpiod driver without configurable adapter speed runs at approximately
# 800 kHz (SWD writes) and 360 kHz (SWD reads)
adapter driver linuxgpiod
proc read_file { name } {
if {[catch {open $name r} fd]} {
return ""
}
set result [read $fd]
close $fd
return $result
}
set pcie_aspm [read_file /sys/module/pcie_aspm/parameters/policy]
# escaping [ ] characters in string match pattern does not work in Jim-Tcl
if {![string match "*<performance>*" [string map { "\[" < "\]" > } $pcie_aspm]]} {
echo "Warn : Switch PCIe power saving off or the first couple of pulses gets clocked as fast as 20 MHz"
echo "Warn : Issue 'echo performance | sudo tee /sys/module/pcie_aspm/parameters/policy'"
}
set GPIO_CHIP 4
source [find interface/raspberrypi-gpio-connector.cfg]