Skip to content

board: add multi-storage board model with composition - #163

Open
Igor Opaniuk (igoropaniuk) wants to merge 5 commits into
qualcomm-linux:mainfrom
igoropaniuk:feat/board-model
Open

board: add multi-storage board model with composition#163
Igor Opaniuk (igoropaniuk) wants to merge 5 commits into
qualcomm-linux:mainfrom
igoropaniuk:feat/board-model

Conversation

@igoropaniuk

Copy link
Copy Markdown
Contributor

Third step of the partition-source rework [1]: a board file that declares a platform with multiple storages, and the composition layer on top of it.

The per-(board, storage) directory convention cannot say "this board has these two storages", cannot share common partition groups except by copy-paste, and cannot express variants (Debian vs QLI rootfs, boot-firmware versions) at all - adding a variant today means duplicating a directory and editing it by hand.

board.py resolves a board file through three mechanisms, applied in a fixed order: board-level extends: inherits a single base board; storage-level includes: concatenates shared partition fragments; --hlos / --boot-fw overlays apply last.

Merges are deep and field-by-field, matched by stable identifier (storage id, partition name); unmatched entries append in file order, and same-name overrides merge in place so partition order - which determines GPT offsets - stays deterministic. Each resolved storage is validated against the strict schema from [2] and reduced to the same LoadedSpec, so a resolved board emits byte-identical XML to the equivalent hand-written file. gen_partition --board emits one partitions.xml per storage; qcom-ptool show --board prints the fully-resolved layout so reviewers never have to chase the composition chain by hand.

[1] #124
[2] #155

Introduce the board format from [1]: a board declares a platform and a
list of storage devices, each with partitions. board.py resolves the
three composition mechanisms into a ResolvedBoard - board-level
`extends:` (inherit one base board, override by storage id / partition
name), storage-level `includes:` (concatenate shared _common fragments,
transitively), and variant overlays (--hlos / --boot-fw) applied last.

Merges are deep and field-by-field, matched by stable identifier, with
unmatched entries appended in file order; resolution order is base
board -> derived board -> storage includes -> variant overlays. There
is no partition deletion in v1. Cycles in extends or includes are
rejected.

Input files are validated structurally against board.schema.json (and
include.schema.json for fragments), which stay permissive because
overrides are partial. Each fully-resolved storage is then validated
strictly against the existing partitions.schema.json and reduced to a
LoadedSpec through the same normalisation helpers the YAML loader uses,
so a resolved board emits XML byte-identical to an equivalent
hand-written single-storage file.

[1] qualcomm-linux#124

Signed-off-by: Igor Opaniuk <[email protected]>
Pin the composition contract: extends inheritance with field-by-field
overrides and appends, storage includes with transitivity, variant
overlays applied last (overriding an included partition in place and
appending new ones), the deterministic partition ordering, cycle
rejection for both extends and includes, strict validation of the
resolved storage, and a byte-identical-XML check against the equivalent
single-storage YAML.

Signed-off-by: Igor Opaniuk <[email protected]>
Extend the CLI with --board / --hlos / --boot-fw (and --root) so a whole
board resolves and emits one partitions.xml per storage, in declared
order, from a single invocation. Outputs are given as one -o per
storage; a count mismatch is reported with the storage ids. The board
resolver is imported lazily so the legacy -i single-storage path never
pulls in PyYAML or jsonschema, and that path is unchanged.

Signed-off-by: Igor Opaniuk <[email protected]>
Derived boards and heavy includes make the effective layout impossible
to read from one file. `qcom-ptool show --board <f> [--hlos ..]
[--boot-fw ..]` resolves the full composition chain and prints the
result as YAML, so reviewers can see exactly what will be emitted
without chasing extends/includes by hand.

Signed-off-by: Igor Opaniuk <[email protected]>
Assert that --board emits one XML per storage in order, that an output
count mismatch fails, that exactly one source (-i or --board) is
required, that the legacy single-storage path still works, and that
show prints the resolved spec with variant overlays applied.

Signed-off-by: Igor Opaniuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants