[esp32p4_base]
extends = esp32_common
custom_esp32_kind = esp32p4
board_build.mcu = esp32p4

build_unflags=
  -DHAS_UDP_MULTICAST=1

build_flags =
  ${esp32_common.build_flags}
  -DMESHTASTIC_EXCLUDE_WIFI=1 ; TODO
  -DMESHTASTIC_EXCLUDE_MQTT=1
  -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1

build_src_filter = 
  ${esp32_common.build_src_filter} -<libpax/> +<platform/esp32> -<mesh/raspihttp> -<serialization/>

extra_scripts =
  ${esp32_common.extra_scripts}
  extra_scripts/ld_response_file.py

; Override esp32_common component pruning: keep esp_hosted + esp_wifi_remote for P4 hosted BT
custom_component_remove =
  espressif/esp_modem
  espressif/esp-dsp
  espressif/esp32-camera
  espressif/libsodium
  espressif/esp-modbus
  espressif/qrcode
  espressif/esp_insights
  espressif/esp_diag_data_store
  espressif/esp_diagnostics
  espressif/esp_rainmaker
  espressif/rmaker_common
  espressif/network_provisioning
  chmorgan/esp-libhelix-mp3
  espressif/esp-tflite-micro
  espressif/esp-sr
  espressif/esp_matter
  espressif/esp-zboss-lib
  espressif/esp-zigbee-lib
  espressif/mqtt

custom_sdkconfig =
  ${esp32_common.custom_sdkconfig}
  CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
  CONFIG_BT_CONTROLLER_DISABLED=y
  CONFIG_ESP_WIFI_REMOTE_ENABLED=y
  # esp_hosted core
  CONFIG_ESP_HOSTED_ENABLED=y
  # Board: custom (not Espressif EV board)
  CONFIG_ESP_HOSTED_P4_DEV_BOARD_NONE=y
  # Delay after C6 reset to allow boot (e.g. old v2.3.0 may be slow)
  CONFIG_ESP_HOSTED_SDIO_RESET_DELAY_MS=1500
  CONFIG_ESP_HOSTED_SDIO_OPTIMIZATION_RX_STREAMING_MODE=y
  CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE=y
  CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET="esp32c6"
  CONFIG_ESP_HOSTED_CP_TARGET_ESP32C6=y
  CONFIG_ESP_HOSTED_CP_TARGET_ESP32H2=n
  CONFIG_ESP_HOSTED_PRIV_SDIO_OPTION=y
  CONFIG_ESP_HOSTED_SPI_HOST_INTERFACE=n
  CONFIG_ESP_HOSTED_TRANSPORT_SDIO=y
  CONFIG_ESP_HOSTED_ENABLE_NIMBLE=y
  CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y
  CONFIG_ESP_HOSTED_NIMBLE_HCI_VHCI=y
  CONFIG_ESP_HOSTED_ENABLE_PEER_DATA_TRANSFER=y
  CONFIG_ESP_HOSTED_MAX_CUSTOM_MSG_HANDLERS=3
  # OTA method: LittleFS
  CONFIG_OTA_METHOD_LITTLEFS=y

  # Skip version check — we force OTA regardless
  # CONFIG_OTA_VERSION_CHECK_HOST_SLAVE is not set
  # CONFIG_OTA_VERSION_CHECK_SLAVEFW_SLAVE is not set

  # RX streaming mode
  CONFIG_ESP_HOSTED_SLAVE_RESET_ON_EVERY_HOST_BOOTUP=y
  ;CONFIG_ESP_HOSTED_SLAVE_RESET_ONLY_IF_NECESSARY=y
  # SOC_LCD (MUI / lovyanGFX)
  CONFIG_SOC_LCD_I80_SUPPORTED=y
  CONFIG_SOC_LCD_RGB_SUPPORTED=y
  CONFIG_SOC_MIPI_DSI_SUPPORTED=y
  # stack dump
  CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y ; remove for production version
  ;CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y; for production version
  ;CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y ; for target debugging
  # Logger: verbose for experiment
  CONFIG_LOG_DEFAULT_LEVEL_INFO=y
  CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y


lib_ignore =
  ${esp32_common.lib_ignore}
  libpax
  esp8266-oled-ssd1306
  bsec2
  esp32_idf5_https_server
  esp_driver_cam
  esp_http_server

; Override lib_deps to exclude environmental_extras
lib_deps =
  ${arduino_base.lib_deps}
  ${networking_base.lib_deps}
  ${networking_extra.lib_deps}
  ${environmental_base.lib_deps}
  ${radiolib_base.lib_deps}
  # renovate: datasource=git-refs depName=meshtastic/Crypto packageName=https://github.com/meshtastic/Crypto gitBranch=master
  https://github.com/meshtastic/Crypto/archive/1aa30eb536bd52a576fde6dfa393bf7349cf102d.zip
  # renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
  https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip
