Skip to content

"Upload FileSystem Image" use unexpected port #1582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anguis-datura opened this issue May 16, 2025 · 1 comment · May be fixed by #1588
Open

"Upload FileSystem Image" use unexpected port #1582

anguis-datura opened this issue May 16, 2025 · 1 comment · May be fixed by #1588

Comments

@anguis-datura
Copy link

I have two ESP32 connected, two ports COM26, COM49 are available to upload. Next I change "auto" selecting port to COM49 for instance, but when I hit "upload file system image" I see that auto scan had happen, and unexpected port was used to upload. Following screen show that:
Image

I expect then if I do specify port explicitly it shopuld be used to "upload filesystem image", similar to just "upload" command.
Thanks in advance.

@ivankravets ivankravets transferred this issue from platformio/platformio-core May 17, 2025
@Jason2866
Copy link
Contributor

Jason2866 commented May 17, 2025

This pre Pio script will populate the VSC port setting to Platformio (read from VSC database)

env = DefaultEnvironment()

import os

if os.environ.get("PLATFORMIO_CALLER") == "vscode":
    print("PIO called from VS Code extension")
    import platform
    import sqlite3
    import json
    from platformio.project.helpers import get_project_dir

    os_name = platform.system()
    print("OS Platform:", os_name)
    os_paths = {
        "Darwin": "~/Library/Application Support/Code/User/globalStorage/state.vscdb",
        "Linux": "~/.config/Code/User/globalStorage/state.vscdb",
        "Windows": r"%APPDATA%\Code\User\globalStorage\state.vscdb"
    }
    project_path = get_project_dir()

    try:
        db_path = os.path.expanduser(os.path.expandvars(os_paths[os_name]))
    except KeyError:
        raise RuntimeError("Unknown OS: " + os_name)

    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()

    for key in ['pioarduino.pioarduino-ide', 'platformio.platformio-ide']:
        cursor.execute("SELECT value FROM ItemTable WHERE key = ?", (key,))
        row = cursor.fetchone()
        if row:
            data = json.loads(row[0])
            projects = data.get("projects", {})
            project = projects.get(project_path)
            if project and "customPort" in project:
                print("USB port set in VSC:", project["customPort"])
                env["UPLOAD_PORT"] = project["customPort"]
                break
    conn.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants