Skip to content

Commit

Permalink
MarlinBft - custom short (8+3) firmware name and bin output support (b…
Browse files Browse the repository at this point in the history
…igtreetech#1037)

* Custom short firmware name

* Expand HARDWARE_SHORT descriptions to all env
  • Loading branch information
GeminiServer authored and Manu512 committed Nov 3, 2020
1 parent 9fb7bb4 commit e1ce923
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 15 deletions.
8 changes: 8 additions & 0 deletions TFT/src/User/API/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ void scanRenameUpdate(void) {
}
f_rename(FIRMWARE_NAME ".bin", FIRMWARE_NAME ".CUR");
}

if (f_file_exists(FIRMWARE_NAME_SHORT ".NEW")) { // firmware exists
if (f_file_exists(FIRMWARE_NAME ".bin")) { // long firmware also exists ? should not be
f_unlink(FIRMWARE_NAME ".bin");
}
f_rename(FIRMWARE_NAME_SHORT ".NEW", FIRMWARE_NAME ".bin");
}

if (f_file_exists(CONFIG_FILE_PATH))
{ // config exists
if (f_file_exists(CONFIG_FILE_PATH ".CUR"))
Expand Down
1 change: 1 addition & 0 deletions TFT/src/User/API/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extern "C" {

#define ADMIN_MODE_FILE "0:admin.txt"
#define FIRMWARE_NAME STRINGIFY(HARDWARE) "." STRINGIFY(SOFTWARE_VERSION)
#define FIRMWARE_NAME_SHORT STRINGIFY(HARDWARE_SHORT) STRINGIFY(SOFTWARE_VERSION_SHORT)
#define BMP_ROOT_DIR "0:" ROOT_DIR "/bmp"
#define FONT_ROOT_DIR "0:" ROOT_DIR "/font"
#define TFT_RESET_FILE "0:reset.txt"
Expand Down
15 changes: 15 additions & 0 deletions buildroot/scripts/short_out_filename.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Import("env")
import shutil

def make_short_file(source, target, env):
print("Generating firmware with short file name...")
buildDir = env.subst('$BUILD_DIR')
build_flags = env.ParseFlags(env['BUILD_FLAGS'])
flags = {k: v for (k, v) in build_flags.get("CPPDEFINES")}
filename = flags.get("HARDWARE") + "." + flags.get("SOFTWARE_VERSION")
filename_short = flags.get("HARDWARE_SHORT") + flags.get("SOFTWARE_VERSION_SHORT")
# do some actions
shutil.copyfile(buildDir+"/"+filename+".bin", buildDir+"/"+filename_short+".new")
print("Done.")

env.AddPostAction("buildprog", make_short_file)
49 changes: 34 additions & 15 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ build_flags = -fmax-errors=5
-ITFT/src/User/Hal/STM32_USB_HOST_Library/Usr/inc
-ITFT/src/User/Hal/STM32_USB_OTG_Driver/inc
-DSOFTWARE_VERSION=26.x
-DSOFTWARE_VERSION_SHORT=26
extra_scripts = post:buildroot/scripts/short_out_filename.py
pre:buildroot/scripts/custom_filename.py


[stm32f10x]
default_src_filter = ${common.default_src_filter} +<src/Libraries/cmsis/stm32f10x> +<src/Libraries/fwlib/stm32f10x> +<src/User/Hal/stm32f10x>
Expand Down Expand Up @@ -91,14 +95,15 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_hd>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x6000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_HD=
-DHSE_VALUE=16000000ul
-DVECT_TAB_FLASH=0x08006000
-DHARDWARE="BIQU_TFT35_V1.0"
-DTFT35_V1_0=
-DHARDWARE_SHORT="B35V10"
-DTFT35_V1_0="B35V10"

#
# BIGTREE TFT35 V1.1
Expand All @@ -109,13 +114,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_hd>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x6000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_HD=
-DHSE_VALUE=16000000ul
-DVECT_TAB_FLASH=0x08006000
-DHARDWARE="BIQU_TFT35_V1.1"
-DHARDWARE_SHORT="B35V11"
-DTFT35_V1_1=

#
Expand All @@ -127,13 +133,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_hd>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x6000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_HD=
-DHSE_VALUE=16000000ul
-DVECT_TAB_FLASH=0x08006000
-DHARDWARE="BIQU_TFT35_V1.2"
-DHARDWARE_SHORT="B35V12"
-DTFT35_V1_2=

#
Expand All @@ -145,13 +152,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_hd>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x3000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_HD=
-DHSE_VALUE=16000000ul
-DVECT_TAB_FLASH=0x08003000
-DHARDWARE="BIQU_TFT35_APP1_V2.0"
-DHARDWARE_SHORT="B35V20"
-DTFT35_V2_0=
monitor_speed = 250000

Expand All @@ -164,13 +172,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f2xx.default_src_filter} +<src/Libraries/Startup/stm32f2xx>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f2xx_0x8000_iap.py
build_flags = ${stm32f2xx.build_flags}
-DSTM32F2XX=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT35_V3.0"
-DHARDWARE_SHORT="B35V30"
-DTFT35_V3_0=

#
Expand All @@ -182,13 +191,15 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f2xx.default_src_filter} +<src/Libraries/Startup/stm32f2xx>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f2xx_0x8000_iap.py

build_flags = ${stm32f2xx.build_flags}
-DSTM32F2XX=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT35_V3.0_E3"
-DHARDWARE_SHORT="35V3E3"
-DTFT35_E3_V3_0=

#
Expand All @@ -200,13 +211,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f2xx.default_src_filter} +<src/Libraries/Startup/stm32f2xx>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f2xx_0x8000_iap.py
build_flags = ${stm32f2xx.build_flags}
-DSTM32F2XX=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT43_V3.0"
-DHARDWARE_SHORT="B43V30"
-DTFT43_V3_0=

#
Expand All @@ -218,13 +230,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f2xx.default_src_filter} +<src/Libraries/Startup/stm32f2xx>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f2xx_0x8000_iap.py
build_flags = ${stm32f2xx.build_flags}
-DSTM32F2XX=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT50_V3.0"
-DHARDWARE_SHORT="B50V30"
-DTFT50_V3_0=

#
Expand All @@ -236,13 +249,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f4xx.default_src_filter} +<src/Libraries/Startup/stm32f40_41x>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f4xx_0x8000_iap.py
build_flags = ${stm32f4xx.build_flags}
-DSTM32F40_41xxx=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT70_V3.0"
-DHARDWARE_SHORT="B70V30"
-DTFT70_V3_0=

#
Expand All @@ -254,13 +268,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_hd>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x6000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_HD=
-DHSE_VALUE=16000000ul
-DVECT_TAB_FLASH=0x08006000
-DHARDWARE="BIQU_TFT28_V1.0"
-DHARDWARE_SHORT="B28V10"
-DTFT28_V1_0=

#
Expand All @@ -272,13 +287,14 @@ framework = stm32cube
board = STM32F103VC
upload_protocol = cmsis-dap
src_filter = ${stm32f2xx.default_src_filter} +<src/Libraries/Startup/stm32f2xx>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f2xx_0x8000_iap.py
build_flags = ${stm32f2xx.build_flags}
-DSTM32F2XX=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08008000
-DHARDWARE="BIGTREE_TFT28_V3.0"
-DHARDWARE_SHORT="B28V30"
-DTFT28_V3_0=

#
Expand All @@ -290,13 +306,14 @@ framework = stm32cube
board = STM32F105RC
upload_protocol = cmsis-dap
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_cl>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x6000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_CL=
-DHSE_VALUE=8000000ul
-DVECT_TAB_FLASH=0x08006000
-DHARDWARE="BIGTREE_TFT24_V1.1"
-DHARDWARE_SHORT="B24V11"
-DTFT24_V1_1=

#
Expand All @@ -309,13 +326,14 @@ board = STM32F107VC
upload_protocol = stlink
debug_tool = stlink
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_cl>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x7000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_CL=
-DHSE_VALUE=25000000ul
-DVECT_TAB_FLASH=0x08007000
-DHARDWARE="MKS_32_V1_4"
-DHARDWARE_SHORT="M32V14"
-DMKS_32_V1_4=

#
Expand All @@ -328,11 +346,12 @@ board = STM32F107VC
upload_protocol = stlink
debug_tool = stlink
src_filter = ${stm32f10x.default_src_filter} +<src/Libraries/Startup/stm32f10x_cl>
extra_scripts = pre:buildroot/scripts/custom_filename.py
extra_scripts = ${common.extra_scripts}
buildroot/scripts/stm32f10x_0x0000_iap.py
build_flags = ${stm32f10x.build_flags}
-DSTM32F10X_CL=
-DHSE_VALUE=25000000ul
-DVECT_TAB_FLASH=0x08000000
-DHARDWARE="MKS_32_V1_4"
-DHARDWARE_SHORT="M32V14"
-DMKS_32_V1_4=

0 comments on commit e1ce923

Please sign in to comment.