目标平台:FPB RA6E2开发板
Zephyr 版本:v4.3.99 (main 分支)
【工程创建】
1、创建一个文件夹,命令为ra6e2_hello。
2、在该文夹内加入src文件夹,文件夹下创建main.c
3、文件夹内添加CMakeLists.txt与prj.conf
添加好后结构如下:
├── CMakeLists.txt ├── README.rst ├── prj.conf └── src └── main.c 1 directory, 4 files
4、查看Zephyr 是否已支持RA6E2:
lugl@lugl:~/zephyrproject/app/ra6e2_hello$ west boards | grep -i ra6e2 fpb_ra6e2 ek_ra6e2
从结果看支持fpb_ra6e2,咱们就可以愉快的开始zephyr之旅了。
5、编写prj.conf
#什么也不用写
6、编写CMakeLists.txt
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)
target_sources(app PRIVATE src/main.c)6、编写应用代码(main.c)
#include <stdio.h>
int main(void)
{
printf("Hello World! %s\n", CONFIG_BOARD_TARGET);
return 0;
}7、构建
west build -b fpb_ra6e2 [145/145] Linking C executable zephyr/zephyr.elf Memory region Used Size Region Size %age Used FLASH: 21956 B 256 KB 8.38% RAM: 4832 B 40 KB 11.80% OFS_OFS0_MEMORY: 4 B 4 B 100.00% OFS_OSIS_MEMORY: 16 B 16 B 100.00% OFS_OFS1_SEC_MEMORY: 4 B 4 B 100.00% OFS_BPS_SEC_MEMORY: 4 B 4 B 100.00% OFS_PBPS_SEC_MEMORY: 4 B 4 B 100.00% IDT_LIST: 0 GB 32 KB 0.00% Generating files from /home/lugl/zephyrproject/app/ra6e2_hello/build/zephyr/zephyr.elf for board: fpb_ra6e2
8、烧录
开发板上板载了Jlink-ob因此可以方便的使用jlink来下载。
lugl@lugl:~/zephyrproject/app/ra6e2_hello$ west flash --runner jlink -- west flash: rebuilding ninja: no work to do. -- west flash: using runner jlink -- runners.jlink: reset after flashing requested -- runners.jlink: JLink version: 8.76 -- runners.jlink: Flashing file: /home/lugl/zephyrproject/app/ra6e2_hello/build/zephyr/zephyr.hex
【验证】
打开串口终端就可以看到输出如下:

【总结】
zephyr生态完美支持RA6E2,可以轻松的上手RA6E2。
优点,不需要下载复杂的fsp,不用安装IDE等等
我要赚赏金
