How can I get assembly code out of a .ino file?

I'd like to compile my .ino sketch into assembly code, so that I can see what's going on a the machine level --- something like "gcc -S ...". How can I do this?

I'm using the Arduino IDE, I also have the linux Arduino command-line tools installed.

Search the forum here I asked that question and got an answer but I seem to have lost the link…
\ 8) 8)

Use avr-objdump

You can use this method but only on the 1.5x IDE and only if you are using linux.
Sorry, Windows is too wimpy and doesn’t come with the tools that linux has.
Actually, it could be made to also work on Windows using a batch script wrapper
that sets up the PATH environment and then uses the sh/bash shell tool that
comes with the WINAVR tools that the Windows IDE comes with to call the same
shell script, but it wasn’t a priority for me since I don’t use Windows.

It will create a listing file and a symbol table file every time you do a build
from the IDE.
Once you set it up, it “just happens”.
It will echo out to the console window where the files are and you can go look at them.

The listing file will be not just your sketch but everything that was linked into the image
and it will have intermixed C code to make it easier to find and examine the assembler.

Instructions are in the attached script but here is a summary:

Here is what you need to do.
In your 1.5x install tree edit the platform.txt file for the AVR processor.
It will be
{installdir}/hardware/avr/platform.txt

Change this:

## Create hex
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

to this:

## Create hex
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

## Bills objcopy wrapper
recipe.objcopy.hex.pattern="{compiler.path}../../avr-objcopy-wrapper.sh" "{compiler.path}{compiler.elf2hex.cmd}" "{compiler.elf2hex.flags}" "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

Then install the shell script attached in:

{installdir}/hardware/tools

— bill

avr-objcopy-wrapper.zip (793 Bytes)

Thanks bill,
Your script worked for me, although the listing and symbol table actually ended up in the /tmp directory. I appreciate it.

Are you saying it ended in /tmp or some other directory down under /tmp?
It should be down in some directory under /tmp

The IDE creates a working directory down in /tmp and uses that area for all its immediate files
so that is where I placed the output files.
Since the directory used changes for each instance of the IDE, that is
why I printed it from the script.

You could install and use UECIDE instead of the Arduino IDE, which has an option in its preferences to generate a .lss file and optionally copy it into the sketch folder. The latest beta version also allows you to inspect it within the editor as well.

Are you saying it ended in /tmp or some other directory down under /tmp?
It should be down in some directory under /tmp

Yes, /tmp/buildLONGNUMBER.tmp/ holds the .lss, .sym, and some other files.

Use avr-objdump

This kind of works, but I have to figure out which file to dump....

You could install and use UECIDE instead of the Arduino IDE, which has an option in its preferences to generate a .lss file and optionally copy it into the sketch folder. The latest beta version also allows you to inspect it within the editor as well.

I've installed this, but haven't tried/figured it out yet. Still to come.