Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ports/espressif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,13 @@ CHIP_COMPONENTS = \
esp_hal_usb

else ifeq ($(IDF_TARGET),esp32p4)
CIRCUITPY_ESP32P4_REV ?= 1
CFLAGS += \
-isystem esp-idf/components/soc/esp32p4/register/hw_ver3 \
-isystem esp-idf/components/soc/esp32p4/register/hw_ver1 \
-isystem esp-idf/components/soc/esp32p4/register/hw_ver$(CIRCUITPY_ESP32P4_REV) \
-isystem esp-idf/components/esp_hw_support/ldo/include \
-isystem esp-idf/components/esp_driver_touch_sens/hw_ver3/include

ifeq ($(CIRCUITPY_ESP32P4_REV),3)
LDFLAGS += \
-Tesp32p4.rom.libc.ld \
-Tesp32p4.rom.systimer.ld \
Expand All @@ -413,6 +414,14 @@ LDFLAGS += \
-Tesp32p4.rom.eco5.rvfp.ld \
-Tesp32p4.rom.version.ld \
-Trom.wdt.ld
else
LDFLAGS += \
-Tesp32p4.rom.libc.ld \
-Tesp32p4.rom.systimer.ld \
-Tesp32p4.rom.rvfp.ld \
-Tesp32p4.rom.version.ld \
-Trom.wdt.ld
endif


CHIP_COMPONENTS = \
Expand Down
9 changes: 9 additions & 0 deletions ports/espressif/boards/adafruit_p4gpio/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include "supervisor/board.h"

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
26 changes: 26 additions & 0 deletions ports/espressif/boards/adafruit_p4gpio/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#pragma once

// Micropython setup

#define MICROPY_HW_BOARD_NAME "Adafruit P4 GPIO"
#define MICROPY_HW_MCU_NAME "ESP32P4"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO52)

#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO35)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO54)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO53)

// Use the second USB device (numbered 0 and 1) -- HS PHY routed to J1.
#define CIRCUITPY_USB_DEVICE_INSTANCE 1
#define CIRCUITPY_USB_DEVICE_HIGH_SPEED (1)

// FS USB on GPIO24/25 routed to J2.
#define CIRCUITPY_USB_HOST_INSTANCE 0
14 changes: 14 additions & 0 deletions ports/espressif/boards/adafruit_p4gpio/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
USB_VID = 0x239A
USB_PID = 0x8174
USB_PRODUCT = "Adafruit P4 GPIO"
USB_MANUFACTURER = "Adafruit"

IDF_TARGET = esp32p4

CIRCUITPY_ESP_FLASH_SIZE = 16MB
CIRCUITPY_ESP_FLASH_MODE = qio
CIRCUITPY_ESP_FLASH_FREQ = 80m

CIRCUITPY_ESP_PSRAM_SIZE = 32MB
CIRCUITPY_ESP_PSRAM_MODE = hpi
CIRCUITPY_ESP_PSRAM_FREQ = 200m
85 changes: 85 additions & 0 deletions ports/espressif/boards/adafruit_p4gpio/pins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2026 Scott Shawcroft for Adafruit Industries
//
// SPDX-License-Identifier: MIT

#include "shared-bindings/board/__init__.h"

static const mp_rom_map_elem_t board_module_globals_table[] = {
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS

// Header J8 (B1)
{ MP_ROM_QSTR(MP_QSTR_B1_0), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_B1_1), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_B1_2), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_B1_3), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_B1_4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_B1_5), MP_ROM_PTR(&pin_GPIO5) },
{ MP_ROM_QSTR(MP_QSTR_B1_6), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_B1_7), MP_ROM_PTR(&pin_GPIO7) },

// Header J7 (B2)
{ MP_ROM_QSTR(MP_QSTR_B2_0), MP_ROM_PTR(&pin_GPIO8) },
{ MP_ROM_QSTR(MP_QSTR_B2_1), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_B2_2), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_B2_3), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_B2_4), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_B2_5), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_B2_6), MP_ROM_PTR(&pin_GPIO14) },
{ MP_ROM_QSTR(MP_QSTR_B2_7), MP_ROM_PTR(&pin_GPIO15) },

// Header J6 (B3)
{ MP_ROM_QSTR(MP_QSTR_B3_0), MP_ROM_PTR(&pin_GPIO16) },
{ MP_ROM_QSTR(MP_QSTR_B3_1), MP_ROM_PTR(&pin_GPIO17) },
{ MP_ROM_QSTR(MP_QSTR_B3_2), MP_ROM_PTR(&pin_GPIO18) },
{ MP_ROM_QSTR(MP_QSTR_B3_3), MP_ROM_PTR(&pin_GPIO19) },
{ MP_ROM_QSTR(MP_QSTR_B3_4), MP_ROM_PTR(&pin_GPIO20) },
{ MP_ROM_QSTR(MP_QSTR_B3_5), MP_ROM_PTR(&pin_GPIO21) },
{ MP_ROM_QSTR(MP_QSTR_B3_6), MP_ROM_PTR(&pin_GPIO22) },
{ MP_ROM_QSTR(MP_QSTR_B3_7), MP_ROM_PTR(&pin_GPIO23) },

// Header J3 (T3)
{ MP_ROM_QSTR(MP_QSTR_T3_0), MP_ROM_PTR(&pin_GPIO33) },
{ MP_ROM_QSTR(MP_QSTR_T3_1), MP_ROM_PTR(&pin_GPIO32) },
{ MP_ROM_QSTR(MP_QSTR_T3_2), MP_ROM_PTR(&pin_GPIO31) },
{ MP_ROM_QSTR(MP_QSTR_T3_3), MP_ROM_PTR(&pin_GPIO30) },
{ MP_ROM_QSTR(MP_QSTR_T3_4), MP_ROM_PTR(&pin_GPIO29) },
{ MP_ROM_QSTR(MP_QSTR_T3_5), MP_ROM_PTR(&pin_GPIO28) },
{ MP_ROM_QSTR(MP_QSTR_T3_6), MP_ROM_PTR(&pin_GPIO27) },
{ MP_ROM_QSTR(MP_QSTR_T3_7), MP_ROM_PTR(&pin_GPIO26) },

// Header J4 (T2)
{ MP_ROM_QSTR(MP_QSTR_T2_0), MP_ROM_PTR(&pin_GPIO43) },
{ MP_ROM_QSTR(MP_QSTR_T2_1), MP_ROM_PTR(&pin_GPIO42) },
{ MP_ROM_QSTR(MP_QSTR_T2_2), MP_ROM_PTR(&pin_GPIO41) },
{ MP_ROM_QSTR(MP_QSTR_T2_3), MP_ROM_PTR(&pin_GPIO40) },
{ MP_ROM_QSTR(MP_QSTR_T2_4), MP_ROM_PTR(&pin_GPIO39) },
{ MP_ROM_QSTR(MP_QSTR_T2_5), MP_ROM_PTR(&pin_GPIO38) },
{ MP_ROM_QSTR(MP_QSTR_T2_6), MP_ROM_PTR(&pin_GPIO37) },
{ MP_ROM_QSTR(MP_QSTR_T2_7), MP_ROM_PTR(&pin_GPIO34) },

// Header J5 (T1)
{ MP_ROM_QSTR(MP_QSTR_T1_0), MP_ROM_PTR(&pin_GPIO51) },
{ MP_ROM_QSTR(MP_QSTR_T1_1), MP_ROM_PTR(&pin_GPIO50) },
{ MP_ROM_QSTR(MP_QSTR_T1_2), MP_ROM_PTR(&pin_GPIO49) },
{ MP_ROM_QSTR(MP_QSTR_T1_3), MP_ROM_PTR(&pin_GPIO48) },
{ MP_ROM_QSTR(MP_QSTR_T1_4), MP_ROM_PTR(&pin_GPIO47) },
{ MP_ROM_QSTR(MP_QSTR_T1_5), MP_ROM_PTR(&pin_GPIO46) },
{ MP_ROM_QSTR(MP_QSTR_T1_6), MP_ROM_PTR(&pin_GPIO45) },
{ MP_ROM_QSTR(MP_QSTR_T1_7), MP_ROM_PTR(&pin_GPIO44) },

// Boot button (also exposed on J9/J10 pin 2)
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO35) },

// NeoPixel
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO52) },

// StemmaQT / Qwiic I2C (J11)
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO53) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO54) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
70 changes: 70 additions & 0 deletions ports/espressif/boards/adafruit_p4gpio/sdkconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# Espressif IoT Development Framework Configuration
#
#
# Bootloader config
#
#
# Log
#
#
# Format
#
# CONFIG_BOOTLOADER_LOG_COLORS is not set
# end of Format

# end of Log

# default:
CONFIG_BOOTLOADER_CPU_CLK_FREQ_MHZ=90
#
# Serial Flash Configurations
#
# CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT is not set
# end of Serial Flash Configurations

# end of Bootloader config

#
# Component config
#
#
# Bluetooth
#
# CONFIG_BT_ENABLED is not set
# end of Bluetooth

#
# Hardware Settings
#
#
# Chip revision
#
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
CONFIG_ESP32P4_REV_MIN_100=y
# default:
CONFIG_ESP32P4_REV_MIN_FULL=100
# default:
CONFIG_ESP_REV_MIN_FULL=100
# default:
CONFIG_ESP32P4_REV_MAX_FULL=199
# default:
CONFIG_ESP_REV_MAX_FULL=199
# end of Chip revision

# end of Hardware Settings

#
# ESP System Settings
#
# default:
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_360=y
# default:
# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_400 is not set
# default:
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=360
# end of ESP System Settings

# end of Component config

# end of Espressif IoT Development Framework Configuration
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
CONFIG_ESP32P4_REV_MIN_100=y
2 changes: 2 additions & 0 deletions ports/espressif/boards/m5stack_tab5/sdkconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
CONFIG_ESP32P4_REV_MIN_100=y
2 changes: 2 additions & 0 deletions ports/espressif/boards/solderparty_esp32p4_stamp_xl/sdkconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_ESP32P4_SELECTS_REV_LESS_V3=y
CONFIG_ESP32P4_REV_MIN_100=y
9 changes: 5 additions & 4 deletions ports/espressif/tools/update_sdkconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import click
import copy
import kconfiglib
import kconfiglib.core
import os

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

kconfig_path = pathlib.Path("esp-idf/Kconfig")
kconfig = kconfiglib.Kconfig(kconfig_path)
kconfig = kconfiglib.Kconfig(str(kconfig_path))

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

cp_kconfig_defaults = kconfiglib.Kconfig(kconfig_path)
cp_kconfig_defaults = kconfiglib.Kconfig(str(kconfig_path))
for default_file in sdkconfigs:
cp_kconfig_defaults.load_config(default_file, replace=False)

Expand Down Expand Up @@ -332,7 +331,7 @@ def update(debug, board, update_all): # noqa: C901 too complex
shared_keys = {}
first = True
for path in pathlib.Path(".").glob(loc):
kc = kconfiglib.Kconfig(path)
kc = kconfiglib.Kconfig(str(path))
all_file_syms = set()
for sym in kc.unique_defined_syms:
all_file_syms.add(sym)
Expand Down Expand Up @@ -378,6 +377,8 @@ def update(debug, board, update_all): # noqa: C901 too complex
all_references.update(rdep.referenced)
psram_reference = False
for referenced in all_references:
if not referenced.name:
continue
if referenced.name.startswith("IDF_TARGET"):
target_reference = True
if referenced.name in target_symbols:
Expand Down
Loading