Skip to content

Platformio build script: H2 image/flash frequency not correctly set #9237

Closed
@Jason2866

Description

@Jason2866

Board

every H2 board

Device Description

H2 devkit

Hardware Configuration

not relevant

Version

latest master (checkout manually)

IDE Name

Platformio (custom self build)

Operating System

MacOS Ventura

Flash frequency

64 Mhz

PSRAM enabled

no

Upload speed

115200

Description

The current Platformio build script does not taking care of the need of different Flash speed and Image frequency for the H2. In this line https://github.com/espressif/arduino-esp32/blob/master/tools/platformio-build.py#L105
the Flash frequency (64Mhz) is used, this is wrong since it needs to be here the Image frequency of 48 Mhz. The needed change is from "--flash_freq", "${__get_board_f_flash(__env__)}", to "--flash_freq", "${__get_board_ f_image(__env__)}",
AND in the Platformio Platform espressif32 in file main.py the setting of board_f_image from the boards.json needs to be done. Something like this

def _normalize_frequency(frequency):
    frequency = str(frequency).replace("L", "")
    return str(int(int(frequency) / 1000000)) + "m"


def _get_board_f_flash(env):
    frequency = env.subst("$BOARD_F_FLASH")
    return _normalize_frequency(frequency)


def _get_board_f_image(env):
    board_config = env.BoardConfig()
    if "build.f_image" in board_config:
        return _normalize_frequency(board_config.get("build.f_image"))

    return _get_board_f_flash(env)

Without this changes compile and flash of the esp32-h2 will not be possible with Platformio

The current Platformio implementation differs from the working ArduinoIDE build recipe
https://github.com/espressif/arduino-esp32/blob/master/platform.txt#L159

Fixed with:

Sketch

https://github.com/Jason2866/platform-espressif32/tree/Arduino_300_org/examples/arduino-blink

Debug Message

https://github.com/Jason2866/platform-espressif32/actions/runs/7888713841/job/21526852061

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions