PlatformIO: Creating a list file after Building automatically.


Well-known member
All PlatformIO users:
This trick will save you a lot of typing when you get an address from the output of the crashReport.

Here is the method I use to generate a list file (.lst) in the same build folder as all the other files that the Compiler generates.

In your Platformio.ini file insert these lines:
extra_scripts =

Then place in your main window some where close to the platformio.ini file this file:
View attachment
Please remove the .pdf from the end of the attached file before you place it in your main window.

The next time your build your project the list file will be in the build folder with all the other files generated by the build system.

Make sure you do not use spaces in the file name of the project or any other file in your source code as this will cause the to issue errors as the objdump program does not like spaces in the file name.

For convenience, here's the contents of that file:

print("Current CLI targets", COMMAND_LINE_TARGETS)
print("Current Build targets", BUILD_TARGETS)

def post_program_action(source, target, env):
    print("Program has been built!")
    program_path = target[0].get_abspath()
    print("Program path", program_path)
    # Use case: sign a firmware, do any manipulations with ELF, etc
    # env.Execute(f"sign --elf {program_path}")

env.AddPostAction("$PROGPATH", post_program_action)

# Custom HEX from ELF
    env.VerboseAction(" ".join([
        "$arm-none-eabi-objdump", "-m arm", "-d", "-S", "--demangle", "-w",
        "$BUILD_DIR/${PROGNAME}.elf", ">", "$BUILD_DIR/${PROGNAME}.lst"
    ]), "Building $BUILD_DIR/${PROGNAME}.lst")