1、安装Toolchain
使用VSCode Nordic插件安装Toolchain
使用命令行安装Toolchain(需要用到nrfutil,直接在官网下载exe可执行程序)
2、通过批处理脚本设置west及相关编译环境变量
批处理脚本set_env_a.bat
@echo off
start "" "cmd.exe" /k "set_env_b.bat"
批处理脚本set_env_b.bat
@echo off
:: 设置环境变量
SET PATH=C:\ncs\toolchains\ce3b5ff664;C:\ncs\toolchains\ce3b5ff664\mingw64\bin;C:\ncs\toolchains\ce3b5ff664\bin;C:\ncs\toolchains\ce3b5ff664\opt\bin;C:\ncs\toolchains\ce3b5ff664\opt\bin\Scripts;C:\ncs\toolchains\ce3b5ff664\opt\nanopb\generator-bin;C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\aarch64-zephyr-elf\bin;C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\x86_64-zephyr-elf\bin;C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\arm-zephyr-eabi\bin;C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk\riscv64-zephyr-elf\bin;%PATH%
SET PYTHONPATH=C:\ncs\toolchains\ce3b5ff664\opt\bin;C:\ncs\toolchains\ce3b5ff664\opt\bin\Lib;C:\ncs\toolchains\ce3b5ff664\opt\bin\Lib\site-packages
SET ZEPHYR_TOOLCHAIN_VARIANT=zephyr
SET ZEPHYR_SDK_INSTALL_DIR=C:\ncs\toolchains\ce3b5ff664\opt\zephyr-sdk
echo "ENV Set!"
3、下载SDK
# Initialize west with the revision of the nRF Connect SDK
west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.7.0
# Enter the following command to clone the project repositories:
west update
# Export a Zephyr CMake package. This allows CMake to automatically load the boilerplate code required for building nRF Connect SDK applications:
west zephyr-export
4、编译
west build -p always -b nrf5340_audio_dk/nrf5340/cpuapp samples\basic\blinky
5、下载
west flash