8000 Merge pull request #6181 from tannewt/c3_serial_jtag · mimoccc/circuitpython@8ebab76 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ebab76

Browse files
authored
Merge pull request adafruit#6181 from tannewt/c3_serial_jtag
Add USB to Serial/JTAG support for REPL
2 parents c1b05ce + ee4c501 commit 8ebab76

27 files changed

+948
-188
lines changed

ports/espressif/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ SRC_C += \
262262
endif
263263
endif
264264

265+
ifeq ($(IDF_TARGET),esp32c3)
266+
SRC_C += \
267+
supervisor/usb_serial_jtag.c
268+
endif
269+
265270
$(BUILD)/i2s_lcd_esp32s2_driver.o: CFLAGS += -Wno-sign-compare
266271

267272
ifneq ($(CIRCUITPY_USB),0)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 microDev
7+
* Copyright (c) 2021 skieast/Bruce Segal
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#include "shared-bindings/microcontroller/Pin.h"
29+
#include "supervisor/board.h"
30+
31+
#include "components/driver/include/driver/gpio.h"
32+
#include "soc/usb_serial_jtag_struct.h"
33+
34+
void board_init(void) {
35+
}
36+
37+
bool board_requests_safe_mode(void) {
38+
return false;
39+
}
40+
41+
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
42+
return false;
43+
}
44+
45+
void reset_board(void) {
46+
}
47+
48+
void board_deinit(void) {
49+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 microDev
7+
* Copyright (c) 2021 skieast/Bruce Segal
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
// Board setup
29+
#define MICROPY_HW_BOARD_NAME "Adafruit QT Py ESP32C3"
30+
#define MICROPY_HW_MCU_NAME "ESP32-C3FN4"
31+
32+
// Status LED
33+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO2)
34+
35+
#define CIRCUITPY_BOARD_I2C (1)
36+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO5}}
37+
38+
#define CIRCUITPY_BOARD_SPI (1)
39+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO10, .mosi = &pin_GPIO7, .miso = &pin_GPIO8}}
40+
41+
#define CIRCUITPY_BOARD_UART (1)
42+
#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO21, .rx = &pin_GPIO20}}
43+
44+
// For entering safe mode
45+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9)
46+
47+
// Explanation of how a user got into safe mode
48+
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
49+
50+
#define CIRCUITPY_ESP_USB_SERIAL_JTAG (1)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CIRCUITPY_CREATOR_ID = 0x0000239A
2+
CIRCUITPY_CREATION_ID = 0x00010001
3+
4+
IDF_TARGET = esp32c3
5+
6+
INTERNAL_FLASH_FILESYSTEM = 1
7+
8+
CIRCUITPY_ESP_FLASH_MODE=dio
9+
CIRCUITPY_ESP_FLASH_FREQ=80m
10+
CIRCUITPY_ESP_FLASH_SIZE=4MB
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 microDev
7+
* Copyright (c) 2021 skieast/Bruce Segal
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy
10+
* of this software and associated documentation files (the "Software"), to deal
11+
* in the Software without restriction, including without limitation the rights
12+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
* copies of the Software, and to permit persons to whom the Software is
14+
* furnished to do so, subject to the following conditions:
15+
*
16+
* The above copyright notice and this permission notice shall be included in
17+
* all copies or substantial portions of the Software.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
28+
#include "shared-bindings/board/__init__.h"
29+
30+
#include "shared-bindings/board/__init__.h"
31+
32+
CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1)
33+
34+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
35+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
36+
37+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) },
38+
{ MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO9) },
39+
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO9) },
40+
41+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO4) },
42+
{ MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO4) },
43+
44+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO3) },
45+
{ MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO3) },
46+
47+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO1) },
48+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO1) },
49+
50+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO0) },
51+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO0) },
52+
53+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO5) },
54+
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO5) },
55+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) },
56+
57+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) },
58+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) },
59+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) },
60+
61+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) },
62+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO21) },
63+
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO21) },
64+
65+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) },
66+
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO20) },
67+
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO20) },
68+
69+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO7) },
70+
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO7) },
71+
72+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO10) },
73+
{ MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO10) },
74+
75+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO8) },
76+
{ MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO8) },
77+
78+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO2) },
79+
80+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
81+
{ MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) },
82+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
83+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
84+
};
85+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Automatically generated file. DO NOT EDIT.
2+
# Espressif IoT Development Framework (ESP-IDF) Project Configuration
3+
#
4+
# Bootloader config
5+
#
6+
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
7+
# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set
8+
CONFIG_BOOTLOADER_LOG_LEVEL=0
9+
# end of Bootloader config
10+
11+
#
12+
# Serial flasher config
13+
#
14+
# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set
15+
# end of Serial flasher config
16+
17+
#
18+
# Partition Table
19+
#
20+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv"
21+
CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv"
22+
# end of Partition Table
23+
24+
#
25+
# Compiler options
26+
#
27+
# CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set
28+
# end of Compiler options
29+
30+
#
31+
# Component config
32+
#
33+
#
34+
# ESP System Settings
35+
#
36+
# CONFIG_ESP_SYSTEM_USE_EH_FRAME is not set
37+
CONFIG_ESP_CONSOLE_SECONDARY_NONE=y
38+
# CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is not set
39+
# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set
40+
# end of ESP System Settings
41+
42+
#
43+
# LWIP
44+
#
45+
CONFIG_LWIP_LOCAL_HOSTNAME="Adafruit-QTPy-ESP32C3"
46+
# end of LWIP
47+
48+
#
49+
# SPI Flash driver
50+
#
51+
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
52+
# end of SPI Flash driver
53+
54+
# end of Component config
55+
56+
#
57+
# Deprecated options for backward compatibility
58+
#
59+
# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set
60+
CONFIG_LOG_BOOTLOADER_LEVEL=0
61+
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
62+
# end of Deprecated options for backward compatibility

ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# Component config
3+
#
4+
#
5+
# ESP32S3-Specific
6+
#
17
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
28
#
39
# SPI RAM config
@@ -9,12 +15,10 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
915
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
1016
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
1117
CONFIG_SPIRAM_SIZE=2097152
12-
# end of SPI RAM config
13-
14-
CONFIG_DEFAULT_PSRAM_CLK_IO=30
1518
#
1619
# PSRAM Clock and CS IO for ESP32S3
1720
#
21+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
1822
CONFIG_DEFAULT_PSRAM_CS_IO=26
1923
# end of PSRAM Clock and CS IO for ESP32S3
2024

@@ -30,8 +34,14 @@ CONFIG_SPIRAM_USE_MEMMAP=y
3034
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
3135
# CONFIG_SPIRAM_USE_MALLOC is not set
3236
CONFIG_SPIRAM_MEMTEST=y
37+
# end of SPI RAM config
38+
39+
# end of ESP32S3-Specific
40+
3341
#
3442
# LWIP
3543
#
3644
CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3"
3745
# end of LWIP
46+
47+
# end of Component config

ports/espressif/common-hal/microcontroller/Pin.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ STATIC void _reset_pin(gpio_num_t pin_number) {
7878
if (11 <= pin_number && pin_number <= 17) {
7979
return;
8080
}
81+
#if CIRCUITPY_ESP_USB_SERIAL_JTAG
82+
if (pin_number == 18 || pin_number == 19) {
83+
return;
84+
}
85+
#endif
8186
#endif
8287

8388
// Give the board a chance to reset the pin in a particular way.

ports/espressif/esp-idf-config/sdkconfig-8MB.defaults

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
1010
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
1111
# end of Serial flasher config
1212

13-
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-8MB.csv"
1413
#
1514
# Partition Table
1615
#
16+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-8MB.csv"
1717
CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB.csv"
1818
# end of Partition Table

0 commit comments

Comments
 (0)
0