diff options
author | Marc Schink <dev@zapb.de> | 2020-04-26 19:28:15 +0200 |
---|---|---|
committer | Andreas Fritiofson <andreas.fritiofson@gmail.com> | 2020-06-18 10:11:02 +0100 |
commit | 5a79481d3b17c4134a43052cea9a7902bbf0accf (patch) | |
tree | a6966fff7ee7575b1a376f2d00998e5942db4855 /src | |
parent | 11116ef6ad875055a43cf9af1f228991349f2ba1 (diff) | |
download | riscv-openocd-5a79481d3b17c4134a43052cea9a7902bbf0accf.zip riscv-openocd-5a79481d3b17c4134a43052cea9a7902bbf0accf.tar.gz riscv-openocd-5a79481d3b17c4134a43052cea9a7902bbf0accf.tar.bz2 |
target/armv7m_trace: Calculate prescaler for external capture devices
This fixes a regression introduced in "2dc88e1479f29ef0141b05bfcd907ad9a3e2d54c"
Change-Id: I04dc19ed30118a4c499b83732700b2ee0fdb67b6
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5610
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/jtag/drivers/jlink.c | 17 | ||||
-rw-r--r-- | src/target/armv7m_trace.c | 16 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index 80202ed..1baf345 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -1324,18 +1324,16 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol, uint32_t min_freq; uint32_t max_freq; + trace_enabled = enabled; + if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_SWO)) { - LOG_ERROR("Trace capturing is not supported by the device."); - return ERROR_FAIL; - } + if (!enabled) + return ERROR_OK; - if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) { - LOG_ERROR("Selected pin protocol is not supported."); + LOG_ERROR("Trace capturing is not supported by the device."); return ERROR_FAIL; } - trace_enabled = enabled; - ret = jaylink_swo_stop(devh); if (ret != JAYLINK_OK) { @@ -1354,6 +1352,11 @@ static int config_trace(bool enabled, enum tpiu_pin_protocol pin_protocol, return ERROR_OK; } + if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) { + LOG_ERROR("Selected pin protocol is not supported."); + return ERROR_FAIL; + } + buffer_size = calculate_trace_buffer_size(); if (!buffer_size) { diff --git a/src/target/armv7m_trace.c b/src/target/armv7m_trace.c index 853362f..6b368f7 100644 --- a/src/target/armv7m_trace.c +++ b/src/target/armv7m_trace.c @@ -68,6 +68,22 @@ int armv7m_trace_tpiu_config(struct target *target) if (retval != ERROR_OK) return retval; + if (trace_config->config_type == TRACE_CONFIG_TYPE_EXTERNAL) { + prescaler = trace_config->traceclkin_freq / trace_config->trace_freq; + + if (trace_config->traceclkin_freq % trace_config->trace_freq) { + prescaler++; + + int trace_freq = trace_config->traceclkin_freq / prescaler; + LOG_INFO("Can not obtain %u trace port frequency from %u " + "TRACECLKIN frequency, using %u instead", + trace_config->trace_freq, trace_config->traceclkin_freq, + trace_freq); + + trace_config->trace_freq = trace_freq; + } + } + if (!trace_config->trace_freq) { LOG_ERROR("Trace port frequency is 0, can't enable TPIU"); return ERROR_FAIL; |