Skip to content

Commit fd2118d

Browse files
committed
fix(modem_sim): Add support to setup initial uart pins
1 parent 25513d0 commit fd2118d

File tree

4 files changed

+144
-3
lines changed

4 files changed

+144
-3
lines changed
File renamed without changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) 5.4.1 Project Minimal Configuration
3+
#
4+
CONFIG_IDF_TARGET="esp32c6"
5+
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
6+
CONFIG_APP_PROJECT_VER_FROM_CONFIG=y
7+
CONFIG_APP_PROJECT_VER="v4.1.0.0-dev"
8+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
9+
CONFIG_PARTITION_TABLE_CUSTOM=y
10+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="module_config/module_esp32c6_default/partitions_at.csv"
11+
CONFIG_PARTITION_TABLE_MD5=n
12+
CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE="module_config/module_esp32c6_default/at_customize.csv"
13+
CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_OFFSET=0x1e000
14+
CONFIG_ESP_TLS_PSK_VERIFICATION=y
15+
CONFIG_ESP_TLS_INSECURE=y
16+
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y
17+
CONFIG_ESP_ERR_TO_NAME_LOOKUP=n
18+
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
19+
CONFIG_HTTPD_MAX_URI_LEN=1024
20+
CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP=y
21+
CONFIG_RTC_CLK_SRC_EXT_CRYS=y
22+
CONFIG_RTC_CLK_CAL_CYCLES=1024
23+
CONFIG_ESP_PHY_MAC_BB_PD=y
24+
CONFIG_PM_ENABLE=y
25+
CONFIG_PM_DFS_INIT_AUTO=y
26+
CONFIG_ESP_TASK_WDT_PANIC=y
27+
CONFIG_ESP_TASK_WDT_TIMEOUT_S=60
28+
CONFIG_ESP_DEBUG_OCDAWARE=n
29+
CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT=y
30+
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0
31+
CONFIG_FATFS_LFN_HEAP=y
32+
CONFIG_FREERTOS_HZ=1000
33+
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
34+
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=n
35+
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
36+
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
37+
CONFIG_LWIP_MAX_SOCKETS=16
38+
CONFIG_LWIP_SO_LINGER=y
39+
CONFIG_LWIP_SO_RCVBUF=y
40+
CONFIG_LWIP_IP4_REASSEMBLY=y
41+
CONFIG_LWIP_IP6_REASSEMBLY=y
42+
CONFIG_LWIP_IPV6_AUTOCONFIG=y
43+
CONFIG_LWIP_TCP_MAXRTX=6
44+
CONFIG_LWIP_TCP_SYNMAXRTX=3
45+
CONFIG_LWIP_PPP_SUPPORT=y
46+
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
47+
CONFIG_LWIP_SNTP_MAX_SERVERS=3
48+
CONFIG_LWIP_SNTP_STARTUP_DELAY=n
49+
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
50+
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
51+
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=n
52+
CONFIG_MBEDTLS_HAVE_TIME_DATE=y
53+
CONFIG_MBEDTLS_DHM_C=y
54+
CONFIG_NEWLIB_NANO_FORMAT=y
55+
CONFIG_VFS_SUPPORT_TERMIOS=n
56+
CONFIG_WL_SECTOR_SIZE_512=y
57+
CONFIG_AT_PROCESS_TASK_STACK_SIZE=6144
58+
CONFIG_AT_MDNS_COMMAND_SUPPORT=n
59+
CONFIG_AT_WPS_COMMAND_SUPPORT=n
60+
CONFIG_AT_SMARTCONFIG_COMMAND_SUPPORT=n
61+
CONFIG_AT_PING_COMMAND_SUPPORT=n

common_components/modem_sim/install.sh

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
set -e
33

44
# Create directory "modem_sim_esp32", go inside it
5-
# Usage: ./install.sh [platform] [module]
5+
# Usage: ./install.sh [platform] [module] [uart_tx_pin] [uart_rx_pin]
66

77
SCRIPT_DIR=$(pwd)
8+
UPDATE_UART_PINS_SCRIPT="$(cd "$(dirname "$0")" && pwd)/update_uart_pins.py"
89
mkdir -p modem_sim_esp32
910
cd modem_sim_esp32
1011

@@ -39,6 +40,8 @@ mkdir -p build
3940
# Default values for platform and module
4041
platform="PLATFORM_ESP32"
4142
module="WROOM-32"
43+
uart_tx_pin=""
44+
uart_rx_pin=""
4245

4346
# Override defaults if parameters are provided
4447
if [ ! -z "$1" ]; then
@@ -47,18 +50,49 @@ fi
4750
if [ ! -z "$2" ]; then
4851
module="$2"
4952
fi
53+
if [ ! -z "$3" ]; then
54+
uart_tx_pin="$3"
55+
fi
56+
if [ ! -z "$4" ]; then
57+
uart_rx_pin="$4"
58+
fi
59+
60+
target="${platform##*_}"
61+
target="${target,,}"
62+
63+
# Use provided pins for description when present; otherwise keep defaults
64+
description="4MB, Wi-Fi + BLE, OTA, TX:17 RX:16"
65+
if [ -n "$uart_tx_pin" ] || [ -n "$uart_rx_pin" ]; then
66+
desc_tx=${uart_tx_pin:-17}
67+
desc_rx=${uart_rx_pin:-16}
68+
description="4MB, Wi-Fi + BLE, OTA, TX:${desc_tx} RX:${desc_rx}"
69+
fi
5070

5171
# Create file "build/module_info.json" with content
5272
cat > build/module_info.json << EOF
5373
{
5474
"platform": "$platform",
5575
"module": "$module",
56-
"description": "4MB, Wi-Fi + BLE, OTA, TX:17 RX:16",
76+
"description": "$description",
5777
"silence": 0
5878
}
5979
EOF
6080

61-
cp "$SCRIPT_DIR/sdkconfig.defaults" "module_config/module_esp32_default/sdkconfig.defaults"
81+
# Optionally update UART pins in factory_param_data.csv for the selected module
82+
if [ -n "$uart_tx_pin" ] || [ -n "$uart_rx_pin" ]; then
83+
csv_path="components/customized_partitions/raw_data/factory_param/factory_param_data.csv"
84+
if [ ! -f "$csv_path" ]; then
85+
echo "Warning: $csv_path not found; skipping UART pin update."
86+
else
87+
python3 "$UPDATE_UART_PINS_SCRIPT" "$platform" "$module" "$uart_tx_pin" "$uart_rx_pin" "$csv_path"
88+
echo "Updated UART pins in $csv_path"
89+
fi
90+
fi
91+
92+
# Copy the platform-specific sdkconfig.defaults file if it exists
93+
if [ -f "$SCRIPT_DIR/${target}.sdkconfig.defaults" ]; then
94+
cp "$SCRIPT_DIR/${target}.sdkconfig.defaults" "module_config/module_${target}_default/sdkconfig.defaults"
95+
fi
6296

6397
echo "Installation completed successfully!"
6498
echo "Created modem_sim_esp32 directory with esp-at repository and configuration"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
# SPDX-License-Identifier: Unlicense OR CC0-1.0
4+
import csv
5+
import pathlib
6+
import sys
7+
8+
9+
def update_uart_pins(platform: str, module: str, tx_pin: str, rx_pin: str, csv_path: str) -> None:
10+
path = pathlib.Path(csv_path)
11+
rows = []
12+
found = False
13+
14+
with path.open(newline="") as f:
15+
reader = csv.DictReader(f)
16+
fieldnames = reader.fieldnames
17+
for row in reader:
18+
if row.get("platform") == platform and row.get("module_name") == module:
19+
if tx_pin:
20+
row["uart_tx_pin"] = tx_pin
21+
if rx_pin:
22+
row["uart_rx_pin"] = rx_pin
23+
found = True
24+
rows.append(row)
25+
26+
if not found:
27+
print(f"Warning: no row updated for platform={platform} module={module}")
28+
29+
with path.open("w", newline="") as f:
30+
writer = csv.DictWriter(f, fieldnames=fieldnames)
31+
writer.writeheader()
32+
writer.writerows(rows)
33+
34+
35+
def main() -> int:
36+
if len(sys.argv) != 6:
37+
print("Usage: update_uart_pins.py <platform> <module> <uart_tx_pin> <uart_rx_pin> <csv_path>")
38+
return 1
39+
40+
platform, module, tx_pin, rx_pin, csv_path = sys.argv[1:6]
41+
update_uart_pins(platform, module, tx_pin, rx_pin, csv_path)
42+
return 0
43+
44+
45+
if __name__ == "__main__":
46+
raise SystemExit(main())

0 commit comments

Comments
 (0)