diff options
| author | Joel Challis <git@zvecr.com> | 2023-09-12 05:16:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-12 05:16:39 +0100 |
| commit | 06cec720dde5e4c9acfb476cbdf3e098a2172eee (patch) | |
| tree | f2dd40ad9a08a2061520d950c19d68a5459a7182 /platforms | |
| parent | ad4fc42e6be5da5c12e64b60f53839d951532a19 (diff) | |
Remove 'Firmware size check does not yet support' message (#21977)
Diffstat (limited to 'platforms')
| -rw-r--r-- | platforms/avr/platform.mk | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index 09028d80af..aef449cadf 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk | |||
| @@ -109,6 +109,29 @@ DEBUG_HOST = localhost | |||
| 109 | 109 | ||
| 110 | #============================================================================ | 110 | #============================================================================ |
| 111 | 111 | ||
| 112 | SIZE_MARGIN = 1024 | ||
| 113 | |||
| 114 | check-size: | ||
| 115 | $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) platforms/avr/bootloader_size.c 2> /dev/null | $(SED) -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0)) | ||
| 116 | $(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)) | ||
| 117 | $(eval FREE_SIZE=$(shell expr $(MAX_SIZE) - $(CURRENT_SIZE))) | ||
| 118 | $(eval OVER_SIZE=$(shell expr $(CURRENT_SIZE) - $(MAX_SIZE))) | ||
| 119 | $(eval PERCENT_SIZE=$(shell expr $(CURRENT_SIZE) \* 100 / $(MAX_SIZE))) | ||
| 120 | if [ $(MAX_SIZE) -gt 0 ] && [ $(CURRENT_SIZE) -gt 0 ]; then \ | ||
| 121 | $(SILENT) || printf "$(MSG_CHECK_FILESIZE)" | $(AWK_CMD); \ | ||
| 122 | if [ $(CURRENT_SIZE) -gt $(MAX_SIZE) ]; then \ | ||
| 123 | $(REMOVE) $(TARGET).$(FIRMWARE_FORMAT); \ | ||
| 124 | $(REMOVE) $(BUILD_DIR)/$(TARGET).{hex,bin,uf2}; \ | ||
| 125 | printf "\n * $(MSG_FILE_TOO_BIG)"; $(PRINT_ERROR_PLAIN); \ | ||
| 126 | else \ | ||
| 127 | if [ $(FREE_SIZE) -lt $(SIZE_MARGIN) ]; then \ | ||
| 128 | $(PRINT_WARNING_PLAIN); printf " * $(MSG_FILE_NEAR_LIMIT)"; \ | ||
| 129 | else \ | ||
| 130 | $(PRINT_OK); $(SILENT) || printf " * $(MSG_FILE_JUST_RIGHT)"; \ | ||
| 131 | fi ; \ | ||
| 132 | fi ; \ | ||
| 133 | fi | ||
| 134 | |||
| 112 | # Convert hex to bin. | 135 | # Convert hex to bin. |
| 113 | bin: $(BUILD_DIR)/$(TARGET).hex | 136 | bin: $(BUILD_DIR)/$(TARGET).hex |
| 114 | ifeq ($(BOOTLOADER),lufa-ms) | 137 | ifeq ($(BOOTLOADER),lufa-ms) |
