Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change OpenOCD option "adapter_khz" to "adapter speed" & resolve conflict on setting speed. #917

Closed
brianredbeard opened this issue Sep 17, 2022 · 1 comment

Comments

@brianredbeard
Copy link

While reviewing the debug console output I noticed a number of problems related to setting the speed of debugging adapters:

  1. Supposedly, in Make adapter_speed changable in platformio.ini #459, a change was made to support making the adapter speed configurable through the file platformio.ini
  2. There are multiple code paths attempting to manage the adapter speed and ultimately stomping on each other.
  3. One of those code paths is using the deprecated OpenOCD option adapter_khz instead of adapter speed

Below are relevant logs:

Reading symbols from /home/user/Projects/hardware/simian/.pio/build/s3d/firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = esp-builtin
PlatformIO: Initializing remote target...
Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
adapter speed: 40000 kHz

Warn : Transport "jtag" was already selected
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : esp_usb_jtag: serial (7C:DF:A1:E7:D7:10)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 5000 kHz
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : starting gdb server for esp32s3.cpu0 on pipe
Info : accepting 'gdb' connection from pipe

A quick grep of the code base shows two locations where adapter_khz is still used in this repository, which explains where the value "5000" is coming from.

$ grep -Rin adapter_khz *
builder/main.py:439:            "adapter_khz %s" % env.GetProjectOption("debug_speed", "5000"),
platform.py:253:                ["-c", "adapter_khz %s" % (debug_config.speed or "5000")]

Additionally, the population of the value "40000" is handled in the interface definitions for esp_usb_jtag and esp_usb_bridge in the espressif/openocd-esp32 repository:

@valeros
Copy link
Member

valeros commented Sep 27, 2022

Hi @brianredbeard, thanks for reaching out.

There are multiple code paths attempting to manage the adapter speed and ultimately stomping on each other.

This is by design; even though the code in platform.py and code in builder/main.py happen to contain similar options, they are responsible for different things. The code in builder/main.py is solely responsible for uploading firmware via debug tools, it may not even be called when a debug session is launched.

One of those code paths is using the deprecated OpenOCD option adapter_khz instead of adapter speed

Fixed in the dev branch.

Additionally, the population of the value "40000" is handled in the interface definitions for esp_usb_jtag and esp_usb_bridge in the espressif/openocd-esp32 repository:

Unfortunately, that's a shortcoming when you have a zoo of debug probes and try to configure them in a similar way. Some of the debug probes require this option while others set it by default. In a nutshell, we needed a speed value that could be a common denominator, so that each supported debug probe will work out of the box. If you need the full speed, just adjust the value using the debug_speed option.

@valeros valeros closed this as completed Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants