cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Board Support in meta-st U-Boot Recipe (STM32MP13)

tsmart
Visitor

Summary
I'm attempting to add support for a custom STM32MP135-based board (M5Stack CoreMP135) to Yocto using meta-st layers, but the u-boot-stm32mp recipe appears to enforce rigid constraints that prevent using custom defconfigs and device trees.

Environment
- **Yocto Version**: Kirkstone
- **meta-st Version**: OpenSTLinux 5.0 (Kirkstone)
- **Target Board**: M5Stack CoreMP135 (STM32MP135DAE7, 512MB RAM)
- **U-Boot Version**: v2022.10-stm32mp-r2
- **Reference**: M5Stack successfully builds this board with Buildroot using custom defconfig

Problem Description

What Works in Buildroot
M5Stack's Buildroot configuration successfully builds U-Boot for the custom board using:
```
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="coremp135"
BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_ST_PATH)/board/m5stack/coremp135/uboot-dts/*"
BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="dtb-y=stm32mp135f-coremp135.dtb DEVICE_TREE=stm32mp135f-coremp135"
```

Attempts in Yocto (All Failed)

Attempt 1: Using UBOOT_MACHINE Override
**Machine config:**
```bitbake
UBOOT_CONFIG = "default_stm32mp13"
```

**Bbappend:**
```bitbake
UBOOT_MACHINE:stm32mp135f-coremp135 = "stm32mp135f_coremp135_defconfig"
```

**Result:**
```
ERROR: You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.
```

Attempt 2: Replacing stm32mp13_defconfig
**Strategy:** Replace ST's `stm32mp13_defconfig` with custom board defconfig in `do_configure:prepend()`

**Bbappend:**
```bitbake
SRC_URI += "file://stm32mp13_defconfig"

do_configure:prepend() {
install -m 0644 ${WORKDIR}/stm32mp13_defconfig ${S}/configs/stm32mp13_defconfig
}
```

**Custom defconfig includes:**
```
CONFIG_DEFAULT_DEVICE_TREE="stm32mp135f-coremp135"
CONFIG_TFABOOT=y
CONFIG_SYS_LOAD_ADDR=0xc2000000
... (145 lines total, includes all required configs)
```

**Result:**
```
fatal error: configs/.h: No such file or directory
include <configs/.h>
```

The defconfig is copied to `${S}/configs/` successfully (verified), but U-Boot's configuration system doesn't recognize it. The empty header name suggests the defconfig isn't being loaded at all.

Attempt 3: Custom UBOOT_CONFIG Key
**Machine config:**
```bitbake
UBOOT_CONFIG = "coremp135"
UBOOT_CONFIG[coremp135] = "stm32mp135f_coremp135_defconfig,,u-boot.dtb"
```

**Result:**
```
ERROR: The selected UBOOT_CONFIG key coremp135 has no match in UBOOT_DEVICETREE keys
```

The recipe has hardcoded UBOOT_CONFIG keys in `u-boot-stm32mp-config.inc` and doesn't allow custom keys.

Analysis

The `u-boot-stm32mp` recipe in meta-st appears to:

1. **Hardcode defconfig selection** based on UBOOT_CONFIG key (e.g., `default_stm32mp13` → `stm32mp13_defconfig`)
2. **Ignore UBOOT_CONFIG[key] overrides** - the defconfig name is embedded in recipe logic
3. **Require UBOOT_CONFIG** to be set - UBOOT_MACHINE alone triggers error
4. **Not support custom UBOOT_CONFIG keys** - only predefined keys in `u-boot-stm32mp-config.inc` work

This differs significantly from standard Yocto U-Boot recipes (meta/recipes-bsp/u-boot/) which allow:
- Custom defconfigs via UBOOT_MACHINE
- Flexible UBOOT_CONFIG definitions
- Easy board-specific overrides

Questions

1. **Is there an officially supported way to add custom board support to meta-st's U-Boot recipe?**

2. **Why does replacing the defconfig file in `do_configure:prepend()` not work?** The file is successfully copied to `${S}/configs/`, but the build fails with `configs/.h` error.

3. **Is the restriction against UBOOT_MACHINE intentional?** If so, what's the reasoning?

4. **Would the community accept patches to make meta-st U-Boot recipe more flexible** for custom boards, similar to standard Yocto U-Boot recipes?

Workarounds Considered

1. **Use ST's DK board device tree** - Not ideal as hardware differs
2. **Build U-Boot manually** outside Yocto - Defeats purpose of Yocto integration
3. **Fork and modify meta-st** - Would prefer upstream solution

Additional Context

- **TF-A and OP-TEE** build successfully with custom board using similar approach (custom device trees in bbappends)
- Same hardware boots fine with M5Stack's Buildroot setup
- Device tree files are from M5Stack's working Buildroot implementation

Request

Guidance on the proper way to support custom STM32MP13 boards in Yocto, or confirmation that this requires recipe modifications to meta-st.

Any help would be greatly appreciated!

---

**Files available upon request:**
- Custom machine config
- U-Boot bbappend
- Custom defconfig (stm32mp135f_coremp135_defconfig)
- Custom device trees (stm32mp135f-coremp135.dts, .dtsi)

0 REPLIES 0