Set up the development environment
This page prepares everything needed on a Linux host to build YuzukiNeko Zephyr programs: system dependencies, a Python virtual environment, west, the XuanTie toolchain, and xfel for downloading. Once it is done, the next page, Get the Zephyr source, has somewhere to put the code.
Workspace directory
Section titled “Workspace directory”Everything that follows goes into the same directory, ~/f101-zephyr, referred to as the “workspace”. In the end it looks like this:
~/f101-zephyr/├── .venv/ Python virtual environment (created on this page)├── toolchains/ XuanTie toolchain (created on this page)├── env.sh environment script to source in every new terminal (created on this page)├── .west/ west workspace marker (created on the next page)├── zephyr/ F101 Zephyr kernel (created on the next page)└── modules/ third-party modules Zephyr depends on (created on the next page)mkdir -p ~/f101-zephyr/toolchains && cd ~/f101-zephyrSystem dependencies
Section titled “System dependencies”sudo apt updatesudo 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 libmagic1Zephyr 4.2 has the following minimum version requirements for the main tools; check them after installing:
| Tool | Minimum version | Check command |
|---|---|---|
| CMake | 3.20.5 | cmake --version |
| Python | 3.10 | python3 --version |
| Devicetree compiler (dtc) | 1.4.6 | dtc --version |
Python virtual environment and west
Section titled “Python virtual environment and west”Use a virtual environment to install west and Zephyr’s Python dependencies without polluting the system Python:
python3 -m venv ~/f101-zephyr/.venv. ~/f101-zephyr/.venv/bin/activatepip install --upgrade pippip install westwest --versionZephyr’s own Python dependencies (pyelftools, PyYAML, etc.) can only be installed once the source has been fetched; that is the last step of the next page.
XuanTie toolchain
Section titled “XuanTie toolchain”The F101 CPU is the XuanTie C907 (rv32imafdcv). Zephyr here uses the XuanTie 900 elf-newlib toolchain, integrated through the cross-compile variant, without the Zephyr SDK.
| Item | Value |
|---|---|
| Package name | Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gz |
| Compiler prefix | riscv64-unknown-elf- |
| Source | T-Head OCC |
cd ~/f101-zephyr/toolchainswget -c https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1751370399722/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gztar -xzf Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gzlsAfter extraction, toolchains/ should contain Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/. Verify:
~/f101-zephyr/toolchains/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin/riscv64-unknown-elf-gcc --versionenv.sh
Section titled “env.sh”Collect the environment variables in a single script, so that afterwards you only need to source it once per terminal:
cat > ~/f101-zephyr/env.sh <<'EOF'# Usage: . ./env.sh (from the workspace root, or source it by absolute path)_F101_WS="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
. "$_F101_WS/.venv/bin/activate"
export ZEPHYR_TOOLCHAIN_VARIANT=cross-compileexport CROSS_COMPILE="$_F101_WS/toolchains/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin/riscv64-unknown-elf-"export PATH="$(dirname "$CROSS_COMPILE"):$PATH"
# zephyr/ does not exist until the source has been fetched; do not set it yet[ -d "$_F101_WS/zephyr" ] && export ZEPHYR_BASE="$_F101_WS/zephyr"
unset _F101_WSEOFWhat each variable does:
| Variable | Purpose |
|---|---|
ZEPHYR_TOOLCHAIN_VARIANT=cross-compile | Makes Zephyr use the external toolchain given by CROSS_COMPILE |
CROSS_COMPILE | Toolchain path plus prefix; note the trailing - |
PATH | Lets riscv64-unknown-elf-gcc and the others be called directly |
ZEPHYR_BASE | Zephyr kernel directory; it only exists after the source is fetched on the next page |
Load and check:
. ~/f101-zephyr/env.shwhich west riscv64-unknown-elf-gccBoth commands should point into the workspace.
Install xfel
Section titled “Install xfel”Loading a program onto the board over USB uses xfel; without it you can still build, but not download and run. The installation steps (including the Linux udev rules) are in FEL download mode and tools, and require v1.4.0 or newer. After installing, verify with xfel version (the board must be in FEL first).
Checklist
Section titled “Checklist”Open a new terminal and confirm every item below holds before moving on to the next page:
. ~/f101-zephyr/env.shwest --versioncmake --versiondtc --versionriscv64-unknown-elf-gcc --versionNext: Get the Zephyr source.