scripts: P4-Nano probe app and C6 esp-hosted OTA tools
p4-probe identifies the P4 and its C6 over esp-hosted SDIO. c6-ota holds the C6 coprocessor build and the two host updaters (3.1 and the 2.x one that moved the factory C6 firmware to esp-hosted 3.1). Also the pending graphify output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
edf35e9c71
commit
ba8e160aee
104 files changed
+8674
-204
No files matched your search
@@ -0,0 +1,64 @@
|
||||
# Common script to find the newest firmware file dynamically during build
|
||||
# This runs every time during build, not just during configuration
|
||||
#
|
||||
# Required input variables:
|
||||
# - SOURCE_COMPONENT_DIR: Path to the component source directory
|
||||
# - BINARY_COMPONENT_DIR: Path to the component binary directory
|
||||
# - OTA_ACTION: "prepare_littlefs" or "select_for_partition"
|
||||
#
|
||||
# Optional input variables:
|
||||
# - COMPONENT_NAME: Name for logging (default: "OTA")
|
||||
|
||||
if(NOT DEFINED COMPONENT_NAME)
|
||||
set(COMPONENT_NAME "OTA")
|
||||
endif()
|
||||
|
||||
# Use the passed component directories
|
||||
set(SOURCE_DIR "${SOURCE_COMPONENT_DIR}/slave_fw_bin")
|
||||
set(TEMP_DIR "${BINARY_COMPONENT_DIR}/temp_littlefs")
|
||||
|
||||
message(STATUS "${COMPONENT_NAME}: Dynamically searching for newest firmware...")
|
||||
message(STATUS "${COMPONENT_NAME}: Searching in ${SOURCE_DIR}")
|
||||
|
||||
# Get all .bin files
|
||||
file(GLOB FIRMWARE_FILES "${SOURCE_DIR}/*.bin")
|
||||
|
||||
if(NOT FIRMWARE_FILES)
|
||||
message(FATAL_ERROR "${COMPONENT_NAME}: No .bin files found in ${SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Find the newest file by timestamp
|
||||
set(NEWEST_FILE "")
|
||||
set(NEWEST_TIMESTAMP 0)
|
||||
|
||||
foreach(FIRMWARE_FILE ${FIRMWARE_FILES})
|
||||
file(TIMESTAMP "${FIRMWARE_FILE}" FILE_TIMESTAMP "%s")
|
||||
message(STATUS "${COMPONENT_NAME}: File ${FIRMWARE_FILE} timestamp: ${FILE_TIMESTAMP}")
|
||||
if(FILE_TIMESTAMP GREATER NEWEST_TIMESTAMP)
|
||||
set(NEWEST_FILE "${FIRMWARE_FILE}")
|
||||
set(NEWEST_TIMESTAMP "${FILE_TIMESTAMP}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
get_filename_component(NEWEST_FILENAME "${NEWEST_FILE}" NAME)
|
||||
message(STATUS "${COMPONENT_NAME}: Selected newest firmware: ${NEWEST_FILENAME}")
|
||||
|
||||
# Perform the requested action
|
||||
if(OTA_ACTION STREQUAL "prepare_littlefs")
|
||||
# Clean and recreate temp directory for LittleFS
|
||||
file(REMOVE_RECURSE "${TEMP_DIR}")
|
||||
file(MAKE_DIRECTORY "${TEMP_DIR}")
|
||||
file(COPY "${NEWEST_FILE}" DESTINATION "${TEMP_DIR}")
|
||||
message(STATUS "${COMPONENT_NAME}: Prepared ${NEWEST_FILENAME} in temp directory for LittleFS")
|
||||
|
||||
elseif(OTA_ACTION STREQUAL "select_for_partition")
|
||||
# Write selection to files for partition OTA
|
||||
file(WRITE "${BINARY_COMPONENT_DIR}/selected_firmware.txt" "${NEWEST_FILE}")
|
||||
file(WRITE "${BINARY_COMPONENT_DIR}/selected_firmware_name.txt" "${NEWEST_FILENAME}")
|
||||
message(STATUS "${COMPONENT_NAME}: Saved firmware selection for partition flashing")
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "${COMPONENT_NAME}: Unknown OTA_ACTION: ${OTA_ACTION}")
|
||||
endif()
|
||||
|
||||
message(STATUS "${COMPONENT_NAME}: Firmware selection completed")
|
||||
@@ -0,0 +1,61 @@
|
||||
# Script to flash the dynamically selected firmware for partition OTA
|
||||
# Reads the firmware path from the selection file and flashes it
|
||||
#
|
||||
# Required input variables:
|
||||
# - BINARY_COMPONENT_DIR: Path to the component binary directory
|
||||
# - SLAVE_FW_OFFSET: Partition offset for flashing
|
||||
# - PYTHON: Python executable path
|
||||
|
||||
if(NOT DEFINED COMPONENT_NAME)
|
||||
set(COMPONENT_NAME "Partition OTA")
|
||||
endif()
|
||||
|
||||
# Read the selected firmware path and name
|
||||
set(SELECTION_FILE "${BINARY_COMPONENT_DIR}/selected_firmware.txt")
|
||||
set(NAME_FILE "${BINARY_COMPONENT_DIR}/selected_firmware_name.txt")
|
||||
|
||||
if(NOT EXISTS "${SELECTION_FILE}")
|
||||
message(FATAL_ERROR "${COMPONENT_NAME}: Selection file not found: ${SELECTION_FILE}")
|
||||
endif()
|
||||
|
||||
file(READ "${SELECTION_FILE}" SELECTED_FIRMWARE_PATH)
|
||||
file(READ "${NAME_FILE}" SELECTED_FIRMWARE_NAME)
|
||||
|
||||
# Remove any trailing newlines
|
||||
string(STRIP "${SELECTED_FIRMWARE_PATH}" SELECTED_FIRMWARE_PATH)
|
||||
string(STRIP "${SELECTED_FIRMWARE_NAME}" SELECTED_FIRMWARE_NAME)
|
||||
|
||||
message(STATUS "-----------------------------------------------------")
|
||||
message(STATUS "${COMPONENT_NAME}: Flashing ${SELECTED_FIRMWARE_NAME}")
|
||||
message(STATUS "Path: ${SELECTED_FIRMWARE_PATH}")
|
||||
message(STATUS "Offset: ${SLAVE_FW_OFFSET}")
|
||||
message(STATUS "-----------------------------------------------------")
|
||||
|
||||
# Check if file exists
|
||||
if(NOT EXISTS "${SELECTED_FIRMWARE_PATH}")
|
||||
message(FATAL_ERROR "❌ ERROR: Selected firmware file not found: ${SELECTED_FIRMWARE_PATH}")
|
||||
endif()
|
||||
|
||||
# Execute esptool (this will inherit the port from the parent build process)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON} -m esptool
|
||||
-b 2000000
|
||||
write_flash
|
||||
--force
|
||||
${SLAVE_FW_OFFSET} "${SELECTED_FIRMWARE_PATH}"
|
||||
RESULT_VARIABLE FLASH_RESULT
|
||||
OUTPUT_VARIABLE FLASH_OUTPUT
|
||||
ERROR_VARIABLE FLASH_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(FLASH_OUTPUT)
|
||||
message(STATUS "${FLASH_OUTPUT}")
|
||||
endif()
|
||||
|
||||
if(NOT FLASH_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR "❌ ERROR: Failed to flash firmware:\n${FLASH_ERROR}")
|
||||
endif()
|
||||
|
||||
message(STATUS "✅ Successfully flashed ${SELECTED_FIRMWARE_NAME} to partition!")
|
||||
Reference in new issue
Block a user