Skip to content

Instantly share code, notes, and snippets.

@dogukancagatay
Last active October 16, 2020 23:04
Show Gist options
  • Save dogukancagatay/a8040c9cd240ba786fd0bbbc186af9f4 to your computer and use it in GitHub Desktop.
Save dogukancagatay/a8040c9cd240ba786fd0bbbc186af9f4 to your computer and use it in GitHub Desktop.
Configurable Marlin Firmware build script (with PlatformIO CLI) for BigTreeTech SKR Mini E3 2.0 board
dist
Configurations
Marlin
BIGTREETECH-TouchScreenFirmware

Configurable Marlin Build Script

Build script that builds Marlin Firmware for BigTreeTech SKR Mini E3 2.0 and Touch Screen Firmware for BigTreeTech TFT35 E3 V3.0 screen.

You can it is easily configure scripts to build firmware for your board and screen using environment variables inside build scripts.

Building Marlin Firmware

Configuration

  • MARLIN_BRANCH: Preffered git branch of Marlin repository to build.
  • MARLIN_CONF_BRANCH: Preferred git branch to copy configuration from.
  • BOARD_CONF_DIR: Relative path for configuration directory of your board on Configurations repo.
  • BOARD_ENV: You can find your board's environment in platformio.ini file.

Building

./build_marlin_fw.sh

Output

Built firmware (firmware.bin file) will be copied under dist/Marlin (at project root) inside a directory.

Building BIGTREETECH Touch Screen Firmware

It has less items to configure than Marlin.

Configuration

Just set your screen to BOARD_ENV and BOARD_TYPE inside build_btt_tft_fw.sh.

You can find the list of options for BOARD_ENV on platform.ini file in firmware repository. The default is BIGTREE_TFT35_E3_V3_0.

The options for BOARD_TYPE are the directory names listed here. Default value is TFT35.

Building

./build_btt_tft_fw.sh

Output

Built firmware (.bin file and other config.ini ) will be copied under dist/Marlin (at project root) inside a directory.

#!/usr/bin/env bash
BUILD_TIME="`date +%Y-%m-%d-%H-%M-%S`"
BUILD_DIR="dist/btt-tft/$BUILD_TIME"
BTT_TFT_REPO="https://github.com/bigtreetech/BIGTREETECH-TouchScreenFirmware.git"
BTT_TFT_REPO_DIR="BIGTREETECH-TouchScreenFirmware"
BTT_TFT_REPO_BRANCH="master"
BOARD_ENV="BIGTREE_TFT35_E3_V3_0"
BOARD_TYPE="TFT35"
if [ ! -d "$BTT_TFT_REPO_DIR" ]; then
git clone "$BTT_TFT_REPO" "$BTT_TFT_REPO_DIR"
cd "$BTT_TFT_REPO_DIR"
git checkout "$BTT_TFT_REPO_BRANCH"
cd ..
# else
# cd "$BTT_TFT_REPO_DIR"
# git clean -fx
# git reset --hard
# cd ..
fi
cd "$BTT_TFT_REPO_DIR"
platformio run -e "$BOARD_ENV"
mkdir -p "../$BUILD_DIR/"
cp "`find .pio/build -iname *.bin`" "../$BUILD_DIR/"
cp "Copy to SD Card root directory to update - Unified Menu Material theme"/config.ini "../$BUILD_DIR/"
cp -r "Copy to SD Card root directory to update - Unified Menu Material theme/$BOARD_TYPE" "../$BUILD_DIR/"
cd ..
#!/usr/bin/env bash
RUN="docker exec -it marlin-builder"
docker run -d -v "$PWD:/app" --name marlin-builder --workdir /app python:slim sleep 900 || docker start marlin-builder
$RUN bash -c 'apt-get update && apt-get install -y curl git'
$RUN bash -c '[ ! -d ~/.platformio/penv/bin ] && python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"'
$RUN bash -c 'PATH=$PATH:~/.platformio/penv/bin ./build_btt_tft_fw.sh'
docker stop marlin-builder
#!/usr/bin/env bash
BUILD_TIME="`date +%Y-%m-%d-%H-%M-%S`"
BUILD_DIR="dist/Marlin/$BUILD_TIME"
MARLIN_REPO="https://github.com/MarlinFirmware/Marlin.git"
MARLIN_REPO_DIR="Marlin"
MARLIN_BRANCH="bugfix-2.0.x" # OR 2.0.x
MARLIN_CONF_REPO="https://github.com/MarlinFirmware/Configurations.git"
MARLIN_CONF_REPO_DIR="Configurations"
MARLIN_CONF_BRANCH="bugfix-2.0.x" # OR import-2.0.x
BOARD_CONF_DIR="config/examples/Creality/Ender-3 Pro/BigTreeTech SKR Mini E3 2.0"
BOARD_ENV="STM32F103RC_btt_512K"
if [ ! -d "$MARLIN_REPO_DIR" ]; then
git clone "$MARLIN_REPO" "$MARLIN_REPO_DIR"
cd "$MARLIN_REPO_DIR"
git checkout "$MARLIN_BRANCH"
cd ..
# else
# cd "$MARLIN_REPO_DIR"
# git clean -fx
# git reset --hard
# cd ..
fi
if [ ! -d "$MARLIN_CONF_REPO_DIR" ]; then
git clone "$MARLIN_CONF_REPO" "$MARLIN_CONF_REPO_DIR"
cd "$MARLIN_CONF_REPO_DIR"
git checkout "$MARLIN_CONF_BRANCH"
cd ..
fi
CONF_DIR="$MARLIN_CONF_REPO_DIR/$BOARD_CONF_DIR"
cp -f "$CONF_DIR"/* "$MARLIN_REPO_DIR/Marlin/"
cd "$MARLIN_REPO_DIR"
platformio run -e "$BOARD_ENV"
mkdir -p "../$BUILD_DIR/"
cp "`find .pio/build -name firmware.bin`" "../$BUILD_DIR/"
cd ..
#!/usr/bin/env bash
RUN="docker exec -it marlin-builder"
docker run -d -v "$PWD:/app" --name marlin-builder --workdir /app python:slim sleep 900 || docker start marlin-builder
$RUN bash -c 'apt-get update && apt-get install -y curl git'
$RUN bash -c '[ ! -d ~/.platformio/penv/bin ] && python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"'
$RUN bash -c 'PATH=$PATH:~/.platformio/penv/bin ./build_marlin_fw.sh'
docker stop marlin-builder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment