esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

PSRAM missing memory_type support with arduino framework #5264

Open Nerivec opened 7 months ago

Nerivec commented 7 months ago

The problem

Unless I'm mistaken, the arduino framework is missing support for memory_type in the PSRAM component, which ends up in boot loops if the board_build.arduino.memory_type config is not provided on top of the psram component for octal boards. I would expect to see something similar to how CONF_MODE is changing config for esp-idf.

https://github.com/esphome/esphome/blob/dev/esphome/components/psram/__init__.py#L40

The flag alone doesn't seem to be enough however, as I then had to move away from version: recommended too, which required additional fixes of its own (see link at the bottom)...

Which version of ESPHome has the issue?

2023.12.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.12.3

What platform are you using?

ESP32

Board

esp32-s3-devkitc-1 esp32-s3-wroom-1-n16r8

Component causing the issue

psram

Example YAML snippet

esphome:
  platformio_options:
    # missing in psram component for "arduino"
    board_build.arduino.memory_type: qio_opi

esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: arduino

psram:
  mode: octal
  speed: 80MHz

Anything in the logs that might be useful for us?

No response

Additional information

Nerivec commented 6 months ago

I barely scratched the surface on the codebase for esphome/platformio/espressif, but it seems the best way to implement this would be a new config for esp32 (to remove old style conf, same as was done with flash_size). With the appropriate changes to remove & prevent platformio_options > board_build.boot and take the new one into account. And then the psram component could lookup the value to build memory_type accordingly (same as seems to be done throughout platformio/espressif codebase).

Quick code refs ```yaml esp32: board: esp32-s3-devkitc-1 variant: esp32s3 flash_size: 16MB boot: qio framework: type: arduino ``` `esphome/components/esp32/const.py` ```python KEY_BOOT = "boot" ``` `esphome/components/psram/__init__.py` ```python ARDUINO_PSRAM_TYPES = { "quad": "qspi", "octal": "opi", } ARDUINO_PSRAM_TYPE_FALLBACK = ARDUINO_PSRAM_TYPES["quad"] ``` ```python if CORE.using_arduino: cg.add_build_flag("-DBOARD_HAS_PSRAM") boot = CORE.data[KEY_ESP32][KEY_BOOT] psram_type = ARDUINO_PSRAM_TYPES[config[CONF_MODE]] if CONF_MODE in config else ARDUINO_PSRAM_TYPE_FALLBACK cg.add_platformio_option("board_build.arduino.memory_type", f"{boot}_{psram_type}") ```

I don't know esphome's codebase enough (yet) to create a full PR on this, but I thought I'd give my 2 cents on a starting point... I couldn't find a definitive list for memory_type supported values (the config itself is barely mentioned...), but these seem to be in it:

- dio_qspi
- dio_opi
- qio_qspi
- qio_opi
- opi_qspi
- opi_opi

First one is "default" according to https://github.com/platformio/platform-espressif32/blob/master/builder/main.py#L47, although here they use build.flash_mode to build it, contrary to link at the top, which would introduce dout & qout...

Bit of a mess... Will need someone with far more knowledge about the whole stack than me!

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Nerivec commented 1 week ago

ping