esphome / esphome/feature-requests
Custom board file support
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
Sometimes the predefined board options are not suitable and some parameters need to be changed. Platformio allows the use of custom board files (see: https://docs.platformio.org/en/latest/platforms/creating_board.html).
esphome does not support custom board files, but I have done some testing and I can get it working quite easily. esphome warns if the board is unknown with the message `This board is unknown, please set the variant manually` (see: [components/esp32/__init__.py#L280](https://github.com/esphome/esphome/blob/b20bae23ccac3903239ca68bfb3a4add25b7b44d/esphome/components/esp32/__init__.py#L280))
My suggestion is to check if the board exists, and if it doesn't then check the variant is configured and that a custom board file can be found, then copy that file to the build directory...
I have written the following code for the `esp32` platform which does everything required to get the board file to the build directory.
This should be placed here: [components/esp32/__init__.py#L526](https://github.com/esphome/esphome/blob/b20bae23ccac3903239ca68bfb3a4add25b7b44d/esphome/components/esp32/__init__.py#L526)
```python
board = CORE.data[KEY_ESP32][CONF_BOARD]
if CORE.data[KEY_ESP32][CONF_VARIANT] and board not in BOARDS:
board_path = Path(f"boards/{board}.json")
if board_path.is_file():
_LOGGER.info(
f"Loading custom board file: boards/{board}.json"
)
copy_file_if_changed(
CORE.relative_config_path(f"boards/{board}.json"),
CORE.relative_build_path(f"boards/{board}.json"),
)
# else:
# raise cv.Invalid(
# f"This board is unknown, please add a custom board file in the 'boards' folder: 'boards/{board}.json'",
# path=[CONF_BOARD],
# )
```
**Please describe your use case for this integration and alternatives you've tried:**
I would like to configure options like the `maximum_ram_size` but it is not possible with the current configuration options e.g.
```yaml
platformio_options:
# like this..
upload_flags: maximum_ram_size=532480
# or this..
upload_flags.maximum_ram_size: 532480
```
**Additional context**
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in components/esp32/__init__.py at the cited board-handling sections, then read the ESPHome ESP32 configuration flow and PlatformIO's custom board file documentation. Done means an unknown board with a configured variant can use boards/{board}.json and the file is copied into the build directory, while the existing unknown-board warning remains appropriate when no custom file is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, embedded-iot
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100