Getting Arduino AVR Disassembly with Platformio

You can get a cpp-source-interleaved disassembly listing, when compiling for Arduino AVR under Platformio.

You add these to platformio.ini:

build_flags =
    -save-temps=obj
    -fverbose-asm

Build_type = debug

Then get the c source interleaved disassembly with:

avr-objdump -S firmware.elf > disassembly.txt

A sample of the disassembly output:

...

void loop() 
{
  // Read adc and save result in read-only slave register 1
  i2c_registers[I2C_REG_1] = myadc_read();
     cc2:	0e 94 46 06 	call	0xc8c	; 0xc8c <_Z10myadc_readv>
     cc6:	90 93 21 01 	sts	0x0121, r25	; 0x800121 <i2c_registers+0x3>
     cca:	80 93 20 01 	sts	0x0120, r24	; 0x800120 <i2c_registers+0x2>

  // Spin for 100ms
  delay(100);
     cce:	64 e6       	ldi	r22, 0x64	; 100
     cd0:	70 e0       	ldi	r23, 0x00	; 0
     cd2:	80 e0       	ldi	r24, 0x00	; 0
     cd4:	90 e0       	ldi	r25, 0x00	; 0
     cd6:	0e 94 b5 03 	call	0x76a	; 0x76a <delay>
     cda:	08 95       	ret

...