diff --git a/.github/workflows/modem_sim__build.yml b/.github/workflows/modem_sim__build.yml index ea4721dd10..fcaa2a1a67 100644 --- a/.github/workflows/modem_sim__build.yml +++ b/.github/workflows/modem_sim__build.yml @@ -27,6 +27,6 @@ jobs: export IDF_PATH=$GITHUB_WORKSPACE/idf ${IDF_PATH}/install.sh cd common_components/modem_sim - ./install.sh + ./install.sh PLATFORM_ESP32C6 ESP32C6-4MB 16 17 source export.sh idf.py build diff --git a/common_components/modem_sim/sdkconfig.defaults b/common_components/modem_sim/esp32.sdkconfig.defaults similarity index 100% rename from common_components/modem_sim/sdkconfig.defaults rename to common_components/modem_sim/esp32.sdkconfig.defaults diff --git a/common_components/modem_sim/esp32c6.sdkconfig.defaults b/common_components/modem_sim/esp32c6.sdkconfig.defaults new file mode 100644 index 0000000000..6487ba9f44 --- /dev/null +++ b/common_components/modem_sim/esp32c6.sdkconfig.defaults @@ -0,0 +1,63 @@ +# This file was generated using idf.py save-defconfig. It can be edited manually. +# Espressif IoT Development Framework (ESP-IDF) 5.4.1 Project Minimal Configuration +# +CONFIG_IDF_TARGET="esp32c6" +CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y +CONFIG_APP_PROJECT_VER_FROM_CONFIG=y +CONFIG_APP_PROJECT_VER="v4.1.0.0-dev" +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="module_config/module_esp32c6_default/partitions_at.csv" +CONFIG_PARTITION_TABLE_MD5=n +CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE="module_config/module_esp32c6_default/at_customize.csv" +CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_OFFSET=0x1e000 +CONFIG_ESP_TLS_PSK_VERIFICATION=y +CONFIG_ESP_TLS_INSECURE=y +CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y +CONFIG_ESP_ERR_TO_NAME_LOOKUP=n +CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 +CONFIG_HTTPD_MAX_URI_LEN=1024 +CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP=y +CONFIG_RTC_CLK_SRC_EXT_CRYS=y +CONFIG_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP_PHY_MAC_BB_PD=y +CONFIG_PM_ENABLE=y +CONFIG_PM_DFS_INIT_AUTO=y +CONFIG_ESP_TASK_WDT_PANIC=y +CONFIG_ESP_TASK_WDT_TIMEOUT_S=60 +CONFIG_ESP_DEBUG_OCDAWARE=n +CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT=y +CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 +CONFIG_FATFS_LFN_HEAP=y +CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=n +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_LOG_DEFAULT_LEVEL_ERROR=y +CONFIG_LWIP_MAX_SOCKETS=16 +CONFIG_LWIP_SO_LINGER=y +CONFIG_LWIP_SO_RCVBUF=y +CONFIG_LWIP_IP4_REASSEMBLY=y +CONFIG_LWIP_IP6_REASSEMBLY=y +CONFIG_LWIP_IPV6_AUTOCONFIG=y +CONFIG_LWIP_TCP_MAXRTX=6 +CONFIG_LWIP_TCP_SYNMAXRTX=3 +CONFIG_LWIP_PPP_SUPPORT=y +CONFIG_LWIP_PPP_SERVER_SUPPORT=y +CONFIG_LWIP_SNTP_MAX_SERVERS=3 +CONFIG_LWIP_SNTP_STARTUP_DELAY=n +CONFIG_MBEDTLS_DYNAMIC_BUFFER=y +CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=n +CONFIG_MBEDTLS_HAVE_TIME_DATE=y +CONFIG_MBEDTLS_DHM_C=y +CONFIG_NEWLIB_NANO_FORMAT=y +CONFIG_VFS_SUPPORT_TERMIOS=n +CONFIG_WL_SECTOR_SIZE_512=y +CONFIG_AT_PROCESS_TASK_STACK_SIZE=6144 +CONFIG_AT_MDNS_COMMAND_SUPPORT=n +CONFIG_AT_WPS_COMMAND_SUPPORT=n +CONFIG_AT_SMARTCONFIG_COMMAND_SUPPORT=n +CONFIG_AT_PING_COMMAND_SUPPORT=n +CONFIG_LWIP_IP_FORWARD=y +CONFIG_LWIP_IPV4_NAPT=y diff --git a/common_components/modem_sim/install.sh b/common_components/modem_sim/install.sh index 2f39e9d315..78d6e85e9b 100755 --- a/common_components/modem_sim/install.sh +++ b/common_components/modem_sim/install.sh @@ -2,9 +2,10 @@ set -e # Create directory "modem_sim_esp32", go inside it -# Usage: ./install.sh [platform] [module] +# Usage: ./install.sh [platform] [module] [uart_tx_pin] [uart_rx_pin] SCRIPT_DIR=$(pwd) +UPDATE_UART_PINS_SCRIPT="$(cd "$(dirname "$0")" && pwd)/update_uart_pins.py" mkdir -p modem_sim_esp32 cd modem_sim_esp32 @@ -39,6 +40,8 @@ mkdir -p build # Default values for platform and module platform="PLATFORM_ESP32" module="WROOM-32" +uart_tx_pin="" +uart_rx_pin="" # Override defaults if parameters are provided if [ ! -z "$1" ]; then @@ -47,18 +50,49 @@ fi if [ ! -z "$2" ]; then module="$2" fi +if [ ! -z "$3" ]; then + uart_tx_pin="$3" +fi +if [ ! -z "$4" ]; then + uart_rx_pin="$4" +fi + +target="${platform##*_}" +target="${target,,}" + +# Use provided pins for description when present; otherwise keep defaults +description="4MB, Wi-Fi + BLE, OTA, TX:17 RX:16" +if [ -n "$uart_tx_pin" ] || [ -n "$uart_rx_pin" ]; then + desc_tx=${uart_tx_pin:-17} + desc_rx=${uart_rx_pin:-16} + description="4MB, Wi-Fi + BLE, OTA, TX:${desc_tx} RX:${desc_rx}" +fi # Create file "build/module_info.json" with content cat > build/module_info.json << EOF { "platform": "$platform", "module": "$module", - "description": "4MB, Wi-Fi + BLE, OTA, TX:17 RX:16", + "description": "$description", "silence": 0 } EOF -cp "$SCRIPT_DIR/sdkconfig.defaults" "module_config/module_esp32_default/sdkconfig.defaults" +# Optionally update UART pins in factory_param_data.csv for the selected module +if [ -n "$uart_tx_pin" ] || [ -n "$uart_rx_pin" ]; then + csv_path="components/customized_partitions/raw_data/factory_param/factory_param_data.csv" + if [ ! -f "$csv_path" ]; then + echo "Warning: $csv_path not found; skipping UART pin update." + else + python3 "$UPDATE_UART_PINS_SCRIPT" "$platform" "$module" "$uart_tx_pin" "$uart_rx_pin" "$csv_path" + echo "Updated UART pins in $csv_path" + fi +fi + +# Copy the platform-specific sdkconfig.defaults file if it exists +if [ -f "$SCRIPT_DIR/${target}.sdkconfig.defaults" ]; then + cp "$SCRIPT_DIR/${target}.sdkconfig.defaults" "module_config/module_${target}_default/sdkconfig.defaults" +fi echo "Installation completed successfully!" echo "Created modem_sim_esp32 directory with esp-at repository and configuration" diff --git a/common_components/modem_sim/update_uart_pins.py b/common_components/modem_sim/update_uart_pins.py new file mode 100644 index 0000000000..ca705b56f1 --- /dev/null +++ b/common_components/modem_sim/update_uart_pins.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Unlicense OR CC0-1.0 +import csv +import pathlib +import sys + + +def update_uart_pins(platform: str, module: str, tx_pin: str, rx_pin: str, csv_path: str) -> None: + path = pathlib.Path(csv_path) + rows = [] + found = False + + with path.open(newline="") as f: + reader = csv.DictReader(f) + fieldnames = reader.fieldnames + for row in reader: + if row.get("platform") == platform and row.get("module_name") == module: + if tx_pin: + row["uart_tx_pin"] = tx_pin + if rx_pin: + row["uart_rx_pin"] = rx_pin + found = True + rows.append(row) + + if not found: + print(f"Warning: no row updated for platform={platform} module={module}") + + with path.open("w", newline="") as f: + writer = csv.DictWriter(f, fieldnames=fieldnames) + writer.writeheader() + writer.writerows(rows) + + +def main() -> int: + if len(sys.argv) != 6: + print("Usage: update_uart_pins.py ") + return 1 + + platform, module, tx_pin, rx_pin, csv_path = sys.argv[1:6] + update_uart_pins(platform, module, tx_pin, rx_pin, csv_path) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())