Skip to content

Core Platform & Infrastructure

Core_Platform_&_Infrastructure is the foundational layer of the ESP3D-X CNC pendant firmware. It owns the complete firmware lifecycle from the ESP-IDF app_main entry point through all subsystem initialization, and provides the shared services every other module depends on: persistent settings, the inter-module message bus, the [ESPxxx] command dispatcher, an observable runtime state system, a structured logging subsystem with pluggable backends, a multi-language translation service, and a centralized user-activity tracking system. All other modules (UI, CNC integration, network, transports) build on the services defined here.


Core Platform & Infrastructure

entry_point

main/main.cpp

app_main()

esp3d_core

main/core/

ESP3DX · Settings · Messages

Commands · HAL · LVGL utils

esp3d_commands

main/core/commands/

ESP0…ESP950 handlers

esp3d_log

components/esp3d_log/

Macros · Backends · Hooks

values

main/modules/values/

ESP3DValues observable bus

translations

main/modules/translations/

ESP3DTranslationService

LNG1 blob format

esp3d_activity_manager

components/esp3d_activity_manager/

Input detection · Inactivity timeouts

ESP3DXNetworkESP3DXStreamESP3DXUi (LVGL task Core 1)ESP3DTranslationServiceESP3DValuesesp3d_log_init()ESP3DSettingsboard_init()nvs_flashESP3DX::begin()app_main()ESP-IDF RuntimeESP3DXNetworkESP3DXStreamESP3DXUi (LVGL task Core 1)ESP3DTranslationServiceESP3DValuesesp3d_log_init()ESP3DSettingsboard_init()nvs_flashESP3DX::begin()app_main()ESP-IDF Runtimeapp_main() [Core 0]ESP3DX::begin()esp3d_log_init()nvs_flash_init()board_init() - display, touch, LVGL tickvalidate NVS schema / reset() if neededinitialize() - allocate buffer poolbegin() - pin LNG1 blob from partitionbegin() - spawn tft_ui_task on Core 1begin() - GCode pipelinebegin() - WiFi or BT networkTask

Shared Services

Core 1

Core 0

networkTask

ESP3DXNetwork

streamTask

ESP3DXStream

esp3d_serial_rx_task

tft_ui_task

LVGL handler

ESP3DValues

(observable, mutex-protected)

ESP3DSettings

(NVS)

esp3d_log

(mutex-protected)

ESP3DMessage

ESP3DMessage

ESP3DMessage

[ESPxxx] → execute

GCode → forward

dispatch() normal

dispatch() high

Serial RX Task

ESP3DCommands

process()

BT RX Task

HTTP Handler

ESPxxx handler

GCode Host

Target TX queue (back)

Target TX queue (front)

Transport TX

Screen CallbackLVGL Task (Core 1)Update Queue (30 slots)ESP3DValuesTransport Task (Core 0)Screen CallbackLVGL Task (Core 1)Update Queue (30 slots)ESP3DValuesTransport Task (Core 0)loop[every LVGL tick]set_value(index, "1.234", Update)enqueue (or replace duplicate)handle()dequeue → write buffer poolsnapshot subscriber listinvoke callbacks (outside mutex)update LVGL widget (safe on Core 1)
Sub-modulePathRole
entry_pointmain/main.cppThin app_main bridge → ESP3DX::begin()
esp3d_coremain/core/ESP3DX, ESP3DSettings, ESP3DJsonSettings, ESP3DClient/ESP3DMessage, ESP3DCommands, esp3d_hal, LVGL snapshot utilities, system message history, string helpers
esp3d_commandsmain/core/commands/[ESP0]–[ESP950] handler implementations
esp3d_logcomponents/esp3d_log/Severity-gated macros (esp3d_log, _d, _w, _e), mutex-serialized output, 5 pluggable backends, runtime hook API
valuesmain/modules/values/ESP3DValues pub/sub bus — single-block pool, circular update queue, subscriber linked lists, all callbacks on Core 1
esp3d_activity_managercomponents/esp3d_activity_manager/BSP input aggregation → inactivity timeout → backlight fade/wake, first-touch suppression
translationsmain/modules/translations/ESP3DTranslationService — LNG1 blob binary search in mmapped flash, English .rodata fallback, SD-card language pack update

ConstraintDetail
LVGL runs on Core 1 onlyNever call LVGL APIs from Core 0 tasks or ISRs
ESP3DValues::handle() called from LVGL taskAll subscriber callbacks are therefore UI-safe
Log macros compile to zero at ESP3D_LOG=0Always wrap in {} to prevent dangling if when logging is stripped
NVS writes serialized by mutexNon-recursive; never call write from within a read callback
Buffer pool single-block allocationMinimizes heap fragmentation on ~10 KB available heap (BT mode)
std::string in hot paths forbiddenUse snprintf into fixed buffers; protect any std::string with try/catch(std::bad_alloc)

DocumentContent
docs/guides/esp32_memory_constraints.mdHeap fragmentation playbook; worst-case RAM budgets per config
docs/guides/esp3d_log_guide.mdLog macro levels, backend selection, runtime hook registration
docs/architecture/connection_management.mdHow transports set connection_status and server_status observable values
docs/architecture/gcode_host_architecture.mdHow GCode handlers write CNC values into ESP3DValues
docs/architecture/screens_architecture.mdHow UI screens subscribe to values and respond via callbacks
docs/ui_resources/development.mdui_resources partition format; font/image/language blob pipeline
docs/features/feature_resource_matrix.mdFeature-flag compatibility matrix; mutual exclusion rules
cmake/sanity_check.cmakeBuild-time enforcement of feature flag constraints