From 59a796729d7ad7595d321340e3e81e478ace54ad Mon Sep 17 00:00:00 2001 From: Oskar Joelsson Date: Fri, 2 Jul 2021 11:41:11 +0200 Subject: [PATCH 1/4] uses buildx for docker to use m1 (arm64) architecture, and build either pvvx or atc1441 --- .gitignore | 1 + 00_bootstrap.sh | 27 +++++++++++++++++++++------ 01_make.sh | 18 +++++++++++++++++- README.md | 4 ++-- 4 files changed, 41 insertions(+), 9 deletions(-) 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..d75f7a2 100755 --- a/00_bootstrap.sh +++ b/00_bootstrap.sh @@ -1,13 +1,28 @@ #!/bin/bash +$MAKE_COMMAND + +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..19f828c 100755 --- a/01_make.sh +++ b/01_make.sh @@ -1,3 +1,19 @@ #!/bin/bash +echo \#\# +echo \#\# Build +echo \#\# +if [ -d "ATC_MiThermometer/ATC_Thermometer" ]; then + docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer/ATC_Thermometer && TEL_PATH=../../SDK make $@" + echo \#\# + echo \#\# Built atc1441 ATC_MiThermometer +else + docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer && TEL_PATH=../SDK make $@" + echo \#\# + echo \#\# Built pvvx ATC_MiThermometer \(if you\'re not using windows an error will occor on validation with tl_check_fw2.exe, it\'s okey\) +fi +echo \#\# -docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer/ATC_Thermometer && TEL_PATH=../../SDK make $@" +mkdir -p firmware +echo \#\# +cp ATC_MiThermometer/ATC_Thermometer.bin firmware/ATC_Thermometer_"$(date +%s)".bin && echo \#\# Here is your awesome firmware: firmware/ATC_Thermometer_"$(date +%s)".bin || 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. From f0335f234d622b289727bbf308c364a71ef5ddce Mon Sep 17 00:00:00 2001 From: Oskar Joelsson Date: Fri, 2 Jul 2021 11:45:15 +0200 Subject: [PATCH 2/4] removes unused variable --- 00_bootstrap.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/00_bootstrap.sh b/00_bootstrap.sh index d75f7a2..4d89106 100755 --- a/00_bootstrap.sh +++ b/00_bootstrap.sh @@ -1,5 +1,4 @@ #!/bin/bash -$MAKE_COMMAND if [ ! -d "ATC_MiThermometer" ]; then read -p "Select flavor of firmware, 'atc1441' or 'pvvx' [atc1441]: " FLAVOR From 5bb7a935f4000687d6eeb5d1daddcc546a2f63a4 Mon Sep 17 00:00:00 2001 From: Oskar Joelsson Date: Fri, 2 Jul 2021 12:36:53 +0200 Subject: [PATCH 3/4] in 01_make select devicetype --- 01_make.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/01_make.sh b/01_make.sh index 19f828c..86e78b1 100755 --- a/01_make.sh +++ b/01_make.sh @@ -1,4 +1,7 @@ #!/bin/bash + +DEVICE_TYPE="LYWSD03MMC" # LYWSD03MMC, MHO_C401 or CGG1 + echo \#\# echo \#\# Build echo \#\# @@ -7,6 +10,7 @@ if [ -d "ATC_MiThermometer/ATC_Thermometer" ]; then echo \#\# echo \#\# Built atc1441 ATC_MiThermometer else + sed -i '' -E "s/#define DEVICE_TYPE.*\/\//#define DEVICE_TYPE\t\t\tDEVICE_$DEVICE_TYPE \/\//g" ATC_MiThermometer/src/app_config.h docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer && TEL_PATH=../SDK make $@" echo \#\# echo \#\# Built pvvx ATC_MiThermometer \(if you\'re not using windows an error will occor on validation with tl_check_fw2.exe, it\'s okey\) @@ -15,5 +19,6 @@ echo \#\# mkdir -p firmware echo \#\# -cp ATC_MiThermometer/ATC_Thermometer.bin firmware/ATC_Thermometer_"$(date +%s)".bin && echo \#\# Here is your awesome firmware: firmware/ATC_Thermometer_"$(date +%s)".bin || echo \#\# No file found +firmware_out=firmware/ATC_Thermometer_"$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 \#\# From aa53dc71bbccea2956804b1b7c45ad2f3e0f22b7 Mon Sep 17 00:00:00 2001 From: Oskar Joelsson Date: Fri, 2 Jul 2021 12:46:49 +0200 Subject: [PATCH 4/4] cleanup and add atcmithermometer flavor in name --- 01_make.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/01_make.sh b/01_make.sh index 86e78b1..562a55e 100755 --- a/01_make.sh +++ b/01_make.sh @@ -1,24 +1,24 @@ #!/bin/bash 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 - docker run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer/ATC_Thermometer && TEL_PATH=../../SDK make $@" - echo \#\# - echo \#\# Built atc1441 ATC_MiThermometer -else +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 run --rm -v $PWD:/app -it tc32 -c "cd ATC_MiThermometer && TEL_PATH=../SDK make $@" - echo \#\# - echo \#\# Built pvvx ATC_MiThermometer \(if you\'re not using windows an error will occor on validation with tl_check_fw2.exe, it\'s okey\) + 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_"$DEVICE_TYPE"_"$(date +%s)".bin +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 \#\#