Skip to content

Hardware Model v2 - Ability to extend an existing board #69548

@tejlmand

Description

@tejlmand

Hardware Model v2, #51831 introduces a new scheme for boards.

A board.yml is used to describe meta data of the board, for example:

board:
  name: plank
  vendor: Zephyr
  socs:
  - name: soc1
    variants:
    - name: foo

Such a board allows users to build for:

cmake -DBOARD=plank/soc1
cmake -DBOARD=plank/soc1/foo

The enhancement proposal is to allow extending such a board in another folder.

This would allow out-of-tree users to re-use an existing board but extend it with an extra build variant.
A benefit is that it allows existing overlay's and config files to still be picked up for the new variant, but not having to change the core build variant.

One limitation of https://docs.zephyrproject.org/latest/hardware/porting/board_porting.html#board-extensions is the fact that once such an enhancement is added, it's not possible to build without the extension.

The enhancement issue provides the ability to extend the board with new variant, thus having the following benefit:

Design idea:
Extend the board.yml with a new extend: <name> field, indicating the board which is being extended.
This will tell list_boards.py that this is not a new board, but a board which should be merged with the existing board definition.

board:
  extend: plank
  variants:
  - name: bar
    soc: soc1

This defines a new bar board variant which applies to an existing soc soc1 definition in the plank board.

Another use-case is to allow boards to be defined in a tree of sub-folders.

An example of such use-case are the qemu boards.
Those are individually defined in their own folder, thus they must each have a unique name, thus ending in situations like this:

-DBOARD=qemu_arc/qemu_arc_em
-DBOARD=qemu_nios2/qemu_nios2

where the arch is repeated for no apparent reason.

Supporting board extensibility will allow to keep qemu boards organized in sub-folders while at the same time present just a highlevel qemu board.

This will also make it easier to see all architectures supported with qemu, as those can now be listed as identifiers for the common board.

Design idea:

Highlevel qemu board:

# board.yml for qemu, no SoCs defined.
board:
  name: qemu

Extend the qemu board with SoCs:

# board.yml for qemu, no SoCs defined.
board:
  extends: qemu
  socs:
  - name: arc_em
  - name: arc_hs
    variants:
    - name: xip
  - name: arc_hs5x
  - name: arc_hs6x

and

board:
  extends: qemu
  socs:
  - name: nios2

Thus making it possible to build for:

-DBOARD=qemu/arc_em
-DBOARD=qemu/nios2

Note the difference between extending a board with a new SoC, and then extending the board with a variant related to a SoC defined in the core board definition.

Challenges:

  • BOARD_DIR is not as uniform, which means Kconfig.<board>, Kconfig, and Kconfig.defconfig must be allowed to be sourced from multiple locations.

As part of this implementation, please also address: #70619 (comment)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions