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

Pr cmsis dap rebase #2

Conversation

maxd-nordic
Copy link

No description provided.

jfischer-no and others added 7 commits April 19, 2023 00:05
Add Serial Wire Debug Port interface driver API and bit-bang driver.

The driver requires a simple Hardware Interface Circuits (HICs),
where signals CLK, DOUT, DIN, ENn, OE_ENn, RESETn
are connected to board GPIOs and buffered signals SWD_CLK and SWD_DIO
to the target.

Signal OE_ENn controls the direction of the Serial Wire (SWD_DIO),
ENn the buffers SWD_CLK possibly others and enables/disables HIC.

Signed-off-by: Johann Fischer <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
Add CMSIS-DAP compatible controller which is a handler between
the host interface and SWD driver. The controller follows CMSIS-DAP
reference implementation. It expects a request buffer from the host
interface, splits it to simple transfers and forwards to the DP driver,
and finally returns a response buffer to the host.
Interface to the host can be implemented with USB HID device support.

Controller implements only SW-DP support and is tested
with pyOCD and ADIv5.x.

Signed-off-by: Johann Fischer <[email protected]>
Add cmsis dap sample using USB HID as interface.

Signed-off-by: Johann Fischer <[email protected]>
this also fixes a bug where the packet size returned was only 17 byte.

Signed-off-by: Johan Carlsson <[email protected]>
if a host client crashes or does not disconnect probe would
otherwise hang. allow a new connection without raising errors.

Signed-off-by: Johan Carlsson <[email protected]>
removed const from callback to make it easier to handle
request and respose like the other code would.

Signed-off-by: Johan Carlsson <[email protected]>
@@ -17,6 +17,13 @@ config CMSIS_DAP_PACKET_COUNT
help
Maximum packet buffers for request and response data.

config CMSIS_DAP_PACKET_SIZE
int "Maximum packet size for request and response data."
Copy link

@tmon-nordic tmon-nordic Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Kconfig has to be removed because this value is used to set wMaxPacketSize field in CONFIGURATION descriptor.

The endpoints are bulk, therefore the only valid options (Universal Serial Bus Specification Revision 2.0 5.8.3 Bulk Transfer Packet Size Constraints) are:

  • 8, 16, 32 or 64 on Full-Speed device (or High-Speed capable device operating at Full-Speed)
  • 512 on High-Speed device operating at High-Speed

Legacy USB stack (i.e. not device-next) is not really suitable for properly handling High-Speed (the problem is with High-Speed device operating at Full-Speed). The next stack is better on this.

While the 8/16/32/64 max packet size choice can seem arbitrary to the application software, there are cases where the USB device controller does not support all of the options. Due to this is better for the USB stack to handle the endpoint sizes.

For the old stack probably the best that can be done is probably just use 64 for Full-Speed and 512 when CONFIG_USB_DC_HAS_HS_SUPPORT is defined. This will exhibit the problem with High-Speed operating at Full-Speed, but fixing that in legacy stack seems infeasible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be enough to set the default based USB_DC_HAS_HS_SUPPORT and add a help text?
Or do you think the risk of misconfiguration is too high?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be Kconfig at all. There are already way too many Kconfigs that can give you essentially-broken-but-compiling code and this is going to be just another one.

Copy link
Owner

@jfischer-no jfischer-no Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Kconfig option is not exclusive for USB transport. You have to adapt it according to your transport layer needs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the idea was to potentially have DAP over BLE at some point.

@maxd-nordic
Copy link
Author

@jfischer-no We talked about the speed of probes that use zephyr_gpio instead of writing to registers directly.
I just compared erasing+flashing an nRF9160 with both configs and the results are good enough in my opinion: 49,342s (zephyr_gpio), 33,116s (direct register write).

@maxd-nordic
Copy link
Author

Just tested on the Raspberry Pi Pico (rp_2040), which needs the new DAP command I implemented and it works fine!

Comment on lines +27 to +50
config CMSIS_DAP_PROBE_VENDOR
string "Probe vendor"
default "Zephyr"

config CMSIS_DAP_PROBE_NAME
string "Probe name"
default "CMSIS-DAP"

config CMSIS_DAP_BOARD_VENDOR
string "Target board vendor"
default ""

config CMSIS_DAP_BOARD_NAME
string "Target board name"
default ""

config CMSIS_DAP_DEVICE_VENDOR
string "Target device vendor"
default ""

config CMSIS_DAP_DEVICE_NAME
string "Target device name"
default ""

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options are more problematic than others in terms of multi-instance support.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, the cmsis_dap.c part only supports one instance. Maybe we can defer that multi-instance support to a later PR entirely.

subsys/dap/cmsis_dap.c Outdated Show resolved Hide resolved
subsys/dap/cmsis_dap.c Outdated Show resolved Hide resolved
subsys/dap/cmsis_dap.c Show resolved Hide resolved
subsys/dap/cmsis_dap.c Show resolved Hide resolved
drivers/dp/fast_bitbang.h Outdated Show resolved Hide resolved
drivers/dp/swdp_bitbang.c Outdated Show resolved Hide resolved
drivers/dp/fast_bitbang.h Outdated Show resolved Hide resolved
drivers/dp/fast_bitbang.h Outdated Show resolved Hide resolved
drivers/dp/swdp_bitbang.c Outdated Show resolved Hide resolved
@maxd-nordic
Copy link
Author

@jfischer-no thanks for the review! I'll try to fulfill the requests, but it might take a while to separate the commits.

@maxd-nordic maxd-nordic force-pushed the pr-cmsis-dap-rebase branch 8 times, most recently from b079234 to a922397 Compare July 7, 2023 11:53
Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Maximilian Deubel <[email protected]>
This is a requirement for CMSIS-DAPv2

Signed-off-by: Maximilian Deubel <[email protected]>
@maxd-nordic
Copy link
Author

@jfischer-no @tmon-nordic please have another look. I tended to the request where I had an idea to fix. Might need more input if more things need to be fixed.

This patch refactors the usage of MS OS 2.0 descriptors in the
WebUSB sample. The function subset header was removed since it
is not allowed for non-composite devices.
Also, a new random GUID was added for automatic driver installation.

Signed-off-by: Maximilian Deubel <[email protected]>
@maxd-nordic maxd-nordic force-pushed the pr-cmsis-dap-rebase branch 2 times, most recently from 00f8c5b to 7b4e00d Compare August 30, 2023 11:52
@jfischer-no
Copy link
Owner

Applied to upstream PR with significant changes.

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

Successfully merging this pull request may close these issues.

3 participants