|
From: openocd-gerrit <ope...@us...> - 2026-10-19 13:12:32
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 758114a61120c6d615ca37ac2af6a811ea710c9a (commit)
from 17dd961aeaaeddb69dc7a521b5ef0a778fdcf587 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 758114a61120c6d615ca37ac2af6a811ea710c9a
Author: Tomas Vanek <tom...@gm...>
Date: Mon Oct 5 10:36:53 2026 +0200
jtag/drivers/ch347: use next lower adapter speed not higher
If an adapter is not able to set the clock speed exactly as requested
it should behave safely and select the next lower speed.
Rework and simplify the table lookup of speed index.
While on it reduce verbosity when the selected speed is lower
than requested. The selected speed is logged by the adapter
infrastructure.
Change-Id: Iae1d680f57ea3f0837ad4ae84b26a3df5ee384e6
Signed-off-by: Tomas Vanek <tom...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/10087
Tested-by: jenkins
Reviewed-by: Matthias Jentsch <in...@ea...>
Reviewed-by: Paulius Zaleckas <pau...@gm...>
diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c
index 34c065b7a..f505d1569 100644
--- a/src/jtag/drivers/ch347.c
+++ b/src/jtag/drivers/ch347.c
@@ -1967,23 +1967,13 @@ static int ch347_speed_get_index(int khz, int *speed_idx)
ch347_standard_pack_clock_speeds : ch347_larger_pack_clock_speeds;
int length = ch347.pack_size == STANDARD_PACK ?
ARRAY_SIZE(ch347_standard_pack_clock_speeds) : ARRAY_SIZE(ch347_larger_pack_clock_speeds);
- int idx = -1;
- int lower_bound = 0;
// find the suitable speed index
- for (int i = 0; i < length; i++) {
- if (khz >= lower_bound && khz <= speeds[i]) {
- idx = i;
- break;
- }
- lower_bound = speeds[i];
- }
- // too high! => use max possible speed
- if (idx == -1) {
- LOG_INFO("Speed %d kHz is higher than highest speed of %d kHz. Using %d khz!",
- khz, speeds[length - 1], speeds[length - 1]);
- idx = length - 1;
- } else if (speeds[idx] != khz) {
- LOG_INFO("Requested speed of %d kHz is not possible. Using the next higher speed of %d kHz!",
+ int idx = length - 1;
+ while (idx > 0 && speeds[idx] > khz)
+ idx--;
+
+ if (speeds[idx] > khz) {
+ LOG_WARNING("Requested speed of %d kHz is not possible. Using %d kHz",
khz, speeds[idx]);
}
*speed_idx = idx;
-----------------------------------------------------------------------
Summary of changes:
src/jtag/drivers/ch347.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|