From 4425934d66b681fc50ebc5cce2910073317e74b0 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Tue, 26 Mar 2019 00:09:23 +0900 Subject: [PATCH 1/4] build size-check enhancement Changed to display a warning when the free size of compilation result is less than 512 bytes. --- message.mk | 1 + tmk_core/rules.mk | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/message.mk b/message.mk index 6894dd8cb504..86fc98b7af8c 100644 --- a/message.mk +++ b/message.mk @@ -80,3 +80,4 @@ MSG_CHECK_FILESIZE = Checking file size of $(TARGET).hex MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n +MSG_FILE_NEAR_LIMIT = The firmware size is the limit soon - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index c43f14292aaf..c80c59474137 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -390,7 +390,15 @@ check-size: $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \ $(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \ - if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); else $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; fi \ + if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ + printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \ + else \ + if [ $(FREE_SIZE) -lt 512 ]; then \ + $(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \ + else \ + $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \ + fi \ + fi \ fi else check-size: From 31e401fc8290dda96fc5fb016e6d91a627d91daf Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Tue, 26 Mar 2019 04:06:31 +0900 Subject: [PATCH 2/4] update message.mk --- message.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/message.mk b/message.mk index 86fc98b7af8c..1fb62ab3119d 100644 --- a/message.mk +++ b/message.mk @@ -80,4 +80,4 @@ MSG_CHECK_FILESIZE = Checking file size of $(TARGET).hex MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n -MSG_FILE_NEAR_LIMIT = The firmware size is the limit soon - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n +MSG_FILE_NEAR_LIMIT = The firmware size is nearly too large - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n From 2f08913bedd594160616d09f698be984ae85c687 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Tue, 26 Mar 2019 17:08:08 +0900 Subject: [PATCH 3/4] add SIZE_MARGIN variable, change default margin 512 to 1024 for Example. ``` $ make SIZE_MARGIN=2048 crkbd:all $ make crkbd:all ## mergin is 1024 ``` --- tmk_core/rules.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index c80c59474137..3a322cee4f25 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -383,6 +383,8 @@ show_path: @echo OBJ=$(OBJ) ifeq ($(findstring avr-gcc,$(CC)),avr-gcc) +SIZE_MARGIN = 1024 + check-size: $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne '/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) $(eval CURRENT_SIZE=$(shell if [ -f $(BUILD_DIR)/$(TARGET).hex ]; then $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex | $(AWK) 'NR==2 {print $$4}'; else printf 0; fi)) @@ -393,7 +395,7 @@ check-size: if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \ else \ - if [ $(FREE_SIZE) -lt 512 ]; then \ + if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \ $(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \ else \ $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \ From 9aacd70b4aebe5c48fd837477f965c64b5d6bb29 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 27 Mar 2019 14:18:03 +0900 Subject: [PATCH 4/4] Update message.mk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit change message to ‘approaching the maximum’ Co-Authored-By: mtei <2170248+mtei@users.noreply.github.com> --- message.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/message.mk b/message.mk index 1fb62ab3119d..71f37be0b5f8 100644 --- a/message.mk +++ b/message.mk @@ -80,4 +80,4 @@ MSG_CHECK_FILESIZE = Checking file size of $(TARGET).hex MSG_FILE_TOO_BIG = $(ERROR_COLOR)The firmware is too large!$(NO_COLOR) $(CURRENT_SIZE)/$(MAX_SIZE) ($(OVER_SIZE) bytes over)\n MSG_FILE_TOO_SMALL = The firmware is too small! $(CURRENT_SIZE)/$(MAX_SIZE)\n MSG_FILE_JUST_RIGHT = The firmware size is fine - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n -MSG_FILE_NEAR_LIMIT = The firmware size is nearly too large - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n +MSG_FILE_NEAR_LIMIT = The firmware size is approaching the maximum - $(CURRENT_SIZE)/$(MAX_SIZE) ($(FREE_SIZE) bytes free)\n