window 编译zephyr
1、stm32f103_mini编译
cd zephyrproject\zephyr
west build -b stm32f103_mini samples/hello_world
2、qemu_cortex_m3编译
cd mysource\zephyrproject\zephyr
west build -b qemu_cortex_m3 samples/hello_world
west build -t run
3、调试
set PATH=F:\software_install\SEGGER\JLink;%PATH%
west flash --runner jlink
west debug --runner jlink
west debug --runner jlink -f build_stm32f103_0704\zephyr\zephyr.elf
west flash --runner jlink -f build_stm32f103_0704\zephyr\zephyr.bin --reset-after-load
4、vscode搭建调试zephyr
5、0704调试
6、gpio函数使用
https://blog.csdn.net/bjbz_cxy/article/details/119575487
添加新board及文件说明:
https://docs.panchip.com/pan1080dk-doc/0.8.0/04_dev_guides/zephyr_board_guidance.html
west build -b stm32f103_0704 samples/hello_world -d build_stm32f103_0704
menuconfig:
west build -b stm32f103_0704 samples/test -d build_stm32f103_0704
west build -t menuconfig -d build_stm32f103_0704
7、gcc 和 armgcc的设备树引用编译
cd /D F:\stm32\zephyrproject\mytest && F:\stm32\zephyrproject\zephyr-sdk-0.16.8\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe main.c -o main -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -IF:\stm32\zephyrproject\mytest
cd /D F:\stm32\zephyrproject\mytest && F:\stm32\zephyrproject\zephyr-sdk-0.16.8\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe main.c -o main -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -DCONFIG_ARM -lm -lc --specs=nosys.specs
1、生成预处理文件
cd /D F:\stm32\zephyrproject\mytest && F:\stm32\zephyrproject\zephyr-sdk-0.16.8\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -E main.c -o main.i -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -DCONFIG_ARM -lm -lc --specs=nosys.specs
F:\software_install\Keil_v5\ARM\ARMCC\bin
2、汇编代码
cd /D F:\stm32\zephyrproject\mytest && F:\stm32\zephyrproject\zephyr-sdk-0.16.8\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -S main.c -o main.s -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -DCONFIG_ARM -lm -lc --specs=nosys.specs
3、目标文件
cd /D F:\stm32\zephyrproject\mytest && F:\stm32\zephyrproject\zephyr-sdk-0.16.8\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -c main.c -o main.o -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -DCONFIG_ARM -lm -lc --specs=nosys.specs
使用keil自身的编译器编译
cd /D F:\stm32\zephyrproject\mytest && F:\software_install\Keil_v5\ARM\ARMCC\bin\armcc.exe -E main.c -o main.i -IF:\stm32\zephyrproject\zephyr-3.7.0\include\ -IF:/stm32/zephyrproject/zephyr-3.7.0/build_stm32f103_0704/zephyr/include/generated/ -DCONFIG_ARM -D__ARMCOMPILER_VERSION -D__LITTLE_ENDIAN__ -D__CHAR_BIT__=8 -D__SIZEOF_LONG__=4 -D__SIZEOF_LONG_LONG__=8
#include <stdio.h> // #include <device.h> #include <zephyr/device.h> // #include <zephyr/init.h> // #include <zephyr/linker/sections.h> // #include <zephyr/pm/state.h> // #include <zephyr/sys/device_mmio.h> // #include <zephyr/sys/iterable_sections.h> // #include <zephyr/sys/util.h> // #include <zephyr/toolchain.h> #define APPRUNLED DT_ALIAS(runled) #define RUNLEDPIN DT_PHA_BY_IDX(APPRUNLED, gpios, 0, pin) #define RUNLEDFLAG DT_PHA_BY_IDX(APPRUNLED, gpios, 0, flags) int main(void) { printf("pin:%d\n", RUNLEDPIN); printf("regaddr:%08x\n",DT_REG_ADDR(DT_NODELABEL(gpiof))); return 0; }
参考链接:
zephry 环境搭建: https://blog.csdn.net/weixin_42443946/article/details/124398691