# ESP-IDF options for the L2's LVGL firmware, over the Arduino framework's own
# (custom_sdkconfig in solo/wio-tracker-l2/platformio.ini; changing this file
# means rebuilding the framework libs: pio run -e Wio_Tracker_L2_idf_libs).

# The reason for all this: a 32 KB instruction cache (the framework ships
# 16 KB) and 64-byte data cache lines. LVGL runs from flash and draws into
# PSRAM; frames draw ~35% faster. Costs 16 KB internal RAM.
CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y

# ...won back, and more: TLS (map downloads, live tiles, OTA) and the BLE
# host keep their buffers in PSRAM.
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL=y

# What the framework's own build sets for octal-PSRAM boards, which a rebuild
# from its generic config would lose: PSRAM up before global constructors
# (MESH_IN_PSRAM needs it), WiFi TX buffers allocated as needed.
CONFIG_SPIRAM_BOOT_HW_INIT=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y
# CONFIG_SPIRAM_MEMTEST is not set
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_RX_BA_WIN=6
CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4

# Internal RAM is what WiFi starts and joins on (~25 KB, more for WPA): big
# zero-initialised statics marked EXT_RAM_BSS_ATTR (QR codes, map state,
# charts...) go to PSRAM instead.
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
# Its callbacks are short (~0.4 KB of stack used): half the framework's 8 KB.
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096
