[AVR] Fix $(ELFSIZE) in Makefiles Topic is solved
Posted: Sat Aug 23, 2025 3:39 am
Binutils 2.26 (released in 2016) removed support for the "--mcu=$(MCU) --format=avr" options from the avr-size command.
Here's a patch to remove those options from the definition of ELFSIZE for AVR demos and tests.
However, when building for AVR targets, you so get the size of the resulting ELF file displayed twice
This could be fixed with a simple change to the AVR compiler rules, as the rule for %.sym already calls $(SZ) on the resulting elf file.
Here's a patch to remove those options from the definition of ELFSIZE for AVR demos and tests.
Code: Select all
From 998d169f4436a5da3510f2d6a12d9ba7d25ca120 Mon Sep 17 00:00:00 2001
From: Nathan Lewis <git@nrlewis.dev>
Date: Fri, 22 Aug 2025 19:17:16 -0700
Subject: [PATCH 1/2] AVR: remove "--mcu=$(MCU) --format=avr" from ELFSIZE.
These options were removed in binutils 2.26.
---
demos/AVR/NIL-ARDUINO-MEGA/Makefile | 2 +-
demos/AVR/NIL-ARDUINO-MINI/Makefile | 2 +-
demos/AVR/NIL-ARDUINO-NANO/Makefile | 2 +-
demos/AVR/NIL-ARDUINO-UNO/Makefile | 2 +-
demos/AVR/NIL-DIGISPARK-ATTINY-167/Makefile | 2 +-
demos/AVR/NIL-MT-DB-X4/Makefile | 2 +-
demos/AVR/RT-ARDUINO-LEONARDO/Makefile | 2 +-
demos/AVR/RT-ARDUINO-MEGA/Makefile | 2 +-
demos/AVR/RT-ARDUINO-MINI/Makefile | 2 +-
demos/AVR/RT-ARDUINO-NANO/Makefile | 2 +-
demos/AVR/RT-ARDUINO-UNO-G++/Makefile | 2 +-
demos/AVR/RT-ARDUINO-UNO/Makefile | 2 +-
demos/AVR/RT-DIGISPARK-ATTINY-167/Makefile | 2 +-
demos/AVR/RT-MT-DB-X4/Makefile | 2 +-
demos/AVR/RT-PRO-MICRO/Makefile | 2 +-
demos/AVR/RT-TEENSY2-USB/Makefile | 2 +-
demos/AVR/TEST-SUITE-NIL/Makefile | 2 +-
demos/AVR/TEST-SUITE-OSLIB/Makefile | 2 +-
demos/AVR/TEST-SUITE-RT/Makefile | 2 +-
testhal/AVR/MEGA/ADC/Makefile | 2 +-
testhal/AVR/MEGA/GPT/Makefile | 2 +-
testhal/AVR/MEGA/I2C/Makefile | 2 +-
testhal/AVR/MEGA/ICU/Makefile | 2 +-
testhal/AVR/MEGA/PWM/Makefile | 2 +-
testhal/AVR/MEGA/SPI/Makefile | 2 +-
testhal/AVR/XMEGA/CRC/Makefile | 2 +-
testhal/AVR/XMEGA/CRYPTO/Makefile | 2 +-
testhal/AVR/XMEGA/SERIAL/Makefile | 2 +-
testhal/AVR/XMEGA/SPI/Makefile | 2 +-
testhal/AVR/XMEGA/TEST-SUITE-OSLIB/Makefile | 2 +-
testhal/AVR/XMEGA/USART/Makefile | 2 +-
testhal/AVR/XMEGA/WDT/Makefile | 2 +-
testhal/AVR/multi/PAL/make/Makefile-arduino_mega.make | 2 +-
testhal/AVR/multi/PAL/make/Makefile-arduino_mini.make | 2 +-
testhal/AVR/multi/PAL/make/Makefile-arduino_nano.make | 2 +-
testhal/AVR/multi/PAL/make/Makefile-arduino_uno.make | 2 +-
36 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/demos/AVR/NIL-ARDUINO-MEGA/Makefile b/demos/AVR/NIL-ARDUINO-MEGA/Makefile
index d3f940a96..60060e943 100644
--- a/demos/AVR/NIL-ARDUINO-MEGA/Makefile
+++ b/demos/AVR/NIL-ARDUINO-MEGA/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/NIL-ARDUINO-MINI/Makefile b/demos/AVR/NIL-ARDUINO-MINI/Makefile
index ffe6b026b..324dadc8f 100644
--- a/demos/AVR/NIL-ARDUINO-MINI/Makefile
+++ b/demos/AVR/NIL-ARDUINO-MINI/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/NIL-ARDUINO-NANO/Makefile b/demos/AVR/NIL-ARDUINO-NANO/Makefile
index b35fdecd3..ea780153a 100644
--- a/demos/AVR/NIL-ARDUINO-NANO/Makefile
+++ b/demos/AVR/NIL-ARDUINO-NANO/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/NIL-ARDUINO-UNO/Makefile b/demos/AVR/NIL-ARDUINO-UNO/Makefile
index 30615ca40..de9e23e2f 100644
--- a/demos/AVR/NIL-ARDUINO-UNO/Makefile
+++ b/demos/AVR/NIL-ARDUINO-UNO/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/NIL-DIGISPARK-ATTINY-167/Makefile b/demos/AVR/NIL-DIGISPARK-ATTINY-167/Makefile
index 08d8e1c13..ab767b847 100644
--- a/demos/AVR/NIL-DIGISPARK-ATTINY-167/Makefile
+++ b/demos/AVR/NIL-DIGISPARK-ATTINY-167/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/NIL-MT-DB-X4/Makefile b/demos/AVR/NIL-MT-DB-X4/Makefile
index f745a7242..b3d82a86b 100644
--- a/demos/AVR/NIL-MT-DB-X4/Makefile
+++ b/demos/AVR/NIL-MT-DB-X4/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-LEONARDO/Makefile b/demos/AVR/RT-ARDUINO-LEONARDO/Makefile
index 84e9ccb17..ee2f9b38d 100644
--- a/demos/AVR/RT-ARDUINO-LEONARDO/Makefile
+++ b/demos/AVR/RT-ARDUINO-LEONARDO/Makefile
@@ -158,7 +158,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-MEGA/Makefile b/demos/AVR/RT-ARDUINO-MEGA/Makefile
index c78e08e1e..07dcf183c 100644
--- a/demos/AVR/RT-ARDUINO-MEGA/Makefile
+++ b/demos/AVR/RT-ARDUINO-MEGA/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-MINI/Makefile b/demos/AVR/RT-ARDUINO-MINI/Makefile
index d3d73de3c..68514e9d0 100644
--- a/demos/AVR/RT-ARDUINO-MINI/Makefile
+++ b/demos/AVR/RT-ARDUINO-MINI/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-NANO/Makefile b/demos/AVR/RT-ARDUINO-NANO/Makefile
index 11ea23ed1..cd3661a22 100644
--- a/demos/AVR/RT-ARDUINO-NANO/Makefile
+++ b/demos/AVR/RT-ARDUINO-NANO/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-UNO-G++/Makefile b/demos/AVR/RT-ARDUINO-UNO-G++/Makefile
index 67ba41f46..a6c40e8a1 100644
--- a/demos/AVR/RT-ARDUINO-UNO-G++/Makefile
+++ b/demos/AVR/RT-ARDUINO-UNO-G++/Makefile
@@ -158,7 +158,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-ARDUINO-UNO/Makefile b/demos/AVR/RT-ARDUINO-UNO/Makefile
index ee4b448b7..abb067358 100644
--- a/demos/AVR/RT-ARDUINO-UNO/Makefile
+++ b/demos/AVR/RT-ARDUINO-UNO/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-DIGISPARK-ATTINY-167/Makefile b/demos/AVR/RT-DIGISPARK-ATTINY-167/Makefile
index 6afbee426..d0c344313 100644
--- a/demos/AVR/RT-DIGISPARK-ATTINY-167/Makefile
+++ b/demos/AVR/RT-DIGISPARK-ATTINY-167/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-MT-DB-X4/Makefile b/demos/AVR/RT-MT-DB-X4/Makefile
index 4cdafadbb..be09e027c 100644
--- a/demos/AVR/RT-MT-DB-X4/Makefile
+++ b/demos/AVR/RT-MT-DB-X4/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-PRO-MICRO/Makefile b/demos/AVR/RT-PRO-MICRO/Makefile
index f50f328e0..f197ce004 100644
--- a/demos/AVR/RT-PRO-MICRO/Makefile
+++ b/demos/AVR/RT-PRO-MICRO/Makefile
@@ -158,7 +158,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/RT-TEENSY2-USB/Makefile b/demos/AVR/RT-TEENSY2-USB/Makefile
index a3e1137aa..ecc765484 100644
--- a/demos/AVR/RT-TEENSY2-USB/Makefile
+++ b/demos/AVR/RT-TEENSY2-USB/Makefile
@@ -162,7 +162,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/TEST-SUITE-NIL/Makefile b/demos/AVR/TEST-SUITE-NIL/Makefile
index 2ed10373c..bc8018d01 100644
--- a/demos/AVR/TEST-SUITE-NIL/Makefile
+++ b/demos/AVR/TEST-SUITE-NIL/Makefile
@@ -162,7 +162,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/TEST-SUITE-OSLIB/Makefile b/demos/AVR/TEST-SUITE-OSLIB/Makefile
index 1281a1c61..1966849b3 100644
--- a/demos/AVR/TEST-SUITE-OSLIB/Makefile
+++ b/demos/AVR/TEST-SUITE-OSLIB/Makefile
@@ -162,7 +162,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/demos/AVR/TEST-SUITE-RT/Makefile b/demos/AVR/TEST-SUITE-RT/Makefile
index c28bf3f1a..77174f5b2 100644
--- a/demos/AVR/TEST-SUITE-RT/Makefile
+++ b/demos/AVR/TEST-SUITE-RT/Makefile
@@ -162,7 +162,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/ADC/Makefile b/testhal/AVR/MEGA/ADC/Makefile
index df2169daf..d94121a0c 100644
--- a/testhal/AVR/MEGA/ADC/Makefile
+++ b/testhal/AVR/MEGA/ADC/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/GPT/Makefile b/testhal/AVR/MEGA/GPT/Makefile
index a2b04f709..535e08837 100644
--- a/testhal/AVR/MEGA/GPT/Makefile
+++ b/testhal/AVR/MEGA/GPT/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/I2C/Makefile b/testhal/AVR/MEGA/I2C/Makefile
index a2b04f709..535e08837 100644
--- a/testhal/AVR/MEGA/I2C/Makefile
+++ b/testhal/AVR/MEGA/I2C/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/ICU/Makefile b/testhal/AVR/MEGA/ICU/Makefile
index a2b04f709..535e08837 100644
--- a/testhal/AVR/MEGA/ICU/Makefile
+++ b/testhal/AVR/MEGA/ICU/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/PWM/Makefile b/testhal/AVR/MEGA/PWM/Makefile
index a2b04f709..535e08837 100644
--- a/testhal/AVR/MEGA/PWM/Makefile
+++ b/testhal/AVR/MEGA/PWM/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/MEGA/SPI/Makefile b/testhal/AVR/MEGA/SPI/Makefile
index a2b04f709..535e08837 100644
--- a/testhal/AVR/MEGA/SPI/Makefile
+++ b/testhal/AVR/MEGA/SPI/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/CRC/Makefile b/testhal/AVR/XMEGA/CRC/Makefile
index 9da0c326a..ebbcb92e7 100644
--- a/testhal/AVR/XMEGA/CRC/Makefile
+++ b/testhal/AVR/XMEGA/CRC/Makefile
@@ -162,7 +162,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/CRYPTO/Makefile b/testhal/AVR/XMEGA/CRYPTO/Makefile
index 8d991b118..90c8c05c2 100644
--- a/testhal/AVR/XMEGA/CRYPTO/Makefile
+++ b/testhal/AVR/XMEGA/CRYPTO/Makefile
@@ -161,7 +161,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/SERIAL/Makefile b/testhal/AVR/XMEGA/SERIAL/Makefile
index 8d991b118..90c8c05c2 100644
--- a/testhal/AVR/XMEGA/SERIAL/Makefile
+++ b/testhal/AVR/XMEGA/SERIAL/Makefile
@@ -161,7 +161,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/SPI/Makefile b/testhal/AVR/XMEGA/SPI/Makefile
index 8d991b118..90c8c05c2 100644
--- a/testhal/AVR/XMEGA/SPI/Makefile
+++ b/testhal/AVR/XMEGA/SPI/Makefile
@@ -161,7 +161,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/TEST-SUITE-OSLIB/Makefile b/testhal/AVR/XMEGA/TEST-SUITE-OSLIB/Makefile
index 5205d6135..63cca7670 100644
--- a/testhal/AVR/XMEGA/TEST-SUITE-OSLIB/Makefile
+++ b/testhal/AVR/XMEGA/TEST-SUITE-OSLIB/Makefile
@@ -163,7 +163,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/USART/Makefile b/testhal/AVR/XMEGA/USART/Makefile
index fa04f05b7..94b4481cc 100644
--- a/testhal/AVR/XMEGA/USART/Makefile
+++ b/testhal/AVR/XMEGA/USART/Makefile
@@ -157,7 +157,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/XMEGA/WDT/Makefile b/testhal/AVR/XMEGA/WDT/Makefile
index 16786366b..ccc69f2ae 100644
--- a/testhal/AVR/XMEGA/WDT/Makefile
+++ b/testhal/AVR/XMEGA/WDT/Makefile
@@ -160,7 +160,7 @@ HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/multi/PAL/make/Makefile-arduino_mega.make b/testhal/AVR/multi/PAL/make/Makefile-arduino_mega.make
index 41e9dcf82..ec9d6d239 100644
--- a/testhal/AVR/multi/PAL/make/Makefile-arduino_mega.make
+++ b/testhal/AVR/multi/PAL/make/Makefile-arduino_mega.make
@@ -146,7 +146,7 @@ BIN = $(CP) -O binary
AVRDUDE = avrdude
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/multi/PAL/make/Makefile-arduino_mini.make b/testhal/AVR/multi/PAL/make/Makefile-arduino_mini.make
index 140ce5126..930c86db5 100644
--- a/testhal/AVR/multi/PAL/make/Makefile-arduino_mini.make
+++ b/testhal/AVR/multi/PAL/make/Makefile-arduino_mini.make
@@ -146,7 +146,7 @@ BIN = $(CP) -O binary
AVRDUDE = avrdude
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/multi/PAL/make/Makefile-arduino_nano.make b/testhal/AVR/multi/PAL/make/Makefile-arduino_nano.make
index 9c3893e2a..3e7a42540 100644
--- a/testhal/AVR/multi/PAL/make/Makefile-arduino_nano.make
+++ b/testhal/AVR/multi/PAL/make/Makefile-arduino_nano.make
@@ -145,7 +145,7 @@ BIN = $(CP) -O binary
AVRDUDE = avrdude
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
diff --git a/testhal/AVR/multi/PAL/make/Makefile-arduino_uno.make b/testhal/AVR/multi/PAL/make/Makefile-arduino_uno.make
index 02476b1e5..45557a4b9 100644
--- a/testhal/AVR/multi/PAL/make/Makefile-arduino_uno.make
+++ b/testhal/AVR/multi/PAL/make/Makefile-arduino_uno.make
@@ -146,7 +146,7 @@ BIN = $(CP) -O binary
AVRDUDE = avrdude
# Size of the elf binary file.
-ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
+ELFSIZE = $(SZ) $(BUILDDIR)/$(PROJECT).elf
# MCU specific options here.
MOPT =
--
2.50.1
However, when building for AVR targets, you so get the size of the resulting ELF file displayed twice
Code: Select all
Linking build/ch.elf
Creating build/ch.hex
Creating build/ch.eep
Creating build/ch.bin
Creating build/ch.lss
Creating build/ch.sym
text data bss dec hex filename
6584 0 696 7280 1c70 build/ch.elf
text data bss dec hex filename
6584 0 696 7280 1c70 ./build/ch.elf
Done
This could be fixed with a simple change to the AVR compiler rules, as the rule for %.sym already calls $(SZ) on the resulting elf file.
Code: Select all
From 216f59b871f8e4b8a7e478bea8d8404c1564e739 Mon Sep 17 00:00:00 2001
From: Nathan Lewis <git@nrlewis.dev>
Date: Fri, 22 Aug 2025 19:38:10 -0700
Subject: [PATCH 2/2] AVR: remove duplicate avr-size call
---
os/common/ports/AVR/compilers/GCC/rules.mk | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/os/common/ports/AVR/compilers/GCC/rules.mk b/os/common/ports/AVR/compilers/GCC/rules.mk
index a14bb0e7b..07433c2ab 100644
--- a/os/common/ports/AVR/compilers/GCC/rules.mk
+++ b/os/common/ports/AVR/compilers/GCC/rules.mk
@@ -260,16 +260,13 @@ ifeq ($(USE_VERBOSE_COMPILE),yes)
$(NM) -n $< > $@
$(SZ) $<
@echo
- if test -f $(BUILDDIR)/$(PROJECT).elf; then echo; echo $(MSG_SIZE_AFTER); \
- $(ELFSIZE); 2>/dev/null; echo; fi
@echo Done
else
@echo Creating $@
@$(NM) -n $< > $@
@echo
@$(SZ) $<
- @if test -f $(BUILDDIR)/$(PROJECT).elf; then echo; echo $(MSG_SIZE_AFTER); \
- $(ELFSIZE); 2>/dev/null; echo; fi
+ @echo
@echo Done
endif
--
2.50.1