Skip to content

Instantly share code, notes, and snippets.

@cfriedt
Last active March 7, 2025 21:26
Show Gist options
  • Save cfriedt/aa769407395c731920b3c73ae5081d73 to your computer and use it in GitHub Desktop.
Save cfriedt/aa769407395c731920b3c73ae5081d73 to your computer and use it in GitHub Desktop.
My Zephyr RC file
# Helper dotfile for managing Zephyr SDK and Python Virtual Environment
# See https://docs.zephyrproject.org/latest/develop/getting_started/index.html
# Also available at https://bit.ly/3Xxehrw
# Variables (adjust as needed)
# curl -L 'https://bit.ly/3Xxehrw' \
# | sed \
# -e "s|^PREFIX=@PREFIX@|PREFIX=$PREFIX|" \
# -e "s|^ZEPHYR_VENV_VERSION=@ZEPHYR_VENV_VERSION@|ZEPHYR_VENV_VERSION=$ZEPHYR_VENV_VERSION|" \
# -e "s|^ZEPHYR_SDK_VERSION=@ZEPHYR_SDK_VERSION@|ZEPHYR_SDK_VERSION=$ZEPHYR_SDK_VERSION|" \
# > ~/.zephyrrc
PREFIX=@PREFIX@
ZEPHYR_SDK_VERSION=@ZEPHYR_SDK_VERSION@
ZEPHYR_VENV_VERSION=@ZEPHYR_VENV_VERSION@
ZEPHYR_VENV="$PREFIX/venv/$ZEPHYR_VENV_VERSION"
## comment this line if using the Zephyr SDK
#export ZEPHYR_TOOLCHAIN_VARIANT=llvm
## comment these lines if using llvm
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR="$PREFIX/zephyr-sdk-$ZEPHYR_SDK_VERSION"
# return arch in the format used by zephyr sdk archives
filter_arch() {
local a="`uname -m`"
case "$a" in
arm64)
echo "aarch64"
;;
*)
echo "$a"
;;
esac
}
# return os in the format used by zephyr sdk archives
filter_os() {
local os="`uname -s`"
case "$os" in
Darwin)
echo "macos"
;;
Linux)
echo "linux"
;;
*)
echo "$os"
;;
esac
}
ARCH="`filter_arch`"
OS="`filter_os`"
if [ "$ZEPHYR_TOOLCHAIN_VARIANT" = "zephyr" ]; then
if [ "$OS" = "linux" ]; then
if [ "$ARCH" = "x86_64" -o "$ARCH" = "aarch64" ]; then
# path for dtc, qemu-system*, openocd, net-tools, etc
PATH="$ZEPHYR_SDK_INSTALL_DIR/sysroots/$ARCH-pokysdk-$OS/usr/bin:$PATH"
fi
fi
# path for all supported Zephyr toolchains
toolchains=(
"aarch64-zephyr-elf"
"arc64-zephyr-elf"
"arc-zephyr-elf"
"arm-zephyr-eabi"
"mips-zephyr-elf"
"nios2-zephyr-elf"
"riscv64-zephyr-elf"
"sparc-zephyr-elf"
"x86_64-zephyr-elf"
"xtensa-espressif_esp32_zephyr-elf"
"xtensa-espressif_esp32s2_zephyr-elf"
"xtensa-intel_apl_adsp_zephyr-elf"
"xtensa-intel_bdw_adsp_zephyr-elf"
"xtensa-intel_byt_adsp_zephyr-elf"
"xtensa-intel_s1000_zephyr-elf"
"xtensa-nxp_imx_adsp_zephyr-elf"
"xtensa-nxp_imx8m_adsp_zephyr-elf"
"xtensa-sample_controller_zephyr-elf"
)
for i in ${toolchains[@]}; do
PATH="$ZEPHYR_SDK_INSTALL_DIR/$i/bin:$PATH"
done
export PATH
fi
# activate python virtual environment installed in the GSG
#
. "$ZEPHYR_VENV/bin/activate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment