Generate a .map file

can platformio generate a .map file ?
Ty :smiley:

Dthat is dependant on the compiler you are wanting to use with it. For the gcc variants, just pass the appropriate arguments in the build_flags section. :slight_smile:

2 Likes

Thank you it’s work !!

Glad to be of some help. :slight_smile:

Advice please. What is the right arguments to generate map file? I’ve made many attemps but without succes.

What were your attempts?

As I wrote. I’d like to generate map file as linking result. So I tried to pass the arguments in the build_flags section, like “build_flags = -Wl,-map”, but without succes. I cannot find the right argument and syntax.

See here,

You also have to specify the name of the map file in the build flags arguments.

Running it with -Wl,-Map,output.map gave me the output map file for avr-gcc and arm-elf-gcc.

Maybe thats what you were missing. :slight_smile:

Hope this helps!!

The exact text is
build_flags = -Wl,-Map,output.map

Thank you, it works! :slight_smile:

I tried to generate a MAP file, but in my case, unfortunately, it does not work.
I use exactly the same build flags as pointed above, but I cannot trace any MAP file in “.pioenvs[my_env]” folder.
The ELF file is there, but no MAP file.
Also, no MAP file generation lines within the build messages.
What am I doing wrong? Where to look for this file?

A little more information please. The above method only works for GCC. Can you post your platformio.INI file please

Hi Krishna,
my INI file has following information:

platform = ststm32
board = genericSTM32F407VE
framework = arduino

I use GCC.
I can see in the build window of ATOM the verbose messages.
The compiling messages are there, but not the linker verbose message:

Archiving .pioenvs\genericSTM32F407VE\libFrameworkArduino.a Linking .pioenvs\genericSTM32F407VE\firmware.elf Calculating size .pioenvs\genericSTM32F407VE\firmware.elf Building .pioenvs\genericSTM32F407VE\firmware.bin text data bss dec hex filename 16712 6392 6064 29168 71f0 .pioenvs\genericSTM32F407VE\firmware.elf [SUCCESS] Took 9.62 seconds

As you can see, just a short line about invoking the linker, but no detailed linker verbose message, so that I cannot see the linker parameters…
And no trace of a MAP file…

After trying to add the needed arguments to the INI files without success, I finally added the MAP generation parameter to the .platformio\platforms\ststm32\builder\main.py

    LINKFLAGS=[
        "-Os",
        "-Wl,--gc-sections,--relax",
        "-Wl,-Map,output.map"
        "-mthumb",
        "-nostartfiles",
        "-nostdlib"
    ],

but still no success.

You should add the flags for map generation to your platformio.ini file under the build_flags section. Please see the above post for more information.

I did try it, but it did not work, see my previous post, where I mentioned this already:

Any thoughts?

There is something wrong!
I tried it again after cleaning the project, and the .map file generated just fine.

I added this to the platformio.ini file.

build_flags = -Wl,-Map,output.map

Where is the MAP file going to be placed?

In the root of the project folder. Atleast thats where my map file was generated.

All right, that was it. I was looking for it in the wrong folder, where the ELF file was placed.
But I can now confirm: it works!
Thanks a lot!

You are welcome! :slight_smile:
Glad to be some help!!!

Btw, just for info, it also works when included into

line 57. In the posted version I had an error, a comma was missing from the line end.

Maybe Ivan would consider to include it to the official version.