diff --git a/.gitignore b/.gitignore index 2c4fa8e..d67de4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ docker/tc32_gcc.tar.bz2 SDK/ ATC_MiThermometer/ +firmware/ \ No newline at end of file diff --git a/00_bootstrap.sh b/00_bootstrap.sh index e74b351..4d89106 100755 --- a/00_bootstrap.sh +++ b/00_bootstrap.sh @@ -1,13 +1,27 @@ #!/bin/bash +if [ ! -d "ATC_MiThermometer" ]; then + read -p "Select flavor of firmware, 'atc1441' or 'pvvx' [atc1441]: " FLAVOR +fi +FLAVOR=${FLAVOR:-atc1441} + + echo \#\# First prepare build environment -curl http://shyboy.oss-cn-shenzhen.aliyuncs.com/readonly/tc32_gcc_v2.0.tar.bz2 > docker/tc32_gcc.tar.bz2 -docker build ./docker/ -t tc32 +if [ ! -f "docker/tc32_gcc.tar.bz2" ]; then + curl http://shyboy.oss-cn-shenzhen.aliyuncs.com/readonly/tc32_gcc_v2.0.tar.bz2 > docker/tc32_gcc.tar.bz2 +fi +docker buildx build --platform linux/amd64 ./docker/ -t tc32 +if [ ! -d "SDK" ]; then + echo \#\# Now download Telink 825X SDK + git clone --depth=1 https://github.com/Ai-Thinker-Open/Telink_825X_SDK SDK +fi -echo \#\# Now download Telink 825X SDK -git clone --depth=1 https://github.com/Ai-Thinker-Open/Telink_825X_SDK SDK +if [ ! -d "ATC_MiThermometer" ]; then + echo \#\# Download ATC_MiThermometer project + git clone "https://github.com/$FLAVOR/ATC_MiThermometer" ATC_MiThermometer +fi -echo \#\# Download ATC_MiThermometer project -git clone https://github.com/atc1441/ATC_MiThermometer +echo \#\# Done, to change flavor delate folder ATC_MiThermometer and run again +echo \#\# run sh 01_make.sh to build the firmware \ No newline at end of file diff --git a/01_make.sh b/01_make.sh index a810d2c..562a55e 100755 --- a/01_make.sh +++ b/01_make.sh @@ -1,3 +1,24 @@ #!/bin/bash -docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer/ATC_Thermometer && TEL_PATH=../../SDK make $@" +DEVICE_TYPE="LYWSD03MMC" # LYWSD03MMC, MHO_C401 or CGG1 +DOCKER_COMMAND="cd ATC_MiThermometer/ATC_Thermometer && TEL_PATH=../../SDK make" +ATC_MITHERMOMETER_FLAVOR="atc1411" + +echo \#\# +echo \#\# Build +echo \#\# +if [ ! -d "ATC_MiThermometer/ATC_Thermometer" ]; then + sed -i '' -E "s/#define DEVICE_TYPE.*\/\//#define DEVICE_TYPE\t\t\tDEVICE_$DEVICE_TYPE \/\//g" ATC_MiThermometer/src/app_config.h + DOCKER_COMMAND="cd ATC_MiThermometer && TEL_PATH=../SDK make" + ATC_MITHERMOMETER_FLAVOR="pvvx" +fi +docker run --rm -v $PWD:/app -it tc32 -c "$DOCKER_COMMAND $@" +echo \#\# +echo \#\# Built $ATC_MITHERMOMETER_FLAVOR ATC_MiThermometer +echo \#\# + +mkdir -p firmware +echo \#\# +firmware_out=firmware/ATC_Thermometer_"$ATC_MITHERMOMETER_FLAVOR"_"$DEVICE_TYPE"_"$(date +%s)".bin +cp ATC_MiThermometer/ATC_Thermometer.bin $firmware_out && echo \#\# Here is your awesome firmware: $firmware_out || echo \#\# No file found +echo \#\# diff --git a/README.md b/README.md index c7d1bed..8b273fe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Build environment setup for ATC_MiThermometer -This is a tc32_gcc custom tailored build environment for https://github.com/atc1441/ATC_MiThermometer according to referenced instructions there for linux but in a docker container. +This is a tc32_gcc custom tailored build environment for https://github.com/atc1441/ATC_MiThermometer or https://github.com/pvvx/ATC_MiThermometer according to referenced instructions there for linux but in a docker container. It shall work on both Linux and macOS with following dependencies installed: * curl @@ -12,7 +12,7 @@ It shall work on both Linux and macOS with following dependencies installed: * build docker image containing tc32_gcc similar like mentioned in https://github.com/Ai-Thinker-Open/Telink_825X_SDK/blob/master/start_linux.md * fetches https://github.com/Ai-Thinker-Open/Telink_825X_SDK as SDK -* fetches https://github.com/atc1441/ATC_MiThermometer and patches makefile to be able to run with this build environment using custom SDK location +* fetches https://github.com/atc1441/ATC_MiThermometer or https://github.com/pvvx/ATC_MiThermometer and patches makefile to be able to run with this build environment using custom SDK location Afterwards you can simply use **01_make.sh** to compile ATC_MiThermometer. If you want you can also add parameter like "**./01_make.sh clean**" to it.