Skip to content

Commit dc9e5db

Browse files
authored
Merge pull request #10986 from tannewt/p4gpio
Fix P4 for v1 and add P4GPIO board definition
2 parents b9305fc + 4a0a891 commit dc9e5db

10 files changed

Lines changed: 226 additions & 6 deletions

File tree

ports/espressif/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,13 @@ CHIP_COMPONENTS = \
399399
esp_hal_usb
400400

401401
else ifeq ($(IDF_TARGET),esp32p4)
402+
CIRCUITPY_ESP32P4_REV ?= 1
402403
CFLAGS += \
403-
-isystem esp-idf/components/soc/esp32p4/register/hw_ver3 \
404-
-isystem esp-idf/components/soc/esp32p4/register/hw_ver1 \
404+
-isystem esp-idf/components/soc/esp32p4/register/hw_ver$(CIRCUITPY_ESP32P4_REV) \
405405
-isystem esp-idf/components/esp_hw_support/ldo/include \
406406
-isystem esp-idf/components/esp_driver_touch_sens/hw_ver3/include
407407

408+
ifeq ($(CIRCUITPY_ESP32P4_REV),3)
408409
LDFLAGS += \
409410
-Tesp32p4.rom.libc.ld \
410411
-Tesp32p4.rom.systimer.ld \
@@ -413,6 +414,14 @@ LDFLAGS += \
413414
-Tesp32p4.rom.eco5.rvfp.ld \
414415
-Tesp32p4.rom.version.ld \
415416
-Trom.wdt.ld
417+
else
418+
LDFLAGS += \
419+
-Tesp32p4.rom.libc.ld \
420+
-Tesp32p4.rom.systimer.ld \
421+
-Tesp32p4.rom.rvfp.ld \
422+
-Tesp32p4.rom.version.ld \
423+
-Trom.wdt.ld
424+
endif
416425

417426

418427
CHIP_COMPONENTS = \
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
9+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "Adafruit P4 GPIO"
12+
#define MICROPY_HW_MCU_NAME "ESP32P4"
13+
14+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO52)
15+
16+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO35)
17+
18+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO54)
19+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO53)
20+
21+
// Use the second USB device (numbered 0 and 1) -- HS PHY routed to J1.
22+
#define CIRCUITPY_USB_DEVICE_INSTANCE 1
23+
#define CIRCUITPY_USB_DEVICE_HIGH_SPEED (1)
24+
25+
// FS USB on GPIO24/25 routed to J2.
26+
#define CIRCUITPY_USB_HOST_INSTANCE 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
USB_VID = 0x239A
2+
USB_PID = 0x8174
3+
USB_PRODUCT = "Adafruit P4 GPIO"
4+
USB_MANUFACTURER = "Adafruit"
5+
6+
IDF_TARGET = esp32p4
7+
8+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9+
CIRCUITPY_ESP_FLASH_MODE = qio
10+
CIRCUITPY_ESP_FLASH_FREQ = 80m
11+
12+
CIRCUITPY_ESP_PSRAM_SIZE = 32MB
13+
CIRCUITPY_ESP_PSRAM_MODE = hpi
14+
CIRCUITPY_ESP_PSRAM_FREQ = 200m
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
9+
static const mp_rom_map_elem_t board_module_globals_table[] = {
10+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
11+
12+
// Header J8 (B1)
13+
{ MP_ROM_QSTR(MP_QSTR_B1_0), MP_ROM_PTR(&pin_GPIO0) },
14+
{ MP_ROM_QSTR(MP_QSTR_B1_1), MP_ROM_PTR(&pin_GPIO1) },
15+
{ MP_ROM_QSTR(MP_QSTR_B1_2), MP_ROM_PTR(&pin_GPIO2) },
16+
{ MP_ROM_QSTR(MP_QSTR_B1_3), MP_ROM_PTR(&pin_GPIO3) },
17+
{ MP_ROM_QSTR(MP_QSTR_B1_4), MP_ROM_PTR(&pin_GPIO4) },
18+
{ MP_ROM_QSTR(MP_QSTR_B1_5), MP_ROM_PTR(&pin_GPIO5) },
19+
{ MP_ROM_QSTR(MP_QSTR_B1_6), MP_ROM_PTR(&pin_GPIO6) },
20+
{ MP_ROM_QSTR(MP_QSTR_B1_7), MP_ROM_PTR(&pin_GPIO7) },
21+
22+
// Header J7 (B2)
23+
{ MP_ROM_QSTR(MP_QSTR_B2_0), MP_ROM_PTR(&pin_GPIO8) },
24+
{ MP_ROM_QSTR(MP_QSTR_B2_1), MP_ROM_PTR(&pin_GPIO9) },
25+
{ MP_ROM_QSTR(MP_QSTR_B2_2), MP_ROM_PTR(&pin_GPIO10) },
26+
{ MP_ROM_QSTR(MP_QSTR_B2_3), MP_ROM_PTR(&pin_GPIO11) },
27+
{ MP_ROM_QSTR(MP_QSTR_B2_4), MP_ROM_PTR(&pin_GPIO12) },
28+
{ MP_ROM_QSTR(MP_QSTR_B2_5), MP_ROM_PTR(&pin_GPIO13) },
29+
{ MP_ROM_QSTR(MP_QSTR_B2_6), MP_ROM_PTR(&pin_GPIO14) },
30+
{ MP_ROM_QSTR(MP_QSTR_B2_7), MP_ROM_PTR(&pin_GPIO15) },
31+
32+
// Header J6 (B3)
33+
{ MP_ROM_QSTR(MP_QSTR_B3_0), MP_ROM_PTR(&pin_GPIO16) },
34+
{ MP_ROM_QSTR(MP_QSTR_B3_1), MP_ROM_PTR(&pin_GPIO17) },
35+
{ MP_ROM_QSTR(MP_QSTR_B3_2), MP_ROM_PTR(&pin_GPIO18) },
36+
{ MP_ROM_QSTR(MP_QSTR_B3_3), MP_ROM_PTR(&pin_GPIO19) },
37+
{ MP_ROM_QSTR(MP_QSTR_B3_4), MP_ROM_PTR(&pin_GPIO20) },
38+
{ MP_ROM_QSTR(MP_QSTR_B3_5), MP_ROM_PTR(&pin_GPIO21) },
39+
{ MP_ROM_QSTR(MP_QSTR_B3_6), MP_ROM_PTR(&pin_GPIO22) },
40+
{ MP_ROM_QSTR(MP_QSTR_B3_7), MP_ROM_PTR(&pin_GPIO23) },
41+
42+
// Header J3 (T3)
43+
{ MP_ROM_QSTR(MP_QSTR_T3_0), MP_ROM_PTR(&pin_GPIO33) },
44+
{ MP_ROM_QSTR(MP_QSTR_T3_1), MP_ROM_PTR(&pin_GPIO32) },
45+
{ MP_ROM_QSTR(MP_QSTR_T3_2), MP_ROM_PTR(&pin_GPIO31) },
46+
{ MP_ROM_QSTR(MP_QSTR_T3_3), MP_ROM_PTR(&pin_GPIO30) },
47+
{ MP_ROM_QSTR(MP_QSTR_T3_4), MP_ROM_PTR(&pin_GPIO29) },
48+
{ MP_ROM_QSTR(MP_QSTR_T3_5), MP_ROM_PTR(&pin_GPIO28) },
49+
{ MP_ROM_QSTR(MP_QSTR_T3_6), MP_ROM_PTR(&pin_GPIO27) },
50+
{ MP_ROM_QSTR(MP_QSTR_T3_7), MP_ROM_PTR(&pin_GPIO26) },
51+
52+
// Header J4 (T2)
53+
{ MP_ROM_QSTR(MP_QSTR_T2_0), MP_ROM_PTR(&pin_GPIO43) },
54+
{ MP_ROM_QSTR(MP_QSTR_T2_1), MP_ROM_PTR(&pin_GPIO42) },
55+
{ MP_ROM_QSTR(MP_QSTR_T2_2), MP_ROM_PTR(&pin_GPIO41) },
56+
{ MP_ROM_QSTR(MP_QSTR_T2_3), MP_ROM_PTR(&pin_GPIO40) },
57+
{ MP_ROM_QSTR(MP_QSTR_T2_4), MP_ROM_PTR(&pin_GPIO39) },
58+
{ MP_ROM_QSTR(MP_QSTR_T2_5), MP_ROM_PTR(&pin_GPIO38) },
59+
{ MP_ROM_QSTR(MP_QSTR_T2_6), MP_ROM_PTR(&pin_GPIO37) },
60+
{ MP_ROM_QSTR(MP_QSTR_T2_7), MP_ROM_PTR(&pin_GPIO34) },
61+
62+
// Header J5 (T1)
63+
{ MP_ROM_QSTR(MP_QSTR_T1_0), MP_ROM_PTR(&pin_GPIO51) },
64+
{ MP_ROM_QSTR(MP_QSTR_T1_1), MP_ROM_PTR(&pin_GPIO50) },
65+
{ MP_ROM_QSTR(MP_QSTR_T1_2), MP_ROM_PTR(&pin_GPIO49) },
66+
{ MP_ROM_QSTR(MP_QSTR_T1_3), MP_ROM_PTR(&pin_GPIO48) },
67+
{ MP_ROM_QSTR(MP_QSTR_T1_4), MP_ROM_PTR(&pin_GPIO47) },
68+
{ MP_ROM_QSTR(MP_QSTR_T1_5), MP_ROM_PTR(&pin_GPIO46) },
69+
{ MP_ROM_QSTR(MP_QSTR_T1_6), MP_ROM_PTR(&pin_GPIO45) },
70+
{ MP_ROM_QSTR(MP_QSTR_T1_7), MP_ROM_PTR(&pin_GPIO44) },
71+
72+
// Boot button (also exposed on J9/J10 pin 2)
73+
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO35) },
74+
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO35) },
75+
76+
// NeoPixel
77+
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO52) },
78+
79+
// StemmaQT / Qwiic I2C (J11)
80+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO53) },
81+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO54) },
82+
83+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
84+
};
85+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Bootloader config
6+
#
7+
#
8+
# Log
9+
#
10+
#
11+
# Format
12+
#
13+
# CONFIG_BOOTLOADER_LOG_COLORS is not set
14+
# end of Format
15+
16+
# end of Log
17+
18+
# default:
19+
CONFIG_BOOTLOADER_CPU_CLK_FREQ_MHZ=90
20+
#
21+
# Serial Flash Configurations
22+
#
23+
# CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT is not set
24+
# end of Serial Flash Configurations
25+
26+
# end of Bootloader config
27+
28+
#
29+
# Component config
30+
#
31+
#
32+
# Bluetooth
33+
#
34+
# CONFIG_BT_ENABLED is not set
35+
# end of Bluetooth
36+
37+
#
38+
# Hardware Settings
39+
#
40+
#
41+
# Chip revision
42+
#
43+
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
44+
CONFIG_ESP32P4_REV_MIN_100=y
45+
# default:
46+
CONFIG_ESP32P4_REV_MIN_FULL=100
47+
# default:
48+
CONFIG_ESP_REV_MIN_FULL=100
49+
# default:
50+
CONFIG_ESP32P4_REV_MAX_FULL=199
51+
# default:
52+
CONFIG_ESP_REV_MAX_FULL=199
53+
# end of Chip revision
54+
55+
# end of Hardware Settings
56+
57+
#
58+
# ESP System Settings
59+
#
60+
# default:
61+
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_360=y
62+
# default:
63+
# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_400 is not set
64+
# default:
65+
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=360
66+
# end of ESP System Settings
67+
68+
# end of Component config
69+
70+
# end of Espressif IoT Development Framework Configuration
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
2+
CONFIG_ESP32P4_REV_MIN_100=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
2+
CONFIG_ESP32P4_REV_MIN_100=y
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
2+
CONFIG_ESP32P4_REV_MIN_100=y

ports/espressif/tools/update_sdkconfig.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import click
66
import copy
77
import kconfiglib
8-
import kconfiglib.core
98
import os
109

1110
OPT_SETTINGS = [
@@ -203,7 +202,7 @@ def update(debug, board, update_all): # noqa: C901 too complex
203202
kconfig_path = pathlib.Path(f"build-{board}/esp-idf/kconfigs.in")
204203

205204
kconfig_path = pathlib.Path("esp-idf/Kconfig")
206-
kconfig = kconfiglib.Kconfig(kconfig_path)
205+
kconfig = kconfiglib.Kconfig(str(kconfig_path))
207206

208207
input_config = pathlib.Path(f"build-{board}/esp-idf/sdkconfig")
209208
kconfig.load_config(input_config)
@@ -244,7 +243,7 @@ def update(debug, board, update_all): # noqa: C901 too complex
244243
# Don't include the board file in cp defaults. The board may have custom
245244
# overrides.
246245

247-
cp_kconfig_defaults = kconfiglib.Kconfig(kconfig_path)
246+
cp_kconfig_defaults = kconfiglib.Kconfig(str(kconfig_path))
248247
for default_file in sdkconfigs:
249248
cp_kconfig_defaults.load_config(default_file, replace=False)
250249

@@ -332,7 +331,7 @@ def update(debug, board, update_all): # noqa: C901 too complex
332331
shared_keys = {}
333332
first = True
334333
for path in pathlib.Path(".").glob(loc):
335-
kc = kconfiglib.Kconfig(path)
334+
kc = kconfiglib.Kconfig(str(path))
336335
all_file_syms = set()
337336
for sym in kc.unique_defined_syms:
338337
all_file_syms.add(sym)
@@ -378,6 +377,8 @@ def update(debug, board, update_all): # noqa: C901 too complex
378377
all_references.update(rdep.referenced)
379378
psram_reference = False
380379
for referenced in all_references:
380+
if not referenced.name:
381+
continue
381382
if referenced.name.startswith("IDF_TARGET"):
382383
target_reference = True
383384
if referenced.name in target_symbols:

0 commit comments

Comments
 (0)