Skip to content

Commit 47d26b9

Browse files
committed
feat(dap): Port swd host
1 parent c579a11 commit 47d26b9

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

components/DAP/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
set(COMPONENT_ADD_INCLUDEDIRS "config include $ENV{IDF_PATH}/components/esp_ringbuf/include/ $ENV{IDF_PATH}/components/")
2-
set(COMPONENT_SRCS "./source/DAP.c ./source/DAP_vendor.c ./source/JTAG_DP.c ./source/SW_DP.c ./source/SWO.c ./source/spi_op.c ./source/spi_switch.c ./source/dap_utility.c")
3-
4-
2+
set(COMPONENT_SRCS
3+
"./source/DAP.c"
4+
"./source/DAP_vendor.c"
5+
"./source/JTAG_DP.c"
6+
"./source/SW_DP.c"
7+
"./source/SWO.c"
8+
"./source/spi_op.c"
9+
"./source/spi_switch.c"
10+
"./source/dap_utility.c"
11+
"./source/swd_host.c")
512

613
register_component()

components/DAP/config/DAP_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ static const char TargetBoardVendor [] = TARGET_BOARD_VENDOR;
213213
static const char TargetBoardName [] = TARGET_BOARD_NAME;
214214
#endif
215215

216+
#define osDelay(n) dap_os_delay(n)
217+
216218
/**
217219
* @brief Get Vendor ID string.
218220
*

components/DAP/config/target_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <stdint.h>
2727

2828
#include "flash_blob.h"
29-
#include "util.h"
3029

3130
//! @brief Current target configuration version.
3231
//!

components/DAP/include/swd_host.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
#ifndef SWDHOST_CM_H
2525
#define SWDHOST_CM_H
2626

27-
#include "flash_blob.h"
28-
#include "target_family.h"
27+
#include "components/DAP/include/flash_blob.h"
28+
#include "components/DAP/include/target_family.h"
2929
#ifdef TARGET_MCU_CORTEX_A
3030
#include "debug_ca.h"
3131
#else
32-
#include "debug_cm.h"
32+
#include "components/DAP/include/debug_cm.h"
3333
#endif
3434

3535
#ifdef __cplusplus

components/DAP/source/swd_host.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
*/
2323

2424
#ifndef TARGET_MCU_CORTEX_A
25-
#include "device.h"
26-
#include "cmsis_os2.h"
27-
#include "target_config.h"
28-
#include "DAP_config.h"
29-
#include "DAP.h"
30-
#include "target_family.h"
31-
#include "swd_host.h"
25+
#include "components/DAP/config/target_config.h"
26+
#include "components/DAP/config/DAP_config.h"
27+
#include "components/DAP/include/DAP.h"
28+
#include "components/DAP/include/target_family.h"
29+
#include "components/DAP/include/swd_host.h"
3230

3331
// Default NVIC and Core debug base addresses
3432
// TODO: Read these addresses from ROM.
@@ -66,6 +64,17 @@ static SWD_CONNECT_TYPE reset_connect = CONNECT_NORMAL;
6664

6765
static DAP_STATE dap_state;
6866
static uint32_t soft_reset = SYSRESETREQ;
67+
uint32_t target_get_apsel()
68+
{
69+
/* not support */
70+
// if (g_target_family && g_target_family->apsel) {
71+
// return g_target_family->apsel;
72+
// } else {
73+
// return 0;
74+
// }
75+
76+
return 0;
77+
}
6978

7079
static uint32_t swd_get_apsel(uint32_t adr)
7180
{
@@ -824,9 +833,11 @@ uint8_t swd_init_debug(void)
824833
// call a target dependant function
825834
// this function can do several stuff before really
826835
// initing the debug
827-
if (g_target_family && g_target_family->target_before_init_debug) {
828-
g_target_family->target_before_init_debug();
829-
}
836+
837+
/* not support */
838+
// if (g_target_family && g_target_family->target_before_init_debug) {
839+
// g_target_family->target_before_init_debug();
840+
// }
830841

831842
if (!JTAG2SWD()) {
832843
do_abort = 1;
@@ -874,9 +885,11 @@ uint8_t swd_init_debug(void)
874885
// call a target dependant function:
875886
// some target can enter in a lock state
876887
// this function can unlock these targets
877-
if (g_target_family && g_target_family->target_unlock_sequence) {
878-
g_target_family->target_unlock_sequence();
879-
}
888+
889+
/* not support */
890+
// if (g_target_family && g_target_family->target_unlock_sequence) {
891+
// g_target_family->target_unlock_sequence();
892+
// }
880893

881894
if (!swd_write_dp(DP_SELECT, 0)) {
882895
do_abort = 1;
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
set(COMPONENT_ADD_INCLUDEDIRS ".")
2-
set(COMPONENT_SRCS "./elaphureLink_protocol.c")
3-
4-
register_component()
1+
idf_component_register(SRCS "./elaphureLink_protocol.c"
2+
REQUIRES DAP)

0 commit comments

Comments
 (0)