Skip to content

Commit

Permalink
Merge branch 'feat/support_configure_rcp_dir' into 'main'
Browse files Browse the repository at this point in the history
feat(rcp update): support configuring rcp source path

See merge request espressif/esp-thread-br!135
  • Loading branch information
chshu committed Aug 14, 2024
2 parents 95e7ec4 + afe6ee1 commit aa68a59
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
12 changes: 7 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ check_build_result:
script:
- *submodule_update
- chmod 700 ./check_components_version.sh
- ALLOW_FAILURE_OUTPUT=$(./check_components_version.sh)
- echo "$ALLOW_FAILURE_OUTPUT"
- ALLOW_FAILURE_VALUE=$(echo "$ALLOW_FAILURE_OUTPUT" | cut -d'=' -f2)
- echo "ALLOW_FAILURE_VALUE=$ALLOW_FAILURE_VALUE"
- ALLOW_EXT_CMD_FAILURE_OUTPUT=$(./check_components_version.sh "components/esp_ot_cli_extension")
- ALLOW_EXT_CMD_FAILURE_VALUE=$(echo "$ALLOW_EXT_CMD_FAILURE_OUTPUT" | cut -d'=' -f2)
- echo "ALLOW_EXT_CMD_FAILURE_VALUE=$ALLOW_EXT_CMD_FAILURE_VALUE"
- ALLOW_RCP_UPDATE_FAILURE_OUTPUT=$(./check_components_version.sh "components/esp_rcp_update")
- ALLOW_RCP_UPDATE_FAILURE_VALUE=$(echo "$ALLOW_RCP_UPDATE_FAILURE_OUTPUT" | cut -d'=' -f2)
- echo "ALLOW_RCP_UPDATE_FAILURE_VALUE=$ALLOW_RCP_UPDATE_FAILURE_VALUE"
- |
if [ "$ALLOW_FAILURE_VALUE" == "true" ]; then
if [ "$ALLOW_EXT_CMD_FAILURE_VALUE" == "true" ] || [ "$ALLOW_RCP_UPDATE_FAILURE_VALUE" == "true" ]; then
echo "allow failure"
exit 0;
else
Expand Down
10 changes: 5 additions & 5 deletions check_components_version.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

export ESP_EXTCMD_COMPONENTS_PATH="components/esp_ot_cli_extension"
export ESP_COMPONENTS_PATH="$1"

if git diff --name-only HEAD~1 | grep -q "${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml"; then
OLD_VERSION=$(git show HEAD~1:${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml | grep -m 1 "^version: " | awk '{print $2}' | tr -d '"')
NEW_VERSION=$(head -n 1 ${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml | grep "^version: " | awk '{print $2}' | tr -d '"')
if git diff --name-only HEAD~1 | grep -q "${ESP_COMPONENTS_PATH}/idf_component.yml"; then
OLD_VERSION=$(git show HEAD~1:${ESP_COMPONENTS_PATH}/idf_component.yml | grep -m 1 "^version: " | awk '{print $2}' | tr -d '"')
NEW_VERSION=$(head -n 1 ${ESP_COMPONENTS_PATH}/idf_component.yml | grep "^version: " | awk '{print $2}' | tr -d '"')
if [ -z "$OLD_VERSION" ] || [ -z "$NEW_VERSION" ]; then
echo "Error: version not found or incorrect format in ${ESP_EXTCMD_COMPONENTS_PATH}/idf_component.yml"
echo "Error: version not found or incorrect format in ${ESP_COMPONENTS_PATH}/idf_component.yml"
exit 1
fi
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
Expand Down
6 changes: 3 additions & 3 deletions components/esp_rcp_update/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ idf_build_get_property(python PYTHON)
if(CONFIG_AUTO_UPDATE_RCP)
add_custom_target(rcp_image_generation ALL
COMMAND ${python} ${CMAKE_CURRENT_SOURCE_DIR}/create_ota_image.py
--rcp-build-dir $ENV{IDF_PATH}/examples/openthread/ot_rcp/build
--rcp-build-dir ${CONFIG_RCP_SRC_DIR}
--target-file ${CMAKE_CURRENT_BINARY_DIR}/spiffs_image/ot_rcp_0/rcp_image
)

spiffs_create_partition_image(rcp_fw ${CMAKE_CURRENT_BINARY_DIR}/spiffs_image FLASH_IN_PROJECT
spiffs_create_partition_image(${CONFIG_RCP_PARTITION_NAME} ${CMAKE_CURRENT_BINARY_DIR}/spiffs_image FLASH_IN_PROJECT
DEPENDS rcp_image_generation)
endif()

if(CONFIG_CREATE_OTA_IMAGE_WITH_RCP_FW)
add_custom_command(OUTPUT ${build_dir}/ota_with_rcp_image
COMMAND ${python} ${CMAKE_CURRENT_SOURCE_DIR}/create_ota_image.py
--rcp-build-dir $ENV{IDF_PATH}/examples/openthread/ot_rcp/build
--rcp-build-dir ${CONFIG_RCP_SRC_DIR}
--target-file ${build_dir}/ota_with_rcp_image
--br-firmware "${build_dir}/${elf_name}.bin"
DEPENDS "${build_dir}/.bin_timestamp"
Expand Down
16 changes: 15 additions & 1 deletion components/esp_rcp_update/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu "OpenThread RCP Update"

config AUTO_UPDATE_RCP
bool 'Update RCP automatically'
default y
default n
help
If enabled, the device will store the RCP image in its firmware and
compare the stored image version with the running RCP image upon boot. The RCP
Expand All @@ -14,4 +14,18 @@ menu "OpenThread RCP Update"
help
If enabled, an ota image will be generated during building.

config RCP_SRC_DIR
depends on AUTO_UPDATE_RCP || CREATE_OTA_IMAGE_WITH_RCP_FW
string "Source folder containing the RCP firmware"
default "$ENV{IDF_PATH}/examples/openthread/ot_rcp/build"
help
The source folder containing the RCP firmware.

config RCP_PARTITION_NAME
depends on AUTO_UPDATE_RCP
string "Name of RCP storage partition"
default "rcp_fw"
help
The name of RCP storage partition.

endmenu
2 changes: 1 addition & 1 deletion components/esp_rcp_update/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "1.1.0"
version: "1.2.0"
description: Espressif RCP Update Component for Thread Border Router and Zigbee Gateway
url: https://github.com/espressif/esp-thread-br/tree/main/components/esp_rcp_update
dependencies:
Expand Down
6 changes: 4 additions & 2 deletions examples/basic_thread_border_router/main/esp_ot_br.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ extern const uint8_t server_cert_pem_end[] asm("_binary_ca_cert_pem_end");
static esp_err_t init_spiffs(void)
{
#if CONFIG_AUTO_UPDATE_RCP
esp_vfs_spiffs_conf_t rcp_fw_conf = {
.base_path = "/rcp_fw", .partition_label = "rcp_fw", .max_files = 10, .format_if_mount_failed = false};
esp_vfs_spiffs_conf_t rcp_fw_conf = {.base_path = "/" CONFIG_RCP_PARTITION_NAME,
.partition_label = CONFIG_RCP_PARTITION_NAME,
.max_files = 10,
.format_if_mount_failed = false};
ESP_RETURN_ON_ERROR(esp_vfs_spiffs_register(&rcp_fw_conf), TAG, "Failed to mount rcp firmware storage");
#endif
#if CONFIG_OPENTHREAD_BR_START_WEB
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_thread_border_router/main/esp_ot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
{ \
.rcp_type = RCP_TYPE_ESP32H2_UART, .uart_rx_pin = CONFIG_PIN_TO_RCP_TX, .uart_tx_pin = CONFIG_PIN_TO_RCP_RX, \
.uart_port = 1, .uart_baudrate = 115200, .reset_pin = CONFIG_PIN_TO_RCP_RESET, \
.boot_pin = CONFIG_PIN_TO_RCP_BOOT, .update_baudrate = 460800, .firmware_dir = "/rcp_fw/ot_rcp", \
.target_chip = ESP32H2_CHIP, \
.boot_pin = CONFIG_PIN_TO_RCP_BOOT, .update_baudrate = 460800, \
.firmware_dir = "/" CONFIG_RCP_PARTITION_NAME "/ot_rcp", .target_chip = ESP32H2_CHIP, \
}

#if CONFIG_OPENTHREAD_CONSOLE_TYPE_UART
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_thread_border_router/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
dependencies:
espressif/mdns: "^1.0.0"
espressif/esp_ot_cli_extension: "~1.1.0"
espressif/esp_rcp_update: "~1.1.0"
espressif/esp_rcp_update: "~1.2.0"
## Required IDF version
idf:
version: ">=4.1.0"
Expand Down

0 comments on commit aa68a59

Please sign in to comment.