跳转至

搭建开发环境

NextPilot 基于 RT-Thread 实时操作系统而打造的,为了便于高效的进行 NextPilot 项目开发,技术团队在 RT-Thread ENV-Windows 基础上重新制作了 nextpilot-windows-toolchain(github | gitee) 和 nextpilot-ubuntu-toolchain(github | gitee),他们相当于 RT-Thread ENV-Windows 的定制升级版。

nextpilot-xxxx-toolchain 集成或自动安装了以下工具:

  • python, pip, scons, kconfiglib, mkdocs等
  • gcc-arm-none-eabi
  • qemu-system-arm
  • git
  • vscode

Windows

1、下载/克隆nextpilot-windows-toolchain(github | gitee)到C:\nextpilot-windows-toolchain文件夹。

注意:暂时工具链只能保存到C:\nextpilot-windows-toolchain文件夹,否则会提示找不到python.exe。

git clone --depth=1 https://github.com/nextpilot/nextpilot-windows-toolchain.git

2、双击Nextpilot-windows-toolchain/start.bat脚本启动CMD终端,并已经配置好了nextpilot开发环境。

3、在CMD终端里,切换到nextpilot-flight-control/bsps目录,然后运行命令进行配置/编译/仿真:

# 克隆nextpilot飞控项目
git clone https://github.com/nextpilot/nextpilot-flight-control.git

# 切换到bsps目录,比如bsps/sitl/qemu,使用qmeu跑软件在环
cd nextpilot-flight-control/bsps/sitl/qemu

# 配置nextpilot项目,仅限开发者
scons --menuconfig

# 雇佣10个线程编译default目标,更多目标参见config/xxxx.config文件
scons default -j10

# 启用qemu进行虚拟飞行仿真
qemu.bat

Tips

由于qemu模式是使用UDP方式和地面站通信,在调试网络驱动的时候,建议准备好 tap-windows-9.21.2.exe华为IP调试工具IPOP V4.1

由于打开Windows命令终端默认是C盘用户目录,如果代码需要存放在其他盘如E盘,则需要先切换E盘,命令为盘符+冒号,如下:

C:\Users\yourname>e:
E:\>

Ubuntu

1、请下载/克隆nextpilot-ubuntu-toolchain(github | gitee)到任意 不包含中文 的目录。

git clone --depth=1 https://github.com/nextpilot/nextpilot-ubunut-toolchain.git ~/.ndt

2、激活nextpilot工具链,首次运行会创建python venv环境并安装必要的工具。

source ~/.ndt/init.sh

3、进行nextpilot项目编译、仿真和配置等。

# 克隆nextpilot飞控项目
git clone https://github.com/nextpilot/nextpilot-flight-control.git ~/nextpilot-flight-control

# 切换到bsps目录,比如bsps/sitl/qemu,使用qmeu跑软件在环
cd ~/nextpilot-flight-control/bsps/sitl/qemu

# 配置nextpilot项目,仅限开发者
scons --menuconfig

# 雇佣10个线程编译default目标,更多目标参见config/xxxx.config文件
scons default -j10

# 启用qemu进行虚拟飞行仿真
./qemu.sh

扩展阅读

RT-Thread 官方提供了完整的一套 RT-Thread 项目开发的工具链,nextpilot-xxxx-toolchain的制作参考或引用其中部分功能。

辅助工具 代码仓库 下载地址 帮助文档 说明
RT-Thread Packages 仓库 官网 帮助 扩展软件包
RT-Thread ENV 仓库 / / 项目开发脚本
RT-Thread ENV-Windows 仓库 下载 帮助 Windows命令行工具链
RT-Thread Studio / 下载 帮助 基于Eclipse的IDE
RT-Thread Studio For VScode / 下载 帮助 VScode插件

RT-Thread ENV脚本 ,为RT-Thread提供编译构建环境、图形化系统配置(menuconfig/Kconfig)及软件包管理(rt-thread packages)功能。其实是一组python脚本,用于搭建Ubuntu和windows下的开发环境,并提供了menuconfig(用于Kconfig系统配置RT-Thread项目)和pkgs(用于管理RT-Thread Packages)两套指令,用于辅助RT-Thread项目开发。

RT-Thread ENV-Windows ,Windows环境下的加强版RT-Thread ENV脚本,不仅包含RT-Thread ENV,还增加了RT-Thread Packages索引库、python、 arm-gcc、qemu(仿真模拟器)、 ConEmu(类似CMD的命令行终端),以及其它一些工具集合。

RT-Thread Studio 集成开发环境(基于eclipse), 主要包括工程创建和管理,代码编辑,SDK管理,RT-Thread配置,构建配置,调试配置,程序下载和调试等功能,结合图形化配置系统以及软件包和组件资源,减少重复工作,提高开发效率。RT-Thread Studio集成了eclipse(IDE开发界面)+ RT-Thread ENV-Windows + ToolChain_Support_Packages(各种编译工具链) + Debugger_Support_Packages(stlink、jlink调试器和qemu模拟器) + Board_Support_Packages(bsp) + Chip_Support_Packages(csp) + RT-Thread_Source_Code(rt-thread代码仓库) + ...

RT-Thread Studio For Vscode插件,支持在 Vscode 编译和调是RT-Thread项目。NextPilot的虚拟飞行仿真使用到了该插件。