Skip to content

Commit

Permalink
Implemented CMSIS-DAP v2 support on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ataradov committed Jan 14, 2024
1 parent 70bf056 commit e5b6b1e
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 155 deletions.
8 changes: 4 additions & 4 deletions dap.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2013-2022, Alex Taradov <[email protected]>. All rights reserved.
// Copyright (c) 2013-2024, Alex Taradov <[email protected]>. All rights reserved.

/*- Includes ----------------------------------------------------------------*/
#include <stdio.h>
Expand Down Expand Up @@ -682,7 +682,7 @@ static void append_word(uint32_t value)
//-----------------------------------------------------------------------------
static bool buffer_request(dap_request_t *req)
{
int packet_size = dbg_get_report_size();
int packet_size = dbg_get_packet_size();
int buf_size, ops_size, response_size, address_inc;
uint32_t address, csw;
bool set_address;
Expand Down Expand Up @@ -1046,7 +1046,7 @@ void dap_jtag_flush(void)
tdo_count = 0;
req_count = 0;
req_size = 2; // Command and Count
remaining = dbg_get_report_size() - req_size - 1;
remaining = dbg_get_packet_size() - req_size - 1;

while (index < dap_jtag_request_count)
{
Expand Down Expand Up @@ -1107,7 +1107,7 @@ void dap_jtag_flush(void)
tdo_count = 0;
req_count = 0;
req_size = 2; // Command and Count
remaining = dbg_get_report_size() - req_size - 1;
remaining = dbg_get_packet_size() - req_size - 1;
}
}

Expand Down
25 changes: 21 additions & 4 deletions dbg.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2013-2022, Alex Taradov <[email protected]>. All rights reserved.
// Copyright (c) 2013-2024, Alex Taradov <[email protected]>. All rights reserved.

#ifndef _DBG_H_
#define _DBG_H_

/*- Includes ----------------------------------------------------------------*/
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

/*- Definitions -------------------------------------------------------------*/
#define DBG_MAX_EP_SIZE 1024
#define DBG_MAX_EP_SIZE 1024

#define DBG_CMSIS_DAP_V1 (1 << 1)
#define DBG_CMSIS_DAP_V2 (1 << 2)

/*- Types -------------------------------------------------------------------*/
typedef struct
Expand All @@ -21,13 +25,26 @@ typedef struct
char *product;
int vid;
int pid;

int versions;
bool use_v2;

int v1_interface;
int v1_ep_size;
int v1_tx_ep;
int v1_rx_ep;

int v2_interface;
int v2_ep_size;
int v2_tx_ep;
int v2_rx_ep;
} debugger_t;

/*- Prototypes --------------------------------------------------------------*/
int dbg_enumerate(debugger_t *debuggers, int size);
void dbg_open(debugger_t *debugger);
void dbg_open(debugger_t *debugger, int version);
void dbg_close(void);
int dbg_get_report_size(void);
int dbg_get_packet_size(void);
int dbg_dap_cmd(uint8_t *data, int resp_size, int req_size);

#endif // _DBG_H_
Expand Down
Loading

0 comments on commit e5b6b1e

Please sign in to comment.