Fixes for zephyr install scripts and place apt keys for conda in the standard place.
This commit is contained in:
parent
e15aaf3b04
commit
04166a1664
24
020_conda.sh
24
020_conda.sh
|
|
@ -1,28 +1,31 @@
|
||||||
DEST=${1:-/etc/skel}
|
DEST=${1:-/etc/skel}
|
||||||
|
|
||||||
# Install our public GPG key to trusted store
|
# Install our public GPG key to trusted store
|
||||||
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg
|
# KEY_DIR=/usr/share/keyrings
|
||||||
install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg
|
KEY_DIR=/etc/apt/trusted.gpg.d
|
||||||
|
|
||||||
|
sudo curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor >conda.gpg
|
||||||
|
sudo install -o root -g root -m 644 conda.gpg ${KEY_DIR}/conda-archive-keyring.gpg
|
||||||
|
|
||||||
# Check whether fingerprint is correct (will output an error message otherwise)
|
# Check whether fingerprint is correct (will output an error message otherwise)
|
||||||
gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806
|
sudo gpg --keyring ${KEY_DIR}/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806
|
||||||
|
|
||||||
# Add our Debian repo
|
# Add our Debian repo
|
||||||
|
sudo echo "deb [arch=amd64 signed-by=${KEY_DIR}/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | sudo tee /etc/apt/sources.list-available/conda.list
|
||||||
|
|
||||||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" | sudo tee /etc/apt/sources.list-available/conda.list
|
sudo ln -sf /etc/apt/sources.list-available/conda.list /etc/apt/sources.list.d/conda.list
|
||||||
|
|
||||||
ln -s /etc/apt/sources.list-available/conda.list /etc/apt/sources.list.d/conda.list
|
|
||||||
|
|
||||||
|
|
||||||
# Install it!
|
# Install it!
|
||||||
apt update
|
sudo apt update
|
||||||
apt install -y conda
|
sudo apt install -y conda
|
||||||
|
|
||||||
|
mkdir -p "${DEST}"/.zshrc.pre-plugins.d/
|
||||||
|
|
||||||
cat <<-EOF | sudo tee "${DEST}"/.zshrc.pre-plugins.d/008_conda.zsh >/dev/null
|
cat <<-EOF | sudo tee "${DEST}"/.zshrc.pre-plugins.d/008_conda.zsh >/dev/null
|
||||||
# when using conda from the vim plugin it expects to be called from base conda environment.
|
# when using conda from the vim plugin it expects to be called from base conda environment.
|
||||||
## >>> conda initialize >>>
|
## >>> conda initialize >>>
|
||||||
## !! Contents within this block are managed by 'conda init' !!
|
## !! Contents within this block are managed by 'conda init' !!
|
||||||
__conda_setup="$('/opt/conda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
|
__conda_setup="$('/opt/conda/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
eval "$__conda_setup"
|
eval "$__conda_setup"
|
||||||
else
|
else
|
||||||
|
|
@ -46,7 +49,6 @@ EOF
|
||||||
|
|
||||||
# see: https://github.com/ubaldot/vim-conda-activate for vim support
|
# see: https://github.com/ubaldot/vim-conda-activate for vim support
|
||||||
|
|
||||||
|
|
||||||
# Check to see if the installation is successful:
|
# Check to see if the installation is successful:
|
||||||
. /opt/conda/etc/profile.d/conda.sh
|
. /opt/conda/etc/profile.d/conda.sh
|
||||||
conda -V
|
conda -V
|
||||||
|
|
|
||||||
126
020_zephyr.sh
126
020_zephyr.sh
|
|
@ -3,6 +3,10 @@
|
||||||
# https://www.zephyrproject.org/zephyr-rtos-on-esp32/
|
# https://www.zephyrproject.org/zephyr-rtos-on-esp32/
|
||||||
# https://zmk.dev/docs/development/setup/
|
# https://zmk.dev/docs/development/setup/
|
||||||
|
|
||||||
|
## build basic blinky
|
||||||
|
# BOARD_NAME=esp32s3_devkitm
|
||||||
|
# cd ~/zephyrproject/zephyr
|
||||||
|
# west build -p always -b ${BOARD_NAME} samples/basic/blinky
|
||||||
|
|
||||||
# Manual flash instructions https://github.com/seemoo-lab/openhaystack/wiki/Flashing-nRF-with-OpenOCD---ST-Link
|
# Manual flash instructions https://github.com/seemoo-lab/openhaystack/wiki/Flashing-nRF-with-OpenOCD---ST-Link
|
||||||
# $ openocd \
|
# $ openocd \
|
||||||
|
|
@ -42,23 +46,33 @@ DEST=${1:-${HOME}}
|
||||||
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
ARCH=$(dpkg --print-architecture)
|
||||||
MACHINE=$(uname -m)
|
MACHINE=$(uname -m)
|
||||||
|
PYTHON_VERSION='3.12.4'
|
||||||
|
|
||||||
|
# zephyr version
|
||||||
|
# ZEPHYR_VERSION=$(lastversion --format tag zephyr) # 3.7.0
|
||||||
|
ZEPHYR_VERSION='v3.5.0' # zmk lags https://zmk.dev/blog
|
||||||
|
|
||||||
|
# sdk version
|
||||||
USER=zephyrproject-rtos
|
USER=zephyrproject-rtos
|
||||||
PROJECT=sdk-ng
|
PROJECT=sdk-ng
|
||||||
API_URL=https://api.github.com/repos/${USER}/${PROJECT}/releases/latest
|
API_URL=https://api.github.com/repos/${USER}/${PROJECT}/releases/latest
|
||||||
RELEASE=$(curl -s ${API_URL} | grep tarball_url | cut -d '"' -f 4 | awk -F "/" {'print $8'})
|
RELEASE=$(curl -s ${API_URL} | grep tarball_url | cut -d '"' -f 4 | awk -F "/" {'print $8'})
|
||||||
SDK_FILENAME=zephyr-sdk-${RELEASE#v}_linux-${MACHINE}_minimal.tar.xz # 41.8 MB
|
SDK_FILENAME=zephyr-sdk-${RELEASE#v}_linux-${MACHINE}_minimal.tar.xz # 41.8 MB
|
||||||
# SDK_FILENAME=zephyr-sdk-${RELEASE#v}_linux-${MACHINE}.tar.xz # 1.35 GB
|
# SDK_FILENAME=zephyr-sdk-${RELEASE#v}_linux-${MACHINE}.tar.xz # 1.35 GB
|
||||||
SDK_URL=https://github.com/${USER}/${PROJECT}/releases/download/${RELEASE}/
|
SDK_URL=https://github.com/${USER}/${PROJECT}/releases/download/${RELEASE}
|
||||||
|
|
||||||
# fetch the sdk
|
# fetch the sdk
|
||||||
# wget ${SDK_URL}/${SDK_FILENAME}
|
wget -c ${SDK_URL}/${SDK_FILENAME}
|
||||||
# wget -O - ${SDK_URL}/sha256.sum | shasum --check --ignore-missing
|
wget -c -O - ${SDK_URL}/sha256.sum | shasum --check --ignore-missing
|
||||||
|
|
||||||
|
|
||||||
SDK_DEST=${DEST}/zephyr-sdk-${RELEASE#v}
|
SDK_DEST=${DEST}/zephyr-sdk-${RELEASE#v}
|
||||||
PROJECT_DEST=${DEST}/zephyrproject
|
PROJECT_DEST=${DEST}/zephyrproject
|
||||||
|
|
||||||
|
mkdir -p ${SDK_DEST}
|
||||||
|
mkdir -p ${PROJECT_DEST}
|
||||||
|
|
||||||
|
# unpack the sdk
|
||||||
|
tar xvf ${SDK_FILENAME}
|
||||||
|
|
||||||
# https://docs.zephyrproject.org/latest/develop/env_vars.html#env-vars-important
|
# https://docs.zephyrproject.org/latest/develop/env_vars.html#env-vars-important
|
||||||
ZEPHYR_ENV_FILE="${HOME}/.zshrc.d/001_zephyr.zsh"
|
ZEPHYR_ENV_FILE="${HOME}/.zshrc.d/001_zephyr.zsh"
|
||||||
|
|
@ -69,24 +83,9 @@ export ZEPHYR_SDK_INSTALL_DIR="${SDK_DEST}"
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
# use the sdk setup script to add the target toolchains and the host tools.
|
|
||||||
pushd ${ZEPHYR_SDK_INSTALL_DIR}
|
|
||||||
west update
|
|
||||||
# bash ./setup.sh -t x86_64-zephyr-elf
|
|
||||||
bash ./setup.sh -t arm-zephyr-eabi
|
|
||||||
bash ./setup.sh -t xtensa-espressif_esp32_zephyr-elf
|
|
||||||
bash ./setup.sh -t xtensa-espressif_esp32s3_zephyr-elf
|
|
||||||
bash ./setup.sh -h
|
|
||||||
popd
|
|
||||||
|
|
||||||
# install udev rules
|
|
||||||
sudo cp ~/zephyr-sdk-${RELEASE#v}/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
|
|
||||||
sudo udevadm control --reload
|
|
||||||
|
|
||||||
RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
|
RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
|
||||||
# xdg-open ${RSS_FEED}
|
# xdg-open ${RSS_FEED}
|
||||||
cat ${RSS_FEED}
|
echo ${RSS_FEED}
|
||||||
|
|
||||||
echo "*** Installing dependencies. ***"
|
echo "*** Installing dependencies. ***"
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
@ -100,7 +99,7 @@ sudo apt install --no-install-recommends -y autoconf automake \
|
||||||
echo "*** Getting Zephyr and installing Python dependencies. ***"
|
echo "*** Getting Zephyr and installing Python dependencies. ***"
|
||||||
# Install west and ensure that ${HOME}/.local/bin is part of your PATH environment variable:
|
# Install west and ensure that ${HOME}/.local/bin is part of your PATH environment variable:
|
||||||
|
|
||||||
echo "*** Installing west with pip3 ***"
|
# echo "*** Installing west with pip3 ***"
|
||||||
# pip3 install -U --user west
|
# pip3 install -U --user west
|
||||||
# echo 'export PATH=${HOME}/.local/bin:”$PATH”' >>${HOME}/.bashrc
|
# echo 'export PATH=${HOME}/.local/bin:”$PATH”' >>${HOME}/.bashrc
|
||||||
|
|
||||||
|
|
@ -109,20 +108,29 @@ echo "*** Installing west with pip3 ***"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
# ensure a conda env exists for zephyr python requirements
|
# ensure a conda env exists for zephyr python requirements
|
||||||
|
if which conda >/dev/null 2>&1; then
|
||||||
|
echo "Conda is already installed."
|
||||||
|
else
|
||||||
|
echo "Conda is not installed. Installing..."
|
||||||
|
bash /var/tmp/automate/020_conda.sh ${HOME}
|
||||||
|
fi
|
||||||
|
|
||||||
|
. /opt/conda/etc/profile.d/conda.sh
|
||||||
|
|
||||||
# https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools/Download?lang=en#infotabs
|
# https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools/Download?lang=en#infotabs
|
||||||
# https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-24-2/nrf-command-line-tools_10.24.2_amd64.deb
|
# https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-24-2/nrf-command-line-tools_10.24.2_amd64.deb
|
||||||
# py -3 -m pip install --pre -U git+https://github.com/makerdiary/uf2utils.git@main
|
# py -3 -m pip install --pre -U git+https://github.com/makerdiary/uf2utils.git@main
|
||||||
if [[ ! -d ${HOME}/.conda/envs/zephyr ]];
|
|
||||||
conda init -n zephyr python west pynrfjprog dtsh # pyocd pylink
|
if [[ ! -d "${HOME}/.conda/envs/zephyr" ]]; then
|
||||||
|
echo "Creating the zephyr environment with conda."
|
||||||
|
conda create -n zephyr python=${PYTHON_VERSION}
|
||||||
|
conda activate zephyr
|
||||||
|
pip install --no-input west pynrfjprog dtsh
|
||||||
|
echo "Zephyr environment created successfully."
|
||||||
|
else
|
||||||
|
echo "Zephyr environment already exists."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
conda activate zephyr
|
|
||||||
|
|
||||||
# add 'west' completion to zsh - use /usr/share/when packaging for debian
|
|
||||||
COMPLETION_FILE="/usr/share/zsh/site-functions/_west"
|
|
||||||
COMPLETION_FILE="${HOME}/.zshrc.d/001_west-completion.zsh"
|
|
||||||
west completion zsh > ${COMPLETION_FILE}
|
|
||||||
|
|
||||||
# Create west configuation file.
|
# Create west configuation file.
|
||||||
cat <<EOF | tee ${HOME}/.westconfig
|
cat <<EOF | tee ${HOME}/.westconfig
|
||||||
[zephyr]
|
[zephyr]
|
||||||
|
|
@ -131,19 +139,57 @@ cat <<EOF | tee ${HOME}/.westconfig
|
||||||
[build]
|
[build]
|
||||||
# pristine = auto
|
# pristine = auto
|
||||||
#board = nrf52840dk/nrf52840
|
#board = nrf52840dk/nrf52840
|
||||||
#dir-fmt = build/{board}
|
#dir-fmt = build/\${board}
|
||||||
#guess-dir = runners
|
#guess-dir = runners
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
echo "Installing Zephyr's toolchain."
|
||||||
|
#Zephyr's SDK adds several additional tools for the host. Download the SDK installer:
|
||||||
|
# use the sdk setup script to add the target toolchains and the host tools.
|
||||||
|
|
||||||
# 'west' is the tool that manages the entire life-cycle of a Zephyr-based project.
|
# 'west' is the tool that manages the entire life-cycle of a Zephyr-based project.
|
||||||
|
# west init -m https://github.com/zephyrproject-rtos/zephyr --mr v2.5.0 zephyrproject
|
||||||
|
|
||||||
echo "*** Getting zephyr source code ***"
|
echo "*** Getting zephyr source code ***"
|
||||||
git clone https://github.com/${USER}/zephyr
|
|
||||||
mkdir -p ${DEST}/zephyr
|
# Move into the conda venv
|
||||||
cd ${DEST}/zephyr
|
conda activate zephyr
|
||||||
git show -s --pretty=format:%cd
|
west init -m https://github.com/${USER}/zephyr --mr ${ZEPHYR_VERSION} ${PROJECT_DEST}
|
||||||
|
|
||||||
|
pushd ${PROJECT_DEST}/zephyr
|
||||||
|
# enable autoswitching with zsh-autoswitch-conda (use echo not mkcenv)
|
||||||
|
echo zephyr >.cenv
|
||||||
|
# sed -i '|\.venv|a|\.cenv' .gitignore
|
||||||
|
sed -i '/\.venv/a\.cenv' .gitignore
|
||||||
|
|
||||||
west update
|
west update
|
||||||
|
conda deactivate
|
||||||
|
popd
|
||||||
|
|
||||||
|
pushd ${ZEPHYR_SDK_INSTALL_DIR}
|
||||||
|
|
||||||
|
# enable autoswitching with zsh-autoswitch-conda (use echo not mkcenv)
|
||||||
|
echo zephyr >.cenv
|
||||||
|
# sed -i '|\.venv|a|\.cenv' .gitignore
|
||||||
|
sed -i '/\.venv/a\.cenv' .gitignore
|
||||||
|
|
||||||
conda activate zephyr
|
conda activate zephyr
|
||||||
|
bash ./setup.sh
|
||||||
|
# bash ./setup.sh -t x86_64-zephyr-elf
|
||||||
|
bash ./setup.sh -t arm-zephyr-eabi
|
||||||
|
bash ./setup.sh -t xtensa-espressif_esp32_zephyr-elf
|
||||||
|
bash ./setup.sh -t xtensa-espressif_esp32s3_zephyr-elf
|
||||||
|
bash ./setup.sh -h
|
||||||
|
popd
|
||||||
|
|
||||||
|
# install udev rules
|
||||||
|
sudo cp ~/zephyr-sdk-${RELEASE#v}/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
|
||||||
|
sudo udevadm control --reload
|
||||||
|
|
||||||
|
# add 'west' completion to zsh - use /usr/share/when packaging for debian
|
||||||
|
COMPLETION_FILE="/usr/share/zsh/site-functions/_west"
|
||||||
|
COMPLETION_FILE="${HOME}/.zshrc.d/001_west-completion.zsh"
|
||||||
|
west completion zsh >${COMPLETION_FILE}
|
||||||
|
|
||||||
echo "Exporting a Zephyr CMake package."
|
echo "Exporting a Zephyr CMake package."
|
||||||
west zephyr-export
|
west zephyr-export
|
||||||
|
|
@ -152,12 +198,4 @@ echo "Installing additional python dependencies via pip3."
|
||||||
pip install -r \
|
pip install -r \
|
||||||
${HOME}/zephyrproject/zephyr/scripts/requirements.txt
|
${HOME}/zephyrproject/zephyr/scripts/requirements.txt
|
||||||
|
|
||||||
echo "Installing Zephyr's toolchain."
|
conda deactivate
|
||||||
#Zephyr's SDK adds several additional tools for the host. Download the SDK installer:
|
|
||||||
|
|
||||||
cd ${HOME}
|
|
||||||
wget -O /var/tmp/${SDK_FILENAME} ${SDK_URL}/{SDK_FILENAME}
|
|
||||||
|
|
||||||
echo "Running the installer, this will install the SDK under the ${DEST}-${RELEASE:1} folder."
|
|
||||||
chmod +x /var/tmp/${SDK_FILENAME}
|
|
||||||
/var/tmp/${SDK_FILENAME} -- -d ${DEST}-${RELEASE:1}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue