Windows下使用命令行编译NCS

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值