Skip to content

Conversation

@maxd-nordic
Copy link
Contributor

No description provided.

@maxd-nordic maxd-nordic changed the title Pull in CMSIS-DAP support from upstream Zephyr WIP: Pull in CMSIS-DAP support from upstream Zephyr Jun 17, 2024
@maxd-nordic maxd-nordic changed the title WIP: Pull in CMSIS-DAP support from upstream Zephyr Pull in CMSIS-DAP support from upstream Zephyr Jun 17, 2024
Copy link
Contributor

Choose a reason for hiding this comment

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

HAL should be used here, and in code below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is from upstream zephyr - it's not the right place to change it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be fixed in a follow-up PR in upstream, that would be cherry-picked as fromlist to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masz-nordic Could you give me some pointers on how to do that? nrf_gpio_cfg uses quite a few more cycles then just setting the PIN_CNF register directly. Speed is of utmost importance for this part.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you post disassembly here? Is nrf_gpio_pin_port_decode not getting optimized enough?
We can add new functions if needed.

#if defined(CONFIG_SOC_SERIES_NRF52X) || defined(CONFIG_SOC_SERIES_NRF53X)
NRF_GPIO_Type * reg = base;

reg->OUTSET = BIT(pin);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with nrf_gpio_port_out_set

#if defined(CONFIG_SOC_SERIES_NRF52X) || defined(CONFIG_SOC_SERIES_NRF53X)
NRF_GPIO_Type * reg = base;

reg->OUTCLR = BIT(pin);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be replaced with nrf_gpio_port_out_clear

#if defined(CONFIG_SOC_SERIES_NRF52X) || defined(CONFIG_SOC_SERIES_NRF53X)
NRF_GPIO_Type * reg = base;

return ((reg->IN >> pin) & 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

nrf_gpio_pin_read

@anangl anangl requested review from a team, carlescufi, de-nordic and nordic-krch as code owners July 3, 2024 09:06
@de-nordic de-nordic removed their request for review July 12, 2024 20:11
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Aug 10, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@tmon-nordic
Copy link
Contributor

Is this going to be obsolete by upmerge?

jfischer-no and others added 17 commits September 20, 2024 15:03
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]>
(cherry picked from commit 3cf630f)
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]>
(cherry picked from commit 7c9259a)
This also fixes a bug where the packet size returned was only 17 byte.

Signed-off-by: Johan Carlsson <[email protected]>
(cherry picked from commit e46e723)
If a host client crashes or fails to disconnect, the probe will
hang. Allow a new connection without raising errors.

Signed-off-by: Johan Carlsson <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit f5ccc3c)
Move low-level GPIO functions to a separate file and use GPIO driver
API if low-level GPIO support is not available for the platform.
Allows alternative pin configuration using only two pins, clk and dio.
Improve binding description.

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit 3ef2c66)
Add API to read count bits from SWDIO into data LSB first.

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit 3e8f9fb)
Implement wait for SWJ pins command.

Signed-off-by: Maximilian Deubel <[email protected]>
(cherry picked from commit 6522dd7)
Add support for DAP_INFO string elements.

Signed-off-by: Maximilian Deubel <[email protected]>
(cherry picked from commit 58d9d88)
Add ID_DAP_UART_* command definitions and react properly to
unsupported UART commands.

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit e31cdc0)
DAP SWD sequence command is a requirement to support CMSIS-DAPv2.
Raise supported version to "2.1.0".

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit 9a9afb0)
…rface

Add CMSIS DAP sample using USB as interface.

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit 94f48c7)
Use k_timepoint_t for timeout handling in the swj_pins function.

Signed-off-by: Maximilian Deubel <[email protected]>
(cherry picked from commit 05a45a1)
Hardcode the lookup table for SWDP requests.
This is an optimization to save some space.
Documentation was added to understand the values.

Signed-off-by: Maximilian Deubel <[email protected]>
(cherry picked from commit f1b6073)
This patch adds documentation for the SWDP API.

Signed-off-by: Maximilian Deubel <[email protected]>
Signed-off-by: Johann Fischer <[email protected]>
(cherry picked from commit 96112ad)
This patch updates the SWD clock calculation to the latest behavior
of DAPLink.

Upstream PR: zephyrproject-rtos/zephyr#74969

Signed-off-by: Maximilian Deubel <[email protected]>
Since CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC is tied to the slow RTC clock
for the nRF53, use the default SYSCLK of 64MHz instead.

Upstream PR: zephyrproject-rtos/zephyr#74969

Signed-off-by: Maximilian Deubel <[email protected]>
This patch changes GPIO initialization
to be in PORT_OFF state by default.
Also, if no transceiver is attached to the signals,
the GPIOs are configured to be disconnected to preserve power.

I tested this on a prototype board where we are going to have
a debugger in a low-power context.

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

We have a version of this as a patch on hello.nrfcloud/firmware. Since this is upstream, it will reach us eventually.

@maxd-nordic maxd-nordic closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants