Fixes for zephyr install scripts and place apt keys for conda in the standard place.
This commit is contained in:
parent
e15aaf3b04
commit
04166a1664
22
020_conda.sh
22
020_conda.sh
|
|
@ -1,22 +1,25 @@
|
|||
DEST=${1:-/etc/skel}
|
||||
|
||||
# Install our public GPG key to trusted store
|
||||
curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg
|
||||
install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg
|
||||
# KEY_DIR=/usr/share/keyrings
|
||||
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)
|
||||
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
|
||||
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
|
||||
|
||||
ln -s /etc/apt/sources.list-available/conda.list /etc/apt/sources.list.d/conda.list
|
||||
|
||||
sudo ln -sf /etc/apt/sources.list-available/conda.list /etc/apt/sources.list.d/conda.list
|
||||
|
||||
# Install it!
|
||||
apt update
|
||||
apt install -y conda
|
||||
sudo apt update
|
||||
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
|
||||
# when using conda from the vim plugin it expects to be called from base conda environment.
|
||||
|
|
@ -46,7 +49,6 @@ EOF
|
|||
|
||||
# see: https://github.com/ubaldot/vim-conda-activate for vim support
|
||||
|
||||
|
||||
# Check to see if the installation is successful:
|
||||
. /opt/conda/etc/profile.d/conda.sh
|
||||
conda -V
|
||||
|
|
|
|||
124
020_zephyr.sh
124
020_zephyr.sh
|
|
@ -3,6 +3,10 @@
|
|||
# https://www.zephyrproject.org/zephyr-rtos-on-esp32/
|
||||
# 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
|
||||
# $ openocd \
|
||||
|
|
@ -42,23 +46,33 @@ DEST=${1:-${HOME}}
|
|||
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
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
|
||||
PROJECT=sdk-ng
|
||||
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'})
|
||||
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_URL=https://github.com/${USER}/${PROJECT}/releases/download/${RELEASE}/
|
||||
SDK_URL=https://github.com/${USER}/${PROJECT}/releases/download/${RELEASE}
|
||||
|
||||
# fetch the sdk
|
||||
# wget ${SDK_URL}/${SDK_FILENAME}
|
||||
# wget -O - ${SDK_URL}/sha256.sum | shasum --check --ignore-missing
|
||||
|
||||
wget -c ${SDK_URL}/${SDK_FILENAME}
|
||||
wget -c -O - ${SDK_URL}/sha256.sum | shasum --check --ignore-missing
|
||||
|
||||
SDK_DEST=${DEST}/zephyr-sdk-${RELEASE#v}
|
||||
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
|
||||
ZEPHYR_ENV_FILE="${HOME}/.zshrc.d/001_zephyr.zsh"
|
||||
|
|
@ -69,24 +83,9 @@ export ZEPHYR_SDK_INSTALL_DIR="${SDK_DEST}"
|
|||
|
||||
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"
|
||||
# xdg-open ${RSS_FEED}
|
||||
cat ${RSS_FEED}
|
||||
echo ${RSS_FEED}
|
||||
|
||||
echo "*** Installing dependencies. ***"
|
||||
sudo apt-get update
|
||||
|
|
@ -100,7 +99,7 @@ sudo apt install --no-install-recommends -y autoconf automake \
|
|||
echo "*** Getting Zephyr and installing Python dependencies. ***"
|
||||
# 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
|
||||
# echo 'export PATH=${HOME}/.local/bin:”$PATH”' >>${HOME}/.bashrc
|
||||
|
||||
|
|
@ -109,19 +108,28 @@ echo "*** Installing west with pip3 ***"
|
|||
# fi
|
||||
|
||||
# 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://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
|
||||
if [[ ! -d ${HOME}/.conda/envs/zephyr ]];
|
||||
conda init -n zephyr python west pynrfjprog dtsh # pyocd pylink
|
||||
fi
|
||||
|
||||
if [[ ! -d "${HOME}/.conda/envs/zephyr" ]]; then
|
||||
echo "Creating the zephyr environment with conda."
|
||||
conda create -n zephyr python=${PYTHON_VERSION}
|
||||
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}
|
||||
pip install --no-input west pynrfjprog dtsh
|
||||
echo "Zephyr environment created successfully."
|
||||
else
|
||||
echo "Zephyr environment already exists."
|
||||
fi
|
||||
|
||||
# Create west configuation file.
|
||||
cat <<EOF | tee ${HOME}/.westconfig
|
||||
|
|
@ -131,19 +139,57 @@ cat <<EOF | tee ${HOME}/.westconfig
|
|||
[build]
|
||||
# pristine = auto
|
||||
#board = nrf52840dk/nrf52840
|
||||
#dir-fmt = build/{board}
|
||||
#dir-fmt = build/\${board}
|
||||
#guess-dir = runners
|
||||
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 init -m https://github.com/zephyrproject-rtos/zephyr --mr v2.5.0 zephyrproject
|
||||
|
||||
echo "*** Getting zephyr source code ***"
|
||||
git clone https://github.com/${USER}/zephyr
|
||||
mkdir -p ${DEST}/zephyr
|
||||
cd ${DEST}/zephyr
|
||||
git show -s --pretty=format:%cd
|
||||
|
||||
# Move into the conda venv
|
||||
conda activate zephyr
|
||||
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
|
||||
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
|
||||
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."
|
||||
west zephyr-export
|
||||
|
|
@ -152,12 +198,4 @@ echo "Installing additional python dependencies via pip3."
|
|||
pip install -r \
|
||||
${HOME}/zephyrproject/zephyr/scripts/requirements.txt
|
||||
|
||||
echo "Installing Zephyr's toolchain."
|
||||
#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}
|
||||
conda deactivate
|
||||
|
|
|
|||
Loading…
Reference in New Issue