From: Paul Fertser Date: Sat, 9 Oct 2021 20:32:01 +0000 (+0300) Subject: jtag: drivers: bcm2835gpio: don't allow GPIOs > 31 X-Git-Tag: v0.12.0-rc1~455 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=da434d7d5975c1c7ebae8e35eb71b6d2d6ad062e jtag: drivers: bcm2835gpio: don't allow GPIOs > 31 Current code assumes all the GPIO signals are manipulated via a single 32-bit register so using higher GPIOs silently fails. Fix the check instead of trying to handle additional GPIOs (available on Raspberry Pi Compute Modules) as that would slow the driver down. Change-Id: Ib3b5864afb3b972d952f9b74665201cd93924959 Signed-off-by: Paul Fertser Reviewed-on: https://review.openocd.org/c/openocd/+/6658 Tested-by: jenkins Reviewed-by: Antonio Borneo --- diff --git a/doc/openocd.texi b/doc/openocd.texi index cd64c7aecb..01bb4f21d1 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3207,6 +3207,8 @@ able to coexist nicely with both sysfs bitbanging and various peripherals' kernel drivers. The driver restores the previous configuration on exit. +GPIO numbers >= 32 can't be used for performance reasons. + See @file{interface/raspberrypi-native.cfg} for a sample config and pinout. diff --git a/src/jtag/drivers/bcm2835gpio.c b/src/jtag/drivers/bcm2835gpio.c index 95e077c334..fd6c28b964 100644 --- a/src/jtag/drivers/bcm2835gpio.c +++ b/src/jtag/drivers/bcm2835gpio.c @@ -198,7 +198,7 @@ static int bcm2835gpio_speed(int speed) static int is_gpio_valid(int gpio) { - return gpio >= 0 && gpio <= 53; + return gpio >= 0 && gpio <= 31; } COMMAND_HANDLER(bcm2835gpio_handle_jtag_gpionums)