forked from auracaster/openocd
jtag/ch347: Refine driver and configs for EasyDevKits adapters
This commit improves support for CH347-based JTAG adapters: - configure.ac: removed "Mode3" restriction (CH347F does not require mode). - configs: added board config for ESP32-WROVER-E WCH JTAG DevKit and ESP32-WROVER-E FTDI JTAG DevKit - ch347 driver: removed `ch347 activity_led` command; activity LED is now controlled via the generic `adapter gpio led` command. - doc/openocd.texi: updated documentation accordingly. Change-Id: I5524290297adcc004e00af919181868d2b6303af Signed-off-by: EasyDevKits <info@easydevkits.com> Reviewed-on: https://review.openocd.org/c/openocd/+/9015 Reviewed-by: zapb <dev@zapb.de> Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
8b43a967e5
commit
5fa74d4ee8
@@ -129,7 +129,7 @@ m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
|
||||
|
||||
m4_define([USB1_ADAPTERS],
|
||||
[[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
|
||||
[[ch347], [Mode 3 of CH347 based devices], [CH347]],
|
||||
[[ch347], [CH347 based devices], [CH347]],
|
||||
[[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]],
|
||||
[[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
|
||||
[[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
|
||||
|
||||
@@ -2590,6 +2590,9 @@ mitigates the problem.
|
||||
@end itemize
|
||||
@end itemize
|
||||
|
||||
The driver supports activity LED through the generic
|
||||
command @ref{adapter gpio, @command{adapter gpio led}}.
|
||||
|
||||
This driver has these driver-specific command:
|
||||
|
||||
@deffn {Config Command} {ch347 vid_pid} [vid pid]+
|
||||
@@ -2609,17 +2612,6 @@ and product ID will be connected.
|
||||
ch347 device_desc "EasyDevKit"
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn {Config Command} {ch347 activity_led} [n]gpio_number
|
||||
If specified the drive let an activity LED blink during JTAG operations.
|
||||
The number is the GPIO number of the CH347T chip. If prefixed with "n",
|
||||
then this GPIO should be low active. The example configures GPIO4 as
|
||||
low active activity LED. For the CH347T chip only GPIO3 (Pin11 / SCL),
|
||||
GPIO4 (Pin15 / ACT), GPIO5 (Pin9 / TRST) and GPIO6 (Pin2 / CTS1) are possible.
|
||||
@example
|
||||
ch347 activity_led n4
|
||||
@end example
|
||||
@end deffn
|
||||
@end deffn
|
||||
|
||||
@deffn {Interface Driver} {cmsis-dap}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <jtag/interface.h>
|
||||
#include <jtag/commands.h>
|
||||
#include <jtag/swd.h>
|
||||
#include <jtag/adapter.h>
|
||||
#include <helper/time_support.h>
|
||||
#include <helper/replacements.h>
|
||||
#include <helper/list.h>
|
||||
@@ -1805,32 +1806,6 @@ COMMAND_HANDLER(ch347_handle_device_desc_command)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The command handler for configuring which GPIO pin is used as activity LED
|
||||
*
|
||||
* @return ERROR_OK at success; ERROR_COMMAND_SYNTAX_ERROR otherwise
|
||||
*/
|
||||
COMMAND_HANDLER(ch347_handle_activity_led_command)
|
||||
{
|
||||
if (CMD_ARGC != 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
uint8_t gpio;
|
||||
if (CMD_ARGV[0][0] == 'n') {
|
||||
COMMAND_PARSE_NUMBER(u8, &CMD_ARGV[0][1], gpio);
|
||||
ch347_activity_led_active_high = false;
|
||||
} else {
|
||||
COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], gpio);
|
||||
ch347_activity_led_active_high = true;
|
||||
}
|
||||
|
||||
if (gpio >= GPIO_CNT || (BIT(gpio) & USEABLE_GPIOS) == 0)
|
||||
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||
|
||||
ch347_activity_led_gpio_pin = gpio;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static const struct command_registration ch347_subcommand_handlers[] = {
|
||||
{
|
||||
.name = "vid_pid",
|
||||
@@ -1846,13 +1821,6 @@ static const struct command_registration ch347_subcommand_handlers[] = {
|
||||
.help = "set the USB device description of the CH347 device",
|
||||
.usage = "description_string",
|
||||
},
|
||||
{
|
||||
.name = "activity_led",
|
||||
.handler = &ch347_handle_activity_led_command,
|
||||
.mode = COMMAND_CONFIG,
|
||||
.help = "if set this CH347 GPIO pin is the JTAG activity LED; start with n for active low output",
|
||||
.usage = "[n]gpio_number",
|
||||
},
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
@@ -1867,6 +1835,25 @@ static const struct command_registration ch347_command_handlers[] = {
|
||||
COMMAND_REGISTRATION_DONE
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Configure which GPIO pin is used as the activity LED.
|
||||
*
|
||||
* Updates the global activity LED GPIO pin and polarity settings
|
||||
* based on the provided configuration. If the given GPIO is not
|
||||
* usable, the function returns without making changes.
|
||||
*
|
||||
* @param led_config Pointer to the GPIO configuration structure for the LED pin
|
||||
*/
|
||||
static void ch347_configure_activity_led(const struct adapter_gpio_config *led_config)
|
||||
{
|
||||
uint8_t gpio = led_config->gpio_num;
|
||||
if (gpio >= GPIO_CNT || (BIT(gpio) & USEABLE_GPIOS) == 0)
|
||||
return;
|
||||
|
||||
ch347_activity_led_gpio_pin = gpio;
|
||||
ch347_activity_led_active_high = !led_config->active_low;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CH347 Initialization function
|
||||
*
|
||||
@@ -1893,6 +1880,8 @@ static int ch347_init(void)
|
||||
|
||||
ch347.pack_size = UNSET;
|
||||
|
||||
ch347_configure_activity_led(&adapter_gpio_get_config()[ADAPTER_GPIO_IDX_LED]);
|
||||
|
||||
if (!swd_mode) {
|
||||
tap_set_state(TAP_RESET);
|
||||
} else {
|
||||
|
||||
37
tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg
Normal file
37
tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg
Normal file
@@ -0,0 +1,37 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Example OpenOCD configuration file for the EasyDevKits ESP32-WROVER-E FTDI JTAG DevKit.
|
||||
#
|
||||
# For example, OpenOCD can be started for ESP32 debugging on
|
||||
#
|
||||
# openocd -f board/esp32-wrover-e-ftdi-jtag-devkit.cfg
|
||||
#
|
||||
|
||||
# Select the FTDI JTAG driver
|
||||
adapter driver ftdi
|
||||
|
||||
# Identify the device
|
||||
ftdi device_desc "EasyDevKit"
|
||||
ftdi vid_pid 0x0403 0x6010
|
||||
# interface 0 is JTAG; interface 1 is the uart
|
||||
ftdi channel 0
|
||||
|
||||
# TCK, TDI, TDO, TMS: ADBUS0-3
|
||||
# activity LED: ADBUS4
|
||||
ftdi layout_init 0x0008 0x001b
|
||||
ftdi layout_signal LED -data 0x0010
|
||||
|
||||
# Source the ESP32 configuration file
|
||||
source [find target/esp32.cfg]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# JTAG speed (in kHz)
|
||||
#
|
||||
# If you encounter DSR/DIR errors that are not caused by OpenOCD
|
||||
# attempting to read unmapped memory regions, try lowering this value.
|
||||
#
|
||||
# Recommended settings for EasyDevKits:
|
||||
# - Do not exceed 20 MHz.
|
||||
# - Best results are typically achieved at 20 MHz.
|
||||
# ---------------------------------------------------------------------------
|
||||
adapter speed 20000
|
||||
37
tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg
Normal file
37
tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg
Normal file
@@ -0,0 +1,37 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Example OpenOCD configuration file for the EasyDevKits ESP32-WROVER-E WCH JTAG DevKit.
|
||||
#
|
||||
# For example, OpenOCD can be started for ESP32 debugging on
|
||||
#
|
||||
# openocd -f board/esp32-wrover-e-wch-jtag-devkit.cfg
|
||||
#
|
||||
|
||||
# Select the CH347 JTAG driver
|
||||
adapter driver ch347
|
||||
|
||||
# Identify the device
|
||||
ch347 device_desc "EasyDevKit"
|
||||
ch347 vid_pid 0x1a86 0x55dd
|
||||
|
||||
# Configure activity LED
|
||||
# Note: The LED is active-low on GPIO4.
|
||||
adapter gpio led 4 -active-low
|
||||
|
||||
# Source the ESP32 configuration file
|
||||
source [find target/esp32.cfg]
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# JTAG speed (in kHz)
|
||||
#
|
||||
# If you encounter DSR/DIR errors that are not caused by OpenOCD
|
||||
# attempting to read unmapped memory regions, try lowering this value.
|
||||
#
|
||||
# Recommended settings for EasyDevKits:
|
||||
# - Do not exceed 30 MHz.
|
||||
# - Best results are typically achieved at 15 MHz.
|
||||
#
|
||||
# Supported frequencies (kHz):
|
||||
# 469, 938, 1875, 3750, 7500, 15000, 30000, 60000
|
||||
# ---------------------------------------------------------------------------
|
||||
adapter speed 15000
|
||||
Reference in New Issue
Block a user