How to create a .lst file using objdump during the build process

Anyone know how to create a .lst (Assembly) file from a .elf file during the build process in PlatformIO?

Regards,
Fred

You invoke objdump of the toolchain with the -d option followed by the path to the produced elf file. That’s one post action script away.

1 Like

What is the proper structure of the path to the .elf file?
Thanks,
Fred

See the last few lines of the example code

# Custom HEX from ELF
env.AddPostAction(
    "$BUILD_DIR/${PROGNAME}.elf",
    env.VerboseAction(" ".join([
        "$OBJCOPY", "-O", "ihex", "-R", ".eeprom",
        "$BUILD_DIR/${PROGNAME}.elf", "$BUILD_DIR/${PROGNAME}.hex"
    ]), "Building $BUILD_DIR/${PROGNAME}.hex")
)

Just need to replace $OBJCOPY with e.g. arm-none-eabi-objdump and the arguments with just -d `.

1 Like

Max:
Thanks, for your answer, but how do I execute this file automatically from my built?
Is this a separate file in my build somewhere?
Sorry for my lack of knowledge about the inner workings of PIO.

Thanks,
Fred

@sbfreddie

Add to platformio.ini:

extra_scripts = post:lst.py

In the same directory as plaformio.ini, put a script lst.py containing something like:

#! /usr/bin/python3

Import("env")

env.AddPostAction(
    "$BUILD_DIR/${PROGNAME}.elf",
    env.VerboseAction(" ".join([
        "arm-none-eabi-objdump", "-d", "-S",
        "$BUILD_DIR/${PROGNAME}.elf", ">", "$BUILD_DIR/${PROGNAME}.lst"
    ]), "Building $BUILD_DIR/${PROGNAME}.lst")
    )

You’ll find the .lst file in the same directory (.pio/build/etc.) as the .elf and .hex files.