From 95c91e3d654fc058fe24f7cb96db86306f30ab14 Mon Sep 17 00:00:00 2001 From: Maciej Baczmanski Date: Mon, 12 Aug 2024 13:32:19 +0200 Subject: [PATCH] Refactor ncs build script Refactor ncs build script to reduce build time and align with ot building calls. Signed-off-by: Maciej Baczmanski --- config/ncs/overlay-ot-cli-1_4.conf | 44 ----- ...i-1_1.conf => overlay-ot-cli-ftd-1.1.conf} | 0 ...i-1_2.conf => overlay-ot-cli-ftd-1.2.conf} | 0 ...i-1_3.conf => overlay-ot-cli-ftd-1.3.conf} | 0 ...i-1_4.conf => overlay-ot-cli-ftd-1.4.conf} | 0 ...y-rcp-1_2.conf => overlay-ot-rcp-1.2.conf} | 0 ...y-rcp-1_3.conf => overlay-ot-rcp-1.3.conf} | 0 ...t-rcp-1_4.conf => overlay-ot-rcp-1.4.conf} | 0 config/ncs/overlay-rcp-1_4.conf | 28 ---- script/make-firmware.bash | 157 +++++++++--------- 10 files changed, 76 insertions(+), 153 deletions(-) delete mode 100644 config/ncs/overlay-ot-cli-1_4.conf rename config/ncs/{overlay-cli-1_1.conf => overlay-ot-cli-ftd-1.1.conf} (100%) rename config/ncs/{overlay-cli-1_2.conf => overlay-ot-cli-ftd-1.2.conf} (100%) rename config/ncs/{overlay-cli-1_3.conf => overlay-ot-cli-ftd-1.3.conf} (100%) rename config/ncs/{overlay-cli-1_4.conf => overlay-ot-cli-ftd-1.4.conf} (100%) rename config/ncs/{overlay-rcp-1_2.conf => overlay-ot-rcp-1.2.conf} (100%) rename config/ncs/{overlay-rcp-1_3.conf => overlay-ot-rcp-1.3.conf} (100%) rename config/ncs/{overlay-ot-rcp-1_4.conf => overlay-ot-rcp-1.4.conf} (100%) delete mode 100644 config/ncs/overlay-rcp-1_4.conf diff --git a/config/ncs/overlay-ot-cli-1_4.conf b/config/ncs/overlay-ot-cli-1_4.conf deleted file mode 100644 index 77b9dcc..0000000 --- a/config/ncs/overlay-ot-cli-1_4.conf +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright (c) 2024 Nordic Semiconductor -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Enable reference device -CONFIG_OPENTHREAD_REFERENCE_DEVICE=y - -# Enable OpenThread features set for Thread 1.4 -CONFIG_OPENTHREAD_THREAD_VERSION_1_4=y -CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y - -# Disable most of the logging -CONFIG_LOG_MODE_DEFERRED=y -CONFIG_BOOT_BANNER=n -CONFIG_LOG=y -CONFIG_NET_LOG=n -CONFIG_NET_STATISTICS=n -CONFIG_OPENTHREAD_DEBUG=n -CONFIG_OPENTHREAD_L2_DEBUG=y - -# Shell configuration for harness -CONFIG_SHELL_PROMPT_UART="" -CONFIG_SHELL_VT100_COLORS=n -CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=1024 -CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024 -CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH=640 -CONFIG_SHELL_CMD_BUFF_SIZE=640 -CONFIG_OPENTHREAD_CLI_MAX_LINE_LENGTH=640 - -# Number of external addresses -CONFIG_OPENTHREAD_IP6_MAX_EXT_MCAST_ADDRS=4 - -# Increase stack -CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2144 - -# Set USB device PID -CONFIG_USB_DEVICE_PID=0xCAFF - -# Configure Thread 1.2 features -CONFIG_OPENTHREAD_CSL_AUTO_SYNC=n -CONFIG_OPENTHREAD_MIN_RECEIVE_ON_AHEAD=104 -CONFIG_OPENTHREAD_MIN_RECEIVE_ON_AFTER=0 diff --git a/config/ncs/overlay-cli-1_1.conf b/config/ncs/overlay-ot-cli-ftd-1.1.conf similarity index 100% rename from config/ncs/overlay-cli-1_1.conf rename to config/ncs/overlay-ot-cli-ftd-1.1.conf diff --git a/config/ncs/overlay-cli-1_2.conf b/config/ncs/overlay-ot-cli-ftd-1.2.conf similarity index 100% rename from config/ncs/overlay-cli-1_2.conf rename to config/ncs/overlay-ot-cli-ftd-1.2.conf diff --git a/config/ncs/overlay-cli-1_3.conf b/config/ncs/overlay-ot-cli-ftd-1.3.conf similarity index 100% rename from config/ncs/overlay-cli-1_3.conf rename to config/ncs/overlay-ot-cli-ftd-1.3.conf diff --git a/config/ncs/overlay-cli-1_4.conf b/config/ncs/overlay-ot-cli-ftd-1.4.conf similarity index 100% rename from config/ncs/overlay-cli-1_4.conf rename to config/ncs/overlay-ot-cli-ftd-1.4.conf diff --git a/config/ncs/overlay-rcp-1_2.conf b/config/ncs/overlay-ot-rcp-1.2.conf similarity index 100% rename from config/ncs/overlay-rcp-1_2.conf rename to config/ncs/overlay-ot-rcp-1.2.conf diff --git a/config/ncs/overlay-rcp-1_3.conf b/config/ncs/overlay-ot-rcp-1.3.conf similarity index 100% rename from config/ncs/overlay-rcp-1_3.conf rename to config/ncs/overlay-ot-rcp-1.3.conf diff --git a/config/ncs/overlay-ot-rcp-1_4.conf b/config/ncs/overlay-ot-rcp-1.4.conf similarity index 100% rename from config/ncs/overlay-ot-rcp-1_4.conf rename to config/ncs/overlay-ot-rcp-1.4.conf diff --git a/config/ncs/overlay-rcp-1_4.conf b/config/ncs/overlay-rcp-1_4.conf deleted file mode 100644 index 514c439..0000000 --- a/config/ncs/overlay-rcp-1_4.conf +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (c) 2024 Nordic Semiconductor -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Enable reference device -CONFIG_OPENTHREAD_REFERENCE_DEVICE=y - -# Enable OpenThread features set for Thread 1.4 -CONFIG_OPENTHREAD_THREAD_VERSION_1_4=y -CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y - -# Enable RCP coprocessor -CONFIG_OPENTHREAD_COPROCESSOR_RCP=y - -# Set USB device PID -CONFIG_USB_DEVICE_PID=0xCAFF - -# Configure logging -CONFIG_LOG=y -CONFIG_LOG_BACKEND_SPINEL=y -CONFIG_LOG_BACKEND_UART=n - -# Configure Thread 1.2 features -CONFIG_OPENTHREAD_CSL_AUTO_SYNC=n -CONFIG_OPENTHREAD_MIN_RECEIVE_ON_AHEAD=104 -CONFIG_OPENTHREAD_MIN_RECEIVE_ON_AFTER=0 diff --git a/script/make-firmware.bash b/script/make-firmware.bash index ccbb0b5..fcd463e 100755 --- a/script/make-firmware.bash +++ b/script/make-firmware.bash @@ -272,6 +272,70 @@ nrfutil_setup() fi } +deploy_ncs() +{ + local commit_hash + commit_hash=$(<"${script_dir}"'/../config/ncs/sdk-nrf-commit') + + sudo apt install --no-install-recommends git cmake ninja-build gperf \ + ccache dfu-util device-tree-compiler wget \ + python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ + make gcc gcc-multilib g++-multilib libsdl2-dev + pip3 install --user west + mkdir -p "${script_dir}"/../ncs + cd "${script_dir}"/../ncs + unset ZEPHYR_BASE + west init -m https://github.com/nrfconnect/sdk-nrf --mr main || true + cd nrf + git fetch origin + git reset --hard "$commit_hash" || die "ERROR: unable to checkout the specified sdk-nrf commit." + west update -n -o=--depth=1 + cd .. + pip3 install --user -r zephyr/scripts/requirements.txt + pip3 install --user -r nrf/scripts/requirements.txt + pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt + + # shellcheck disable=SC1091 + source zephyr/zephyr-env.sh + west config manifest.path nrf +} + +build_ncs() +{ + mkdir -p "$OUTPUT_ROOT" + deploy_ncs + cd nrf + + thread_version=${thread_version?} + local timestamp=$(date +%Y%m%d) + local commit_id=$(git rev-parse --short HEAD) + + # variant is a list of entries: "app:sample_name" + local variants + case "${thread_version}" in + 1.1) + variants=("ot-cli-ftd:cli") + ;; + *) + variants=("ot-cli-ftd:cli" "ot-rcp:coprocessor") + ;; + + esac + + for variant in "${variants[@]}"; do + local app=$(echo $variant | cut -d':' -f1) + local sample_name=$(echo $variant | cut -d':' -f2) + local sample_path="samples/openthread/${sample_name}" + local sample_config="${script_dir}/../config/ncs/overlay-${app}-${thread_version}.conf" + local build_path="/tmp/ncs_${app}_${thread_version}" + local hex_path="${build_path}/${sample_name}/zephyr/zephyr.hex" + + west build -d "${build_path}" -b nrf52840dongle/nrf52840 -p always "${sample_path}" --sysbuild -- -DOVERLAY_CONFIG="${sample_config}" + + distribute "${hex_path}" "${app}" "${thread_version}" "${timestamp}" "${commit_id}" + done +} + build() { if [ "${REFERENCE_RELEASE_TYPE?}" = "1.2" ]; then @@ -287,6 +351,10 @@ build() thread_version=1.2 build_type="USB_trans" build_ot "${build_1_2_options[@]}" "$@" thread_version=1.1 build_type="USB_trans" build_ot "${build_1_1_env[@]}" "$@" ;; + ncs) + thread_version=1.2 build_ncs + thread_version=1.1 build_ncs + ;; esac elif [ "${REFERENCE_RELEASE_TYPE}" = "1.3" ]; then options=("${build_1_3_options_common[@]}") @@ -303,6 +371,9 @@ build() build_script_flags=("--skip-silabs-apps") thread_version=1.3 build_ot "-DBOARD=brd4166a" "${options[@]}" "$@" ;; + ncs) + thread_version=1.3 build_ncs + ;; esac elif [ "${REFERENCE_RELEASE_TYPE}" = "1.4" ]; then options=("${build_1_4_options_common[@]}") @@ -319,85 +390,15 @@ build() build_script_flags=("--skip-silabs-apps") thread_version=1.4 build_ot "-DBOARD=brd4166a" "${options[@]}" "$@" ;; + ncs) + thread_version=1.4 build_ncs + ;; esac else die "Error: REFERENCE_RELEASE_TYPE = ${REFERENCE_RELEASE_TYPE} is unsupported" fi } -deploy_ncs() -{ - local commit_hash - commit_hash=$(<"${script_dir}"'/../config/ncs/sdk-nrf-commit') - - sudo apt install --no-install-recommends git cmake ninja-build gperf \ - ccache dfu-util device-tree-compiler wget \ - python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ - make gcc gcc-multilib g++-multilib libsdl2-dev - pip3 install --user west - mkdir -p "${script_dir}"/../ncs - cd "${script_dir}"/../ncs - unset ZEPHYR_BASE - west init -m https://github.com/nrfconnect/sdk-nrf --mr main || true - cd nrf - git fetch origin - git reset --hard "$commit_hash" || die "ERROR: unable to checkout the specified sdk-nrf commit." - west update -n -o=--depth=1 - cd .. - pip3 install --user -r zephyr/scripts/requirements.txt - pip3 install --user -r nrf/scripts/requirements.txt - pip3 install --user -r bootloader/mcuboot/scripts/requirements.txt - - # shellcheck disable=SC1091 - source zephyr/zephyr-env.sh - west config manifest.path nrf -} - -package_ncs() -{ - # Get build info - local commit_id - local timestamp - commit_id=$(git rev-parse --short HEAD) - timestamp=$(date +%Y%m%d) - - distribute "/tmp/ncs_cli_1_1/cli/zephyr/zephyr.hex" "ot-cli-ftd" "1.1" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_cli_1_2/cli/zephyr/zephyr.hex" "ot-cli-ftd" "1.2" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_rcp_1_2/coprocessor/zephyr/zephyr.hex" "ot-rcp" "1.2" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_cli_1_3/cli/zephyr/zephyr.hex" "ot-cli-ftd" "1.3" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_rcp_1_3/coprocessor/zephyr/zephyr.hex" "ot-rcp" "1.3" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_cli_1_4/cli/zephyr/zephyr.hex" "ot-cli-ftd" "1.4" "${timestamp}" "${commit_id}" - distribute "/tmp/ncs_rcp_1_4/coprocessor/zephyr/zephyr.hex" "ot-rcp" "1.4" "${timestamp}" "${commit_id}" -} - -build_ncs() -{ - mkdir -p "$OUTPUT_ROOT" - deploy_ncs - - # Build folder | nrf-sdk sample | Sample configuration - local cli_1_1=("/tmp/ncs_cli_1_1" "samples/openthread/cli/" "${script_dir}/../config/ncs/overlay-cli-1_1.conf") - local cli_1_2=("/tmp/ncs_cli_1_2" "samples/openthread/cli/" "${script_dir}/../config/ncs/overlay-cli-1_2.conf") - local rcp_1_2=("/tmp/ncs_rcp_1_2" "samples/openthread/coprocessor/" "${script_dir}/../config/ncs/overlay-rcp-1_2.conf") - local cli_1_3=("/tmp/ncs_cli_1_3" "samples/openthread/cli/" "${script_dir}/../config/ncs/overlay-cli-1_3.conf") - local rcp_1_3=("/tmp/ncs_rcp_1_3" "samples/openthread/coprocessor/" "${script_dir}/../config/ncs/overlay-rcp-1_3.conf") - local cli_1_4=("/tmp/ncs_cli_1_4" "samples/openthread/cli/" "${script_dir}/../config/ncs/overlay-cli-1_4.conf") - local rcp_1_4=("/tmp/ncs_rcp_1_4" "samples/openthread/coprocessor/" "${script_dir}/../config/ncs/overlay-rcp-1_4.conf") - - local variants=(cli_1_1[@] cli_1_2[@] rcp_1_2[@] cli_1_3[@] rcp_1_3[@] cli_1_4[@] rcp_1_4[@]) - - cd nrf - for variant in "${variants[@]}"; do - west build -d "${!variant:0:1}" -b nrf52840dongle/nrf52840 -p always "${!variant:1:1}" --sysbuild -- -DOVERLAY_CONFIG="${!variant:2:1}" - done - - package_ncs "ot-cli-ftd" "1.1" - package_ncs "ot-cli-ftd" "1.2" - package_ncs "ot-rcp" "1.2" - package_ncs "ot-cli-ftd" "1.3" - package_ncs "ot-rcp" "1.3" -} - main() { readonly OT_PLATFORMS=(nrf52840 efr32mg12 ncs) @@ -426,14 +427,8 @@ main() nrfutil_setup ;; esac - case "${platform}" in - ncs*) - build_ncs - ;; - *) - build "$@" - ;; - esac + + build "$@" done }