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>
This commit is contained in:
Marc Schink 2020-04-26 19:28:15 +02:00 committed by Andreas Fritiofson
parent 11116ef6ad
commit 5a79481d3b
2 changed files with 26 additions and 7 deletions

View File

@ -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)) {
if (!enabled)
return ERROR_OK;
LOG_ERROR("Trace capturing is not supported by the device.");
return ERROR_FAIL;
}
if (pin_protocol != TPIU_PIN_PROTOCOL_ASYNC_UART) {
LOG_ERROR("Selected pin protocol is not supported.");
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) {

View File

@ -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;