Install routines and docker build
This commit is contained in:
parent
0ae0955640
commit
807682ab69
3 changed files with 121 additions and 9 deletions
|
@ -1,15 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ZMK_DIR="$HOME/zmk"
|
||||
CONFIG_DIR="$HOME/zmk-config"
|
||||
OUTPUT_DIR="$WINHOME/Downloads"
|
||||
WEST_OPTS="$@"
|
||||
OUTPUT_DIR="$WINHOME/Downloads"
|
||||
|
||||
HOST_ZMK_DIR="$HOME/zmk"
|
||||
HOST_CONFIG_DIR="$HOME/zmk-config"
|
||||
|
||||
RUNWITH_DOCKER=true
|
||||
DOCKER_SUDO="sudo" # leave empty if user is in docker group
|
||||
DOCKER_VERSION="zmkfirmware/zmk-dev-arm:3.0"
|
||||
|
||||
DOCKER_ZMK_DIR="/workspace/zmk"
|
||||
DOCKER_CONFIG_DIR="/workspace/zmk-config"
|
||||
|
||||
# +-------------------------+
|
||||
# | AUTOMATE CONFIG OPTIONS |
|
||||
# +-------------------------+
|
||||
|
||||
cd "$CONFIG_DIR"
|
||||
cd "$HOST_CONFIG_DIR"
|
||||
|
||||
# update maximum combos per key
|
||||
count=$( \
|
||||
|
@ -35,22 +43,44 @@ echo "Setting MAX_KEYS_PER_COMBO to $count"
|
|||
# | BUILD THE FIRMWARE |
|
||||
# +--------------------+
|
||||
|
||||
if [[ $RUNWITH_DOCKER = true ]]
|
||||
then
|
||||
echo "Build mode: docker"
|
||||
DOCKER_CMD="$DOCKER_SUDO docker run --name zmk --rm -w $DOCKER_ZMK_DIR/app \
|
||||
--mount type=bind,source=$HOST_ZMK_DIR,target=$DOCKER_ZMK_DIR \
|
||||
--mount type=bind,source=$HOST_CONFIG_DIR,target=$DOCKER_CONFIG_DIR,readonly \
|
||||
--mount type=volume,source=zmk-root-user,target=/root \
|
||||
--mount type=volume,source=zmk-zephyr,target=$DOCKER_ZMK_DIR/zephyr \
|
||||
--mount type=volume,source=zmk-zephyr-modules,target=$DOCKER_ZMK_DIR/modules \
|
||||
--mount type=volume,source=zmk-zephyr-tools,target=$DOCKER_ZMK_DIR/tools \
|
||||
$DOCKER_VERSION"
|
||||
SUFFIX="_docker"
|
||||
CONFIG_DIR="$DOCKER_CONFIG_DIR/config"
|
||||
|
||||
else
|
||||
echo "Build mode: local"
|
||||
DOCKER_CMD=
|
||||
SUFFIX=
|
||||
CONFIG_DIR="$HOST_CONFIG_DIR/config"
|
||||
fi
|
||||
|
||||
# usage: compile_board [board] [bin|uf2]
|
||||
compile_board () {
|
||||
echo -e "\n$(tput setaf 4)Building $1$(tput sgr0)"
|
||||
west build -d build/$1 -b $1 ${WEST_OPTS} -- -DZMK_CONFIG="$CONFIG_DIR/config" -Wno-dev
|
||||
$DOCKER_CMD west build -d "build/$1$SUFFIX" -b $1 $WEST_OPTS \
|
||||
-- -DZMK_CONFIG="$CONFIG_DIR" -Wno-dev
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
echo "$(tput setaf 4)Success: $1 done$(tput sgr0)"
|
||||
OUTPUT="$OUTPUT_DIR/$1-zmk.$2"
|
||||
[[ -f $OUTPUT ]] && [[ ! -L $OUTPUT ]] && mv "$OUTPUT" "$OUTPUT".bak
|
||||
cp "$ZMK_DIR/app/build/$1/zephyr/zmk.$2" "$OUTPUT"
|
||||
[[ -f $OUTPUT ]] && [[ ! -L $OUTPUT ]] && mv "$OUTPUT" "$OUTPUT.bak"
|
||||
cp "$HOST_ZMK_DIR/app/build/$1/zephyr/zmk.$2" "$OUTPUT"
|
||||
else
|
||||
echo "$(tput setaf 1)Error: $1$ failed$(tput sgr0)"
|
||||
echo "$(tput setaf 1)Error: $1 failed$(tput sgr0)"
|
||||
fi
|
||||
}
|
||||
|
||||
cd "$ZMK_DIR/app"
|
||||
cd "$HOST_ZMK_DIR/app"
|
||||
compile_board planck_rev6 bin
|
||||
compile_board corneish_zen_v2_left uf2
|
||||
compile_board corneish_zen_v2_right uf2
|
||||
|
|
25
scripts/zmk_docker_install.sh
Executable file
25
scripts/zmk_docker_install.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
HOST_ZMK_DIR="$HOME/zmk"
|
||||
DOCKER_ZMK_DIR="/workspace/zmk"
|
||||
|
||||
DOCKER_VERSION="zmkfirmware/zmk-dev-arm:3.0"
|
||||
|
||||
DOCKER_SUDO="sudo" # leave empty if user is in docker group
|
||||
DOCKER_CMD="$DOCKER_SUDO docker run --name zmk --rm \
|
||||
--mount type=bind,source=$HOST_ZMK_DIR,target=$DOCKER_ZMK_DIR \
|
||||
--mount type=volume,source=zmk-root-user,target=/root \
|
||||
--mount type=volume,source=zmk-zephyr,target=$DOCKER_ZMK_DIR/zephyr \
|
||||
--mount type=volume,source=zmk-zephyr-modules,target=$DOCKER_ZMK_DIR/modules \
|
||||
--mount type=volume,source=zmk-zephyr-tools,target=$DOCKER_ZMK_DIR/tools"
|
||||
|
||||
# Reset volumes
|
||||
$DOCKER_SUDO docker volume rm $(sudo docker volume ls -q | grep zmk-)
|
||||
|
||||
# Install west
|
||||
$DOCKER_CMD -w "$DOCKER_ZMK_DIR" "$DOCKER_VERSION" west init -l app/
|
||||
$DOCKER_CMD -w "$DOCKER_ZMK_DIR" "$DOCKER_VERSION" west update
|
||||
|
||||
# Install docosaurus
|
||||
$DOCKER_CMD -w "$DOCKER_ZMK_DIR/docs" "$DOCKER_VERSION" npm ci
|
||||
|
57
scripts/zmk_local_install.sh
Executable file
57
scripts/zmk_local_install.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
### Step 1: Update OS
|
||||
sudo apt update
|
||||
sudo apt upgrade
|
||||
|
||||
### Step 2: Install dependencies
|
||||
sudo apt-get install --yes --no-install-recommends git cmake ninja-build gperf \
|
||||
ccache dfu-util device-tree-compiler wget \
|
||||
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
|
||||
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
|
||||
|
||||
### Step 3: Install Zephyr SDK
|
||||
|
||||
# Find latest release version
|
||||
ZSDK_URL="https://github.com/zephyrproject-rtos/sdk-ng/releases/latest"
|
||||
export ZSDK_VERSION="$(curl -fsSLI -o /dev/null -w %{url_effective} ${ZSDK_URL} | sed 's/^.*v//')"
|
||||
|
||||
# Download and verify latest Zephyr SDK bundle
|
||||
cd ~/.local
|
||||
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}_linux-x86_64.tar.gz
|
||||
wget -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/sha256.sum | shasum --check --ignore-missing
|
||||
## TODO: abort if exit code is error
|
||||
|
||||
# Extract the Zephyr SDK bundle archive
|
||||
tar xvf zephyr-sdk-${ZSDK_VERSION}_linux-x86_64.tar.gz
|
||||
rm zephyr-sdk-${ZSDK_VERSION}_linux-x86_64.tar.gz
|
||||
|
||||
# Run the Zephyr SDK bundle setup script
|
||||
cd zephyr-sdk-${ZSDK_VERSION}
|
||||
./setup.sh
|
||||
|
||||
# Install udev rules, which allow you to flash most Zephyr boards as a regular user
|
||||
sudo cp ~/zephyr-sdk-${ZSDK_VERSION}/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
|
||||
sudo udevadm control --reload
|
||||
|
||||
### Step 4: Get Zephyr and install Python dependencies
|
||||
|
||||
# Install West
|
||||
pip3 install --user -U west # may need to replace with "python3 -m pip" or "python -m pip"
|
||||
|
||||
# Get the Zephyr cource code:
|
||||
cd ~/zmk
|
||||
west init -l app/
|
||||
west update
|
||||
|
||||
# Export a Zephyr CMake package to allow CMake to load the code needed to build ZMK
|
||||
west zephyr-export
|
||||
|
||||
# Install Zephyr Python Dependencies
|
||||
pip3 install --user -r zephyr/scripts/requirements.txt # see above
|
||||
|
||||
### Step 5: Install Docusaurus
|
||||
sudo apt-get install --yes --no-install-recommends npm
|
||||
cd ~zmk/docs
|
||||
npm ci
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue