platformIO 在构建时不显示二进制大小

问题描述

我正在使用带有 PlatformIO 的 VsCode 和一个非常简单的程序。 它可以正确编译并生成有效的 elf 和 hex 文件

但是,除非 pio 声明它检查大小,否则它不会输出任何内容

我的配置如下

[env:release]
platform = atmelavr
board_build.mcu = atmega168A
board_build.f_cpu = 8000000L

运行构建它只是输出

Processing release (platform: atmelavr)
----------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v,--verbose` option
HARDWARE: ATMEGA168A 8MHz,PACKAGES: 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> [had to replace link to being allowed to post]
LDF Modes: Finder ~ chain,Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\release\src\HMI.o
Compiling .pio\build\release\src\Oled.o
Compiling .pio\build\release\src\Segment.o
Compiling .pio\build\release\src\main.o
Linking .pio\build\release\firmware.elf
Checking size .pio\build\release\firmware.elf
Building .pio\build\release\firmware.hex
=========================================================== [SUCCESS] Took 1.95 seconds ===========================================================


即使使用 -v 运行它,它也不会显示更多信息

Processing release (platform: atmelavr; board_build.mcu: atmega168A; board_build.f_cpu: 8000000L)
----------------------------------------------------------------------------------------------------------------------------------------------------HARDWARE: ATMEGA168A 8MHz,Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
avr-gcc -o .pio\build\release\src\HMI.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_cpu=8000000L -dplATFORMIO=50101 -Isrc src\HMI.c
avr-gcc -o .pio\build\release\src\Oled.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_cpu=8000000L -dplATFORMIO=50101 -Isrc src\Oled.c
avr-gcc -o .pio\build\release\src\Segment.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A 
-DF_cpu=8000000L -dplATFORMIO=50101 -Isrc src\Segment.c
avr-gcc -o .pio\build\release\src\main.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_cpu=8000000L -dplATFORMIO=50101 -Isrc src\main.c
avr-gcc -o .pio\build\release\firmware.elf -Os -mmcu=atmega168A -Wl,--gc-sections -flto -fuse-linker-plugin .pio\build\release\src\HMI.o .pio\build\release\src\Oled.o .pio\build\release\src\Segment.o .pio\build\release\src\main.o -L.pio\build\release -Wl,--start-group -lm -Wl,--end-group        
MethodWrapper(["checkprogsize"],[".pio\build\release\firmware.elf"])
avr-objcopy -O ihex -R .eeprom .pio\build\release\firmware.elf .pio\build\release\firmware.hex
=========================================================== [SUCCESS] Took 1.77 seconds ===========================================================

我正在使用

  • PIO 扩展 v2.3.2
  • PIO 核心 5.1.1·首页 3.3.4
  • 平台 atmelavr 3.3.0

从下载的包中手动调用 avr-size 正确显示信息。

有什么建议可以解决这个问题吗?

解决方法

向配置中添加显式 board 配置项似乎可以解决该问题。

[env:release]
platform = atmelavr
board = ATmega168
board_build.mcu = atmega168A
board_build.f_cpu = 8000000L