PlatformIO Community

Avr-objdump.exe -h -S firmware.elf doesn't contain source statements

How can I get platformIO to create an AVR output file like the arduino IDE?

Dumping the .elf file compiled with the arduino IDE gives me assembly code including the source statements which makes the output very usefully readable to me as shown in the example below:

void setup()
{ if( TEST ) 
  { pinMode( ledPin, OUTPUT ) ; 
     a28:	61 e0       	ldi	r22, 0x01	; 1
     a2a:	8d e0       	ldi	r24, 0x0D	; 13
     a2c:	0e 94 f7 01 	call	0x3ee	; 0x3ee <pinMode>
    digitalWrite( ledPin, LOW ) ; 
     a30:	60 e0       	ldi	r22, 0x00	; 0
     a32:	8d e0       	ldi	r24, 0x0D	; 13
     a34:	0e 94 c9 01 	call	0x392	; 0x392 <digitalWrite>

The same dumped from the .elf file from a platformIO compile gives assembly code but without the source statements.

a4e:       61 e0           ldi     r22, 0x01       ; 1
a50:       8d e0           ldi     r24, 0x0D       ; 13
a52:       0e 94 e4 00     call    0x1c8   ; 0x1c8 <pinMode>
a56:       60 e0           ldi     r22, 0x00       ; 0
a58:       8d e0           ldi     r24, 0x0D       ; 13
a5a:       0e 94 b5 00     call    0x16a   ; 0x16a <digitalWrite>

I already added the -g build option to platformio.ini but that did not do it.

1 Like

When you activate verbose output for compilation in the Arduino IDE settings, what avr-g++ etc commands and switches is it using?

Below is the compiler output of a simple sketch:

const uint8_t ledPin = 13 ;
void setup()
{ pinMode(      ledPin, OUTPUT ) ; 
  digitalWrite( ledPin, LOW ) ; 
}
void loop() { }

It is quite lengthy and beyond my understanding :frowning:

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\PeterK\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\PeterK\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries D:\Peter\Development\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10810 -build-path T:\TMP\arduino_build_626698 -warnings=default -build-cache T:\TMP\arduino_cache_513773 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose T:\TMP\untitled454085958.tmp\sketch_mar10a\sketch_mar10a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\PeterK\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\PeterK\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries D:\Peter\Development\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10810 -build-path T:\TMP\arduino_build_626698 -warnings=default -build-cache T:\TMP\arduino_cache_513773 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.arduinoOTA.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.3.0 -verbose T:\TMP\untitled454085958.tmp\sketch_mar10a\sketch_mar10a.ino
Using board 'nano' from platform in folder: C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2
Using core 'arduino' from platform in folder: C:\Users\PeterK\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2
Detecting libraries used...
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino" "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\eightanaloginputs" "T:\\TMP\\arduino_build_626698\\sketch\\sketch_mar10a.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino" "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\eightanaloginputs" "T:\\TMP\\arduino_build_626698\\sketch\\sketch_mar10a.ino.cpp" -o "T:\\TMP\\arduino_build_626698\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "T:\\TMP\\arduino_build_626698\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino" "-IC:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\eightanaloginputs" "T:\\TMP\\arduino_build_626698\\sketch\\sketch_mar10a.ino.cpp" -o "T:\\TMP\\arduino_build_626698\\sketch\\sketch_mar10a.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: T:\TMP\arduino_cache_513773\core\core_arduino_avr_nano_cpu_atmega328_3a2fa074a66e1d4e0c0e232b18b70324.a
Linking everything together...
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-gcc" -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.elf" "T:\\TMP\\arduino_build_626698\\sketch\\sketch_mar10a.ino.cpp.o" "T:\\TMP\\arduino_build_626698/..\\arduino_cache_513773\\core\\core_arduino_avr_nano_cpu_atmega328_3a2fa074a66e1d4e0c0e232b18b70324.a" "-LT:\\TMP\\arduino_build_626698" -lm
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.elf" "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.eep"
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-objcopy" -O ihex -R .eeprom "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.elf" "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.hex"
"C:\\Users\\PeterK\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-size" -A "T:\\TMP\\arduino_build_626698/sketch_mar10a.ino.elf"
Sketch uses 714 bytes (2%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.