# zephyr-build **Repository Path**: openkylin/zephyr-build ## Basic Information - **Project Name**: zephyr-build - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-18 - **Last Updated**: 2026-09-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Zephyr Build(E2000Q) Phytium E2000Q(`e2000q_demo` / `pe2204`)最小 bringup 工作区:提供构建脚本与文档,配合 [openkylin/zephyr](https://gitee.com/openkylin/zephyr) 编译 `hello_world` 与 `shell_module`。 ## 目录结构 工作区根目录 `openkylin_zephyr/`(west workspace): ``` openkylin_zephyr/ ├── .venv/ # Python 3.12 + west(本地创建,不提交) ├── zephyr/ # https://gitee.com/openkylin/zephyr ├── zephyr-sdk-1.0.1/ # Zephyr SDK(本地安装,不提交) └── zephyr-build/ # 本仓库:README.md、build-e2000q.sh ``` ## 前置依赖 | 组件 | 最低版本 / 说明 | |------|-----------------| | 操作系统 | Ubuntu 22.04+ | | CMake | ≥ 3.20.5 | | Python | ≥ 3.12 | | Devicetree 编译器(`dtc`) | ≥ 1.4.6(`device-tree-compiler`) | | Zephyr SDK | **1.0.1**(含 `aarch64-zephyr-elf`),见 §1.4 | ```bash sudo apt update sudo apt install --no-install-recommends git cmake ninja-build gperf \ ccache dfu-util device-tree-compiler wget python3-dev python3-venv python3-tk \ xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 ``` AArch64 主机若无 `gcc-multilib` / `g++-multilib` 可省略。上板走 U-Boot TFTP(§3),不用 `west flash` / QEMU,但建议仍按上表装齐。 ## 1. 环境搭建 ### 1.1 创建工作目录 ```bash mkdir -p ~/openkylin_zephyr && cd ~/openkylin_zephyr ``` ### 1.2 Python 虚拟环境与 west ```bash cd ~/openkylin_zephyr python3 -m venv .venv source .venv/bin/activate pip install west ``` `build-e2000q.sh` 会自动 prepend `.venv/bin`,一般无需每次手动 `activate`。 ### 1.3 拉取 Zephyr 模块 ```bash cd ~/openkylin_zephyr west init -m https://gitee.com/openkylin/zephyr-build.git ~/openkylin_zephyr # 首次执行 west update # 安装zephyr内部依赖模块 west packages pip --install ``` ### 1.4 安装 Zephyr SDK 在工作区根目录安装,与 `zephyr/` 同级: ```bash cd ~/openkylin_zephyr wget https://gitcode.com/openkylin/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-x86_64_gnu.tar.xz wget https://gitcode.com/openkylin/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-x86_64_llvm.tar.xz wget -O - https://gitcode.com/openkylin/sdk-ng/releases/download/v1.0.1/sha256.sum | shasum --check --ignore-missing #校验完整性 tar xvf zephyr-sdk-1.0.1_linux-x86_64_gnu.tar.xz tar xvf zephyr-sdk-1.0.1_linux-x86_64_llvm.tar.xz cd zephyr-sdk-1.0.1 ./setup.sh ``` 如果是aarch架构请下载: ``` wget https://gitcode.com/openkylin/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-arrch64_gnu.tar.xz wget https://gitcode.com/openkylin/sdk-ng/releases/download/v1.0.1/zephyr-sdk-1.0.1_linux-arrch64_llvm.tar.xz ``` 后续步骤一致,`build-e2000q.sh` 默认使用 `<工作区>/zephyr-sdk-1.0.1`。 ## 2. 编译 ### 2.1 e2000q示例程序 在工作区根目录执行 `./zephyr-build/build-e2000q.sh`(封装 `west build`,shell 目标自动叠加 `e2000q_demo_shell.conf`)。 | 目标 | 说明 | |------|------| | `all` | 编译 hello + shell(**默认**) | | `hello` | `zephyr/samples/hello_world` | | `shell` | `zephyr/samples/subsys/shell/shell_module` | | `clean` | 删除 `build-e2000q-hello/`、`build-e2000q-shell/` | | `--help` | 打印用法 | ```bash cd ~/openkylin_zephyr ./zephyr-build/build-e2000q.sh ./zephyr-build/build-e2000q.sh hello ./zephyr-build/build-e2000q.sh shell ./zephyr-build/build-e2000q.sh clean ``` 构建产物(相对工作区根): | 目标 | ELF | |------|-----| | hello | `build-e2000q-hello/zephyr/zephyr.elf` | | shell | `build-e2000q-shell/zephyr/zephyr.elf` | 可选环境变量(均有脚本默认值,通常不必设置): | 变量 | 默认 | |------|------| | `ZEPHYR_SDK_INSTALL_DIR` | `<工作区>/zephyr-sdk-1.0.1` | | `ZEPHYR_BASE` | `<工作区>/zephyr` | | `BOARD` | `e2000q_demo` | 常见报错:`ZEPHYR_SDK_INSTALL_DIR not found` → 检查 §1.4;`ZEPHYR_BASE not found` → 确认 `west update`;`west not found` → 完成 §1.2。 ### 2.2 QEMU示例程序 如需为其他板卡构建固件,请将上述配置中的 qemu_cortex_m3 替换为目标板卡名称。 ```bash cd ~/openkylin_zephyr/zephyr west build -b qemu_cortex_m3 samples/hello_world -d build-qemu-hello #编译 west build -d build-qemu-hello -t run #运行 ``` 输出`Hello World! qemu_cortex_m3/ti_lm3s6965` ## 3. 上板(U-Boot) ```text E2000# tftpboot 0x90100000 zephyr.elf E2000# bootelf -p 0x90100000 ``` - hello:`Hello World! e2000q_demo/pe2204` - shell:出现 `uart:~$`,可执行 `help`