Skip to content

Broken -Map flag causes extra firmware map file in root directory #214

Open
@lucasmaziero

Description

@lucasmaziero

PROBLEM DESCRIPTION

After updating to the latest pioarduino/platform-espressif32, PlatformIO started generating a malformed .map file in the project root, with a name like:

DesktopBlink.piobuildesp32devfirmware.map

This happens on Windows and seems to be caused by a corrupted -Wl,-Map=... linker flag, where the full path is being passed without proper escaping or quotes, resulting in the entire path being interpreted as the filename.

This issue did not happen before the platform update and appears to be introduced by a recent change.


EXPECTED BEHAVIOR

Only a correctly named .map file should be generated in the build directory:

.pio/build/esp32dev/firmware.map

ACTUAL BEHAVIOR

An additional .map file is created in the root of the project, with a malformed name that concatenates the full path, missing all slashes.


SYSTEM INFO

  • OS: Windows 11
  • PlatformIO Core: 6.1.18
  • platform-espressif32: using platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21/platform-espressif32.zip
  • Board: esp32dev

TEMPORARY FIX

To prevent this behavior, I added the following extra_script to my project:

# scripts/fix_map_flag.py
Import("env")
env.ProcessUnFlags(["-Wl,-Map"])
env.Append(LINKFLAGS=["-Wl,-Map=.pio/build/%s/firmware.map" % env["PIOENV"]])

And included it in platformio.ini:

extra_scripts = scripts/fix_map_flag.py

After this, the unwanted .map file no longer appears in the project root.


SUGGESTED FIX

Please check how the -Map linker flag is being generated on Windows. It seems the path is not being properly escaped or normalized. A fix might involve wrapping it in quotes or using os.path.normpath() during path construction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions