diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f593cb2..3b025b0 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -17,7 +17,7 @@ jobs:
continue-on-error: false
strategy:
matrix:
- target-hardware: [esp32c3,esp32]
+ target-hardware: [esp32c3,esp32,esp32s3]
steps:
@@ -77,6 +77,16 @@ jobs:
command: esptool.py --chip ${{ matrix.target-hardware }} merge_bin -o build/wireless_tools_esp32_full.bin 0x0 build/bootloader/bootloader.bin 0xF000 build/partition_table/partition-table.bin 0x20000 build/wireless_tools_esp32.bin
+ - name: merge bin files (esp32s3)
+ if: matrix.target-hardware == 'esp32s3'
+ uses: espressif/esp-idf-ci-action@v1
+ with:
+ esp_idf_version: v5.2.1
+ target: ${{ matrix.target-hardware }}
+ path: './'
+ command: esptool.py --chip ${{ matrix.target-hardware }} merge_bin -o build/wireless_tools_esp32_full.bin 0x0 build/bootloader/bootloader.bin 0xF000 build/partition_table/partition-table.bin 0x20000 build/wireless_tools_esp32.bin
+
+
- name: Upload firmware
uses: actions/upload-artifact@v2
with:
diff --git a/README.md b/README.md
index 9d3bb47..f27b800 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@ For Keil users, we now also support [elaphureLink](https://github.com/windowsair
1. SoC Compatibility
- [x] ESP32
- [x] ESP32C3
+ - [x] ESP32S3
2. Debug Communication Mode
- [x] SWD
@@ -101,6 +102,34 @@ There is built-in ipv4 only mDNS server. You can access the device using `dap.lo
| TVCC | 3V3 |
| GND | GND |
+
+
+
+ESP32S3
+
+| SWD | |
+|----------------|--------|
+| SWCLK | GPIO12 |
+| SWDIO | GPIO11 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
+--------------
+
+
+| JTAG | |
+|--------------------|--------|
+| TCK | GPIO12 |
+| TMS | GPIO11 |
+| TDI | GPIO10 |
+| TDO | GPIO9 |
+| nTRST \(optional\) | GPIO14 |
+| nRESET | GPIO13 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
diff --git a/README_CN.md b/README_CN.md
index 03cc781..43a55a6 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -1,235 +1,262 @@
-## 简介
-
-只需要**一枚ESP芯片**即可开始无线调试!通过USBIP协议栈和CMSIS-DAP协议栈实现。
-
-> 👉在5米范围内,擦除并烧写100kb大小的固件(Hex固件) :
-
-

-
-----
-
-对于Keil用户,我们现在支持[elaphureLink](https://github.com/windowsair/elaphureLink)。无需usbip即可开始您的无线调试之旅!
-
-## 特性
-
-1. 支持的ESP芯片
- - [x] ESP32
- - [x] ESP32C3
-
-2. 支持的调试接口:
- - [x] SWD
- - [x] JTAG
-
-3. 支持的USB通信协议:
- - [x] USB-HID
- - [x] WCID & WinUSB (默认)
-4. 支持的调试跟踪器:
- - [x] TCP转发的串口
-
-5. 其它
- - [x] 通过SPI接口加速的SWD协议(最高可达40MHz)
- - [x] 支持[elaphureLink](https://github.com/windowsair/elaphureLink),无需驱动的快速Keil调试
- - [x] ...
-
-## 连接你的开发板
-
-### WIFI连接
-
-
-
-固件中已经内置了一个mDNS服务。你可以通过`dap.local`的地址访问到设备。
-
-
-
-
-### 调试接口连接
-
-
-ESP32C3
-
-| SWD | |
-|----------------|--------|
-| SWCLK | GPIO6 |
-| SWDIO | GPIO7 |
-| TVCC | 3V3 |
-| GND | GND |
-
---------------
-
-| JTAG | |
-|--------------------|---------|
-| TCK | GPIO6 |
-| TMS | GPIO7 |
-| TDI | GPIO9 |
-| TDO | GPIO8 |
-| nTRST \(optional\) | GPIO4 |
-| nRESET | GPIO5 |
-| TVCC | 3V3 |
-| GND | GND |
-
-
-
-
-
-ESP32
-
-| SWD | |
-|----------------|--------|
-| SWCLK | GPIO14 |
-| SWDIO | GPIO13 |
-| TVCC | 3V3 |
-| GND | GND |
-
---------------
-
-| JTAG | |
-|--------------------|---------|
-| TCK | GPIO14 |
-| TMS | GPIO13 |
-| TDI | GPIO18 |
-| TDO | GPIO19 |
-| nTRST \(optional\) | GPIO25 |
-| nRESET | GPIO26 |
-| TVCC | 3V3 |
-| GND | GND |
-
-
-
-
-----
-
-## 编译固件并烧写
-
-你可以在本地构建或使用Github Action在线构建固件,然后下载固件进行烧写。
-
-
-### 在本地构建并烧写
-
-
-ESP32C3
-
-1. 获取esp-idf
-
- 目前,请考虑使用esp-idf v5.2.1: https://github.com/espressif/esp-idf/releases/tag/v5.2.1
-
-2. 编译和烧写
-
- 使用ESP-IDF编译系统进行构建。
- 更多的信息,请见:[Build System](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html "Build System")
-
-
-下面例子展示了在Windows上完成这些任务的一种可行方法:
-
-```bash
-idf.py set-target esp32c3
-# 编译
-idf.py build
-# 烧写
-idf.py -p /dev/ttyS5 flash
-```
-
-
-> 位于项目根目录的`idf.py`脚本仅适用于较老的ESP8266设备,请不要在ESP32设备上使用。
-
-
-
-
-> 我们还提供了预编译固件用于快速评估。详见 [Releases](https://github.com/windowsair/wireless-esp8266-dap/releases)
-
-
-
-## 使用
-
-1. 获取USBIP项目
-
-- Windows: [usbip-win](https://github.com/cezanne/usbip-win)。
-- Linux:USBIP作为Linux内核的一部分发布,但我们还没有在Linux平台上测试,下面的说明都是在Windows平台下的。
-
-2. 启动ESP8266并且把ESP8266连接到同一个WIFI下。
-
-3. 通过USBIP连接ESP8266:
-
-```bash
-# 仅HID模式,用于SourceForge上的预编译版本或者旧的USBIP版本。
-.\usbip.exe -D -a 1-1
-
-# 👉 推荐。HID模式或者WinUSB模式。用于usbip-win 0.3.0 kmdf ude版本。
-.\usbip.exe attach_ude -r -b 1-1
-```
-
-如果一切顺利,你应该看到你的设备被连接,如下图所示。
-
-
-
-下面我们用keil MDK来测试:
-
-
-
-------
-
-## 经常会问的问题
-
-### Keil提示“RDDI-DAP ERROR”或“SWD/JTAG Communication Failure”
-
-1. 检查线路连接。别忘了连接3V3引脚。
-2. 检查网络连接是否稳定。
-
-
-## DAP很慢或者不稳定
-
-注意,本项目受限于周围的网络环境。如果你在电脑上使用热点进行连接,你可以尝试使用wireshark等工具对网络连接进行分析。当调试闲置时,线路上应保持静默,而正常工作时一般不会发生太多的丢包。
-
-一些局域网广播数据包可能会造成严重影响,这些包可能由这些应用发出:
-- DropBox LAN Sync
-- Logitech Arx Control
-- ...
-
-
-周围的射频环境同样会造成影响,此外距离、网卡性能等也可能是需要考虑的。
-
-
-## 文档
-
-### 速度策略
-
-单独使用ESP8266通用IO时的最大翻转速率只有大概2MHz。当你选择最大时钟时,我们需要采取以下操作:
-
-- `clock < 2Mhz` :与你选择的时钟速度类似。
-- `2MHz <= clock < 10MHz` :使用最快的纯IO速度。
-- `clock >= 10MHz` :使用40MHz时钟的SPI加速。
-
-> 请注意,这个项目最重要的速度制约因素仍然是TCP连接速度。
-
-### 对于OpenOCD用户
-
-这个项目最初是为在Keil上运行而设计的,但现在你也可以在OpenOCD上通过它来烧录程序。
-注意,如果你想使用40MHz的SPI加速器,你需要在连接目标设备后指定速度,否则会在开始时失败。
-
-```bash
-# 在使用flash指令前需要先运行:
-> adapter speed 10000
-
-> halt
-> flash write_image [erase] [unlock] filename [offset] [type]
-```
-
-> Keil的操作时序与OpenOCD的有些不同。例如,OpenOCD在读取 "IDCODE "寄存器之前缺少SWD线复位序列。
-
-# 致谢
-
-归功于以下项目、人员和组织。
-
-> - https://www.github.com/windowsair/wireless-esp8266-dap origin of this project
-> - https://github.com/thevoidnn/esp8266-wifi-cmsis-dap for adapter firmware based on CMSIS-DAP v1.0
-> - https://github.com/ARM-software/CMSIS_5 for CMSIS
-> - https://github.com/cezanne/usbip-win for usbip windows
-
-- [@windowsair](https://www.github.com/windowsair/wireless-esp8266-dap)
-- [@HeavenSpree](https://www.github.com/HeavenSpree)
-- [@Zy19930907](https://www.github.com/Zy19930907)
-- [@caiguang1997](https://www.github.com/caiguang1997)
-- [@ZhuYanzhen1](https://www.github.com/ZhuYanzhen1)
-
-
-## 许可证
-[Apache 2.0 许可证](LICENSE)
+## 简介
+
+只需要**一枚ESP芯片**即可开始无线调试!通过USBIP协议栈和CMSIS-DAP协议栈实现。
+
+> 👉在5米范围内,擦除并烧写100kb大小的固件(Hex固件) :
+
+
+
+----
+
+对于Keil用户,我们现在支持[elaphureLink](https://github.com/windowsair/elaphureLink)。无需usbip即可开始您的无线调试之旅!
+
+## 特性
+
+1. 支持的ESP芯片
+ - [x] ESP32
+ - [x] ESP32C3
+ - [x] ESP32S3
+
+2. 支持的调试接口:
+ - [x] SWD
+ - [x] JTAG
+
+3. 支持的USB通信协议:
+ - [x] USB-HID
+ - [x] WCID & WinUSB (默认)
+4. 支持的调试跟踪器:
+ - [x] TCP转发的串口
+
+5. 其它
+ - [x] 通过SPI接口加速的SWD协议(最高可达40MHz)
+ - [x] 支持[elaphureLink](https://github.com/windowsair/elaphureLink),无需驱动的快速Keil调试
+ - [x] ...
+
+## 连接你的开发板
+
+### WIFI连接
+
+
+
+固件中已经内置了一个mDNS服务。你可以通过`dap.local`的地址访问到设备。
+
+
+
+
+### 调试接口连接
+
+
+ESP32C3
+
+| SWD | |
+|----------------|--------|
+| SWCLK | GPIO6 |
+| SWDIO | GPIO7 |
+| TVCC | 3V3 |
+| GND | GND |
+
+--------------
+
+| JTAG | |
+|--------------------|---------|
+| TCK | GPIO6 |
+| TMS | GPIO7 |
+| TDI | GPIO9 |
+| TDO | GPIO8 |
+| nTRST \(optional\) | GPIO4 |
+| nRESET | GPIO5 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
+
+
+
+ESP32
+
+| SWD | |
+|----------------|--------|
+| SWCLK | GPIO14 |
+| SWDIO | GPIO13 |
+| TVCC | 3V3 |
+| GND | GND |
+
+--------------
+
+| JTAG | |
+|--------------------|---------|
+| TCK | GPIO14 |
+| TMS | GPIO13 |
+| TDI | GPIO18 |
+| TDO | GPIO19 |
+| nTRST \(optional\) | GPIO25 |
+| nRESET | GPIO26 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
+
+
+ESP32S3
+
+| SWD | |
+|----------------|--------|
+| SWCLK | GPIO12 |
+| SWDIO | GPIO11 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
+--------------
+
+
+| JTAG | |
+|--------------------|--------|
+| TCK | GPIO12 |
+| TMS | GPIO11 |
+| TDI | GPIO10 |
+| TDO | GPIO9 |
+| nTRST \(optional\) | GPIO14 |
+| nRESET | GPIO13 |
+| TVCC | 3V3 |
+| GND | GND |
+
+
+
+----
+
+## 编译固件并烧写
+
+你可以在本地构建或使用Github Action在线构建固件,然后下载固件进行烧写。
+
+
+### 在本地构建并烧写
+
+
+ESP32C3
+
+1. 获取esp-idf
+
+ 目前,请考虑使用esp-idf v5.2.1: https://github.com/espressif/esp-idf/releases/tag/v5.2.1
+
+2. 编译和烧写
+
+ 使用ESP-IDF编译系统进行构建。
+ 更多的信息,请见:[Build System](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html "Build System")
+
+
+下面例子展示了在Windows上完成这些任务的一种可行方法:
+
+```bash
+idf.py set-target esp32c3
+# 编译
+idf.py build
+# 烧写
+idf.py -p /dev/ttyS5 flash
+```
+
+
+> 位于项目根目录的`idf.py`脚本仅适用于较老的ESP8266设备,请不要在ESP32设备上使用。
+
+
+
+
+> 我们还提供了预编译固件用于快速评估。详见 [Releases](https://github.com/windowsair/wireless-esp8266-dap/releases)
+
+
+
+## 使用
+
+1. 获取USBIP项目
+
+- Windows: [usbip-win](https://github.com/cezanne/usbip-win)。
+- Linux:USBIP作为Linux内核的一部分发布,但我们还没有在Linux平台上测试,下面的说明都是在Windows平台下的。
+
+2. 启动ESP8266并且把ESP8266连接到同一个WIFI下。
+
+3. 通过USBIP连接ESP8266:
+
+```bash
+# 仅HID模式,用于SourceForge上的预编译版本或者旧的USBIP版本。
+.\usbip.exe -D -a 1-1
+
+# 👉 推荐。HID模式或者WinUSB模式。用于usbip-win 0.3.0 kmdf ude版本。
+.\usbip.exe attach_ude -r -b 1-1
+```
+
+如果一切顺利,你应该看到你的设备被连接,如下图所示。
+
+
+
+下面我们用keil MDK来测试:
+
+
+
+------
+
+## 经常会问的问题
+
+### Keil提示“RDDI-DAP ERROR”或“SWD/JTAG Communication Failure”
+
+1. 检查线路连接。别忘了连接3V3引脚。
+2. 检查网络连接是否稳定。
+
+
+## DAP很慢或者不稳定
+
+注意,本项目受限于周围的网络环境。如果你在电脑上使用热点进行连接,你可以尝试使用wireshark等工具对网络连接进行分析。当调试闲置时,线路上应保持静默,而正常工作时一般不会发生太多的丢包。
+
+一些局域网广播数据包可能会造成严重影响,这些包可能由这些应用发出:
+- DropBox LAN Sync
+- Logitech Arx Control
+- ...
+
+
+周围的射频环境同样会造成影响,此外距离、网卡性能等也可能是需要考虑的。
+
+
+## 文档
+
+### 速度策略
+
+单独使用ESP8266通用IO时的最大翻转速率只有大概2MHz。当你选择最大时钟时,我们需要采取以下操作:
+
+- `clock < 2Mhz` :与你选择的时钟速度类似。
+- `2MHz <= clock < 10MHz` :使用最快的纯IO速度。
+- `clock >= 10MHz` :使用40MHz时钟的SPI加速。
+
+> 请注意,这个项目最重要的速度制约因素仍然是TCP连接速度。
+
+### 对于OpenOCD用户
+
+这个项目最初是为在Keil上运行而设计的,但现在你也可以在OpenOCD上通过它来烧录程序。
+注意,如果你想使用40MHz的SPI加速器,你需要在连接目标设备后指定速度,否则会在开始时失败。
+
+```bash
+# 在使用flash指令前需要先运行:
+> adapter speed 10000
+
+> halt
+> flash write_image [erase] [unlock] filename [offset] [type]
+```
+
+> Keil的操作时序与OpenOCD的有些不同。例如,OpenOCD在读取 "IDCODE "寄存器之前缺少SWD线复位序列。
+
+# 致谢
+
+归功于以下项目、人员和组织。
+
+> - https://www.github.com/windowsair/wireless-esp8266-dap origin of this project
+> - https://github.com/thevoidnn/esp8266-wifi-cmsis-dap for adapter firmware based on CMSIS-DAP v1.0
+> - https://github.com/ARM-software/CMSIS_5 for CMSIS
+> - https://github.com/cezanne/usbip-win for usbip windows
+
+- [@windowsair](https://www.github.com/windowsair/wireless-esp8266-dap)
+- [@HeavenSpree](https://www.github.com/HeavenSpree)
+- [@Zy19930907](https://www.github.com/Zy19930907)
+- [@caiguang1997](https://www.github.com/caiguang1997)
+- [@ZhuYanzhen1](https://www.github.com/ZhuYanzhen1)
+
+
+## 许可证
+[Apache 2.0 许可证](LICENSE)
diff --git a/components/DAP/DAP_config.h b/components/DAP/DAP_config.h
index b00d977..20f7b31 100644
--- a/components/DAP/DAP_config.h
+++ b/components/DAP/DAP_config.h
@@ -60,6 +60,7 @@
#include "esp8266/pin_mux_register.h"
#elif defined CONFIG_IDF_TARGET_ESP32
#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32S3
#else
#error unknown hardware
#endif
@@ -99,6 +100,8 @@ This information includes:
#elif defined CONFIG_IDF_TARGET_ESP32C3
#define CPU_CLOCK 16000000
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<160MHz
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ #define CPU_CLOCK 240000000
#endif
@@ -374,7 +377,19 @@ __STATIC_INLINE uint8_t DAP_GetProductFirmwareVersionString (char *str) {
#define PIN_LED_CONNECTED _ // won't be used
#define PIN_LED_RUNNING _ // won't be used
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ #define PIN_SWDIO _ // SPI MISO
+ #define PIN_SWDIO_MOSI 11 // SPI MOSI
+ #define PIN_SWCLK 12
+ #define PIN_TDO 9 // device TDO -> Host Data Input
+ #define PIN_TDI 10
+ #define PIN_nTRST 14 // optional
+ #define PIN_nRESET 13
+ #define PIN_LED_CONNECTED _ // won't be used
+ #define PIN_LED_RUNNING _ // won't be used
+#else
+#error "not a supported target"
#endif
@@ -534,6 +549,29 @@ __STATIC_INLINE void PORT_JTAG_SETUP(void)
GPIO_PULL_UP_ONLY_SET(PIN_nTRST);
GPIO_PULL_UP_ONLY_SET(PIN_nRESET);
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+__STATIC_INLINE void PORT_JTAG_SETUP(void)
+{
+ // set TCK, TMS pin
+
+ // PIN_TDO output disable
+ gpio_ll_output_disable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_TDO);
+ // PIN_TDO input enable
+ gpio_ll_input_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_TDO);
+
+ // PIN_TDI output
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_TDI);
+ gpio_ll_od_disable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_TDI);
+ gpio_ll_pulldown_dis(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_TDI);
+
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nTRST);
+ gpio_ll_od_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nTRST);
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
+ gpio_ll_od_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
+
+ GPIO_PULL_UP_ONLY_SET(PIN_nTRST);
+ GPIO_PULL_UP_ONLY_SET(PIN_nRESET);
+}
#endif
/**
@@ -584,6 +622,11 @@ __STATIC_INLINE void PORT_OFF(void)
// gpio_set_pull_mode(PIN_nTRST, GPIO_PULLUP_ONLY);
GPIO_PULL_UP_ONLY_SET(PIN_nRESET);
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
+ gpio_ll_od_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
+ GPIO_PULL_UP_ONLY_SET(PIN_nRESET);
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET, 1);
#endif
}
@@ -727,6 +770,10 @@ __STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE(void)
// Note that the input of esp32c3 is not always connected.
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[PIN_SWDIO_MOSI]);
GPIO.out_w1ts.out_w1ts = (0x1 << PIN_SWDIO_MOSI);
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ // Note that the input is not always connected.
+ gpio_ll_input_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI);
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI, 1);
#endif
}
@@ -775,7 +822,7 @@ __STATIC_FORCEINLINE uint32_t PIN_TDO_IN(void)
return READ_PERI_REG(RTC_GPIO_IN_DATA) & 0x1;
#elif defined CONFIG_IDF_TARGET_ESP32
return ((GPIO.in >> PIN_TDO) & 0x1) ? 1 : 0;
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
return GPIO_GET_LEVEL(PIN_TDO);
#endif
}
@@ -836,6 +883,8 @@ __STATIC_FORCEINLINE void PIN_nRESET_OUT(uint32_t bit)
GPIO.enable_w1tc |= (0x01 << PIN_nRESET);
#elif defined CONFIG_IDF_TARGET_ESP32C3
GPIO.enable_w1tc.enable_w1tc |= (0x01 << PIN_nRESET);
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ gpio_ll_output_disable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
#endif
}
else
@@ -845,6 +894,8 @@ __STATIC_FORCEINLINE void PIN_nRESET_OUT(uint32_t bit)
GPIO.enable_w1ts |= (0x01 << PIN_nRESET);
#elif defined CONFIG_IDF_TARGET_ESP32C3
GPIO.enable_w1ts.enable_w1ts |= (0x01 << PIN_nRESET);
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_nRESET);
#endif
GPIO_SET_LEVEL_LOW(PIN_nRESET);
}
diff --git a/components/DAP/cmsis-dap/include/DAP.h b/components/DAP/cmsis-dap/include/DAP.h
index 4f61acf..d23b982 100644
--- a/components/DAP/cmsis-dap/include/DAP.h
+++ b/components/DAP/cmsis-dap/include/DAP.h
@@ -345,7 +345,7 @@ extern void DAP_Setup (void);
;
}
#else
- #if defined CONFIG_IDF_TARGET_ESP8266 || CONFIG_IDF_TARGET_ESP32
+ #if defined CONFIG_IDF_TARGET_ESP8266 || defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32S3
__STATIC_FORCEINLINE void PIN_DELAY_SLOW(int32_t delay)
{
__asm__ volatile(
diff --git a/components/DAP/cmsis-dap/include/gpio_common.h b/components/DAP/cmsis-dap/include/gpio_common.h
index b5eaf7f..2d26d79 100644
--- a/components/DAP/cmsis-dap/include/gpio_common.h
+++ b/components/DAP/cmsis-dap/include/gpio_common.h
@@ -31,9 +31,10 @@
#include "soc/soc/esp32/include/soc/spi_reg.h"
#endif
#include "hal/gpio_types.h"
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
#include "soc/gpio_struct.h"
#include "hal/gpio_ll.h"
+ #include "hal/gpio_hal.h"
#include "hal/clk_gate_ll.h"
#include "soc/gpio_struct.h"
#include "soc/dport_access.h"
diff --git a/components/DAP/cmsis-dap/include/gpio_op.h b/components/DAP/cmsis-dap/include/gpio_op.h
index 1a5a4b7..8572db0 100644
--- a/components/DAP/cmsis-dap/include/gpio_op.h
+++ b/components/DAP/cmsis-dap/include/gpio_op.h
@@ -53,6 +53,11 @@ __STATIC_INLINE __UNUSED void GPIO_FUNCTION_SET(int io_num)
}
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[io_num], PIN_FUNC_GPIO);
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+__STATIC_INLINE __UNUSED void GPIO_FUNCTION_SET(int io_num)
+{
+ gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[io_num], PIN_FUNC_GPIO);
+}
#endif
@@ -77,6 +82,13 @@ __STATIC_INLINE __UNUSED void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num)
// PP out
GPIO.pin[io_num].pad_driver = 0;
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+__STATIC_INLINE __UNUSED void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num)
+{
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num);
+ // PP out
+ gpio_ll_od_disable(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num);
+}
#endif
@@ -90,14 +102,14 @@ __STATIC_INLINE __UNUSED void GPIO_SET_LEVEL_LOW(int io_num)
{
GPIO.out_w1tc |= (0x1 << io_num);
}
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
__STATIC_INLINE __UNUSED void GPIO_SET_LEVEL_HIGH(int io_num)
{
- gpio_ll_set_level(&GPIO, io_num, 1);
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num, 1);
}
__STATIC_INLINE __UNUSED void GPIO_SET_LEVEL_LOW(int io_num)
{
- gpio_ll_set_level(&GPIO, io_num, 0);
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num, 0);
}
#endif
@@ -107,10 +119,10 @@ __STATIC_INLINE __UNUSED int GPIO_GET_LEVEL(int io_num)
{
return ((GPIO.in >> io_num) & 0x1) ? 1 : 0;
}
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
__STATIC_INLINE __UNUSED int GPIO_GET_LEVEL(int io_num)
{
- return gpio_ll_get_level(&GPIO, io_num);
+ return gpio_ll_get_level(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num);
}
#endif
@@ -125,6 +137,14 @@ __STATIC_INLINE __UNUSED void GPIO_PULL_UP_ONLY_SET(int io_num)
// enable pull up
REG_SET_BIT(GPIO_PIN_MUX_REG[io_num], FUN_PU);
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+__STATIC_INLINE __UNUSED void GPIO_PULL_UP_ONLY_SET(int io_num)
+{
+ // disable pull down
+ gpio_ll_pulldown_dis(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num);
+ // enable pull up
+ gpio_ll_pullup_en(GPIO_HAL_GET_HW(GPIO_PORT_0), io_num);
+}
#elif defined CONFIG_IDF_TARGET_ESP8266
__STATIC_INLINE __UNUSED void GPIO_PULL_UP_ONLY_SET(int io_num)
{
diff --git a/components/DAP/cmsis-dap/source/DAP.c b/components/DAP/cmsis-dap/source/DAP.c
index 5e93d8e..f000940 100644
--- a/components/DAP/cmsis-dap/source/DAP.c
+++ b/components/DAP/cmsis-dap/source/DAP.c
@@ -437,7 +437,7 @@ static uint32_t DAP_SWJ_Clock(const uint8_t *request, uint8_t *response) {
#ifdef CONFIG_IDF_TARGET_ESP8266
#define BUS_CLOCK_FIXED 80000000
-#elif defined CONFIG_IDF_TARGET_ESP32
+#elif defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32S3
#define BUS_CLOCK_FIXED 100000000
#elif defined CONFIG_IDF_TARGET_ESP32C3
#define BUS_CLOCK_FIXED 80000000
diff --git a/components/DAP/cmsis-dap/source/SW_DP.c b/components/DAP/cmsis-dap/source/SW_DP.c
index 7a12042..95b6cd6 100644
--- a/components/DAP/cmsis-dap/source/SW_DP.c
+++ b/components/DAP/cmsis-dap/source/SW_DP.c
@@ -292,7 +292,7 @@ static uint8_t SWD_Transfer_SPI (uint32_t request, uint32_t *data) {
else if ((ack == DAP_TRANSFER_WAIT) || (ack == DAP_TRANSFER_FAULT)) {
#if defined CONFIG_IDF_TARGET_ESP8266 || defined CONFIG_IDF_TARGET_ESP32
DAP_SPI_Generate_Cycle(1);
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
DAP_SPI_Fast_Cycle();
#endif
diff --git a/components/DAP/cmsis-dap/source/spi_op.c b/components/DAP/cmsis-dap/source/spi_op.c
index be4255c..78c016d 100644
--- a/components/DAP/cmsis-dap/source/spi_op.c
+++ b/components/DAP/cmsis-dap/source/spi_op.c
@@ -29,6 +29,8 @@
#define DAP_SPI SPI2
#elif defined CONFIG_IDF_TARGET_ESP32C3
#define DAP_SPI GPSPI2
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ #define DAP_SPI GPSPI2
#else
#error unknown hardware
#endif
@@ -52,7 +54,7 @@
while (DAP_SPI.cmd.usr) continue; \
} while(0)
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
#define SET_MOSI_BIT_LEN(x) DAP_SPI.ms_dlen.ms_data_bitlen = x
#define SET_MISO_BIT_LEN(x) DAP_SPI.ms_dlen.ms_data_bitlen = x
#define START_AND_WAIT_SPI_TRANSMISSION_DONE() \
@@ -207,7 +209,7 @@ __FORCEINLINE void DAP_SPI_Send_Header(const uint8_t packetHeaderData, uint8_t *
dataBuf = DAP_SPI.data_buf[0];
*ack = (dataBuf >> 1) & 0b111;
} // defined CONFIG_IDF_TARGET_ESP8266 || defined CONFIG_IDF_TARGET_ESP32
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
__FORCEINLINE void DAP_SPI_Send_Header(const uint8_t packetHeaderData, uint8_t *ack, uint8_t TrnAfterACK)
{
uint32_t dataBuf;
@@ -297,7 +299,7 @@ __FORCEINLINE void DAP_SPI_Write_Data(uint32_t data, uint8_t parity)
START_AND_WAIT_SPI_TRANSMISSION_DONE();
}
-#elif defined CONFIG_IDF_TARGET_ESP32C3
+#elif defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
__FORCEINLINE void DAP_SPI_Write_Data(uint32_t data, uint8_t parity)
{
DAP_SPI.user.usr_mosi = 1;
@@ -314,7 +316,7 @@ __FORCEINLINE void DAP_SPI_Write_Data(uint32_t data, uint8_t parity)
#endif
-#if defined CONFIG_IDF_TARGET_ESP8266 || defined CONFIG_IDF_TARGET_ESP32
+#if defined CONFIG_IDF_TARGET_ESP8266 || defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32S3
/**
* @brief Generate Clock Cycle
*
@@ -345,7 +347,7 @@ __FORCEINLINE void DAP_SPI_Generate_Cycle(uint8_t num)
}
#endif
-#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3
+#if defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32C3 || defined CONFIG_IDF_TARGET_ESP32S3
/**
* @brief Quickly generate 1 clock
*
diff --git a/components/DAP/cmsis-dap/source/spi_switch.c b/components/DAP/cmsis-dap/source/spi_switch.c
index 18a703a..aa7dfef 100644
--- a/components/DAP/cmsis-dap/source/spi_switch.c
+++ b/components/DAP/cmsis-dap/source/spi_switch.c
@@ -18,6 +18,7 @@
#include "cmsis-dap/include/cmsis_compiler.h"
#include "cmsis-dap/include/spi_switch.h"
#include "cmsis-dap/include/gpio_common.h"
+#include "DAP_config.h"
#ifdef CONFIG_IDF_TARGET_ESP8266
#define DAP_SPI SPI1
@@ -29,6 +30,9 @@
#define SPI_LL_RST_MASK (SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST)
#elif defined CONFIG_IDF_TARGET_ESP32C3
#define DAP_SPI GPSPI2
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+ #define DAP_SPI GPSPI2
+#define SPI_HOST_NUM SPI2_HOST
#else
#error unknown hardware
#endif
@@ -351,6 +355,92 @@ void DAP_SPI_Init()
DAP_SPI.user.usr_command = 0;
DAP_SPI.user.usr_addr = 0;
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+void DAP_SPI_Init()
+{
+ periph_ll_enable_clk_clear_rst(PERIPH_SPI2_MODULE);
+
+ // In esp32, the driving of GPIO should be stopped,
+ // otherwise there will be issue in the spi
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI, 0);
+ gpio_ll_set_level(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWCLK, 0);
+
+ // We will use IO_MUX to get the maximum speed.
+ gpio_ll_iomux_in(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWCLK,FSPICLK_IN_IDX);
+ gpio_ll_iomux_out(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWCLK, FUNC_GPIO12_FSPICLK, 0);
+
+ gpio_ll_iomux_in(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI,FSPID_IN_IDX);
+ gpio_ll_iomux_out(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI, FUNC_GPIO11_FSPID, 0);
+
+// // Not using DMA
+ DAP_SPI.user.usr_conf_nxt = 0;
+ DAP_SPI.slave.usr_conf = 0;
+ DAP_SPI.dma_conf.dma_rx_ena = 0;
+ DAP_SPI.dma_conf.dma_tx_ena = 0;
+
+ // Set to Master mode
+ DAP_SPI.slave.slave_mode = false;
+
+ // use all 64 bytes of the buffer
+ DAP_SPI.user.usr_mosi_highpart = false;
+ DAP_SPI.user.usr_miso_highpart = false;
+
+ // Disable cs pin
+ DAP_SPI.user.cs_setup = false;
+ DAP_SPI.user.cs_hold = false;
+
+ // Disable CS signal
+ DAP_SPI.misc.cs0_dis = 1;
+ DAP_SPI.misc.cs1_dis = 1;
+ DAP_SPI.misc.cs2_dis = 1;
+ DAP_SPI.misc.cs3_dis = 1;
+ DAP_SPI.misc.cs4_dis = 1;
+ DAP_SPI.misc.cs5_dis = 1;
+
+ // Duplex transmit
+ DAP_SPI.user.doutdin = false; // half dulex
+
+ // Set data bit order
+ DAP_SPI.ctrl.wr_bit_order = 1; // SWD -> LSB
+ DAP_SPI.ctrl.rd_bit_order = 1; // SWD -> LSB
+
+ // Set dummy
+ DAP_SPI.user.usr_dummy = 0; // not use
+
+ // Set spi clk: 40Mhz 50% duty
+ // CLEAR_PERI_REG_MASK(PERIPHS_IO_MUX_CONF_U, SPI1_CLK_EQU_SYS_CLK);
+
+ // See TRM `SPI_CLOCK_REG`
+ DAP_SPI.clock.clk_equ_sysclk = false;
+ DAP_SPI.clock.clkdiv_pre = 0;
+ DAP_SPI.clock.clkcnt_n = SPI_40MHz_DIV - 1;
+ DAP_SPI.clock.clkcnt_h = SPI_40MHz_DIV / 2 - 1;
+ DAP_SPI.clock.clkcnt_l = SPI_40MHz_DIV - 1;
+
+ // MISO delay setting
+ DAP_SPI.user.rsck_i_edge = true;
+ DAP_SPI.din_mode.din0_mode = 0;
+ DAP_SPI.din_mode.din1_mode = 0;
+ DAP_SPI.din_mode.din2_mode = 0;
+ DAP_SPI.din_mode.din3_mode = 0;
+ DAP_SPI.din_num.din0_num = 0;
+ DAP_SPI.din_num.din1_num = 0;
+ DAP_SPI.din_num.din2_num = 0;
+ DAP_SPI.din_num.din3_num = 0;
+
+ // Set the clock polarity and phase CPOL = 1, CPHA = 0
+ DAP_SPI.misc.ck_idle_edge = 1; // HIGH while idle
+ DAP_SPI.user.ck_out_edge = 0;
+
+ // enable spi clock
+ DAP_SPI.clk_gate.clk_en = 1;
+ DAP_SPI.clk_gate.mst_clk_active = 1;
+ DAP_SPI.clk_gate.mst_clk_sel = 1;
+
+ // No command and addr for now
+ DAP_SPI.user.usr_command = 0;
+ DAP_SPI.user.usr_addr = 0;
+}
#endif
@@ -416,6 +506,21 @@ __FORCEINLINE void DAP_SPI_Deinit()
GPIO.enable_w1ts.enable_w1ts |= (0x1 << 7);
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[7]);
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+__FORCEINLINE void DAP_SPI_Deinit()
+{
+ gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[PIN_SWCLK], PIN_FUNC_GPIO);
+ gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[PIN_SWDIO_MOSI], PIN_FUNC_GPIO); // MOSI
+ //PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[12], PIN_FUNC_GPIO); // MISO
+
+ // enable SWCLK output
+ gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWCLK);
+
+ // enable MOSI output & input
+// gpio_ll_output_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI);
+ GPIO.enable_w1ts |= (0x1 << PIN_SWDIO_MOSI);
+ gpio_ll_input_enable(GPIO_HAL_GET_HW(GPIO_PORT_0), PIN_SWDIO_MOSI);
+}
#endif
@@ -458,6 +563,25 @@ __FORCEINLINE void DAP_SPI_Release()
{
PIN_FUNC_SELECT(IO_MUX_GPIO6_REG, FUNC_MTCK_GPIO6);
}
+#elif defined CONFIG_IDF_TARGET_ESP32S3
+/**
+ * @brief Gain control of SPI
+ *
+ */
+__FORCEINLINE void DAP_SPI_Acquire()
+{
+ gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[PIN_SWCLK], FUNC_GPIO12_FSPICLK);
+}
+
+
+/**
+ * @brief Release control of SPI
+ *
+ */
+__FORCEINLINE void DAP_SPI_Release()
+{
+ gpio_ll_iomux_func_sel(GPIO_PIN_MUX_REG[PIN_SWCLK], FUNC_GPIO12_GPIO12);
+}
#endif
/**
* @brief Use SPI acclerate