Skip to content

pylibfdt: expose address cells, size cells and memory reservation add/delete accessors - #190

Closed
alchark wants to merge 2 commits into
dgibson:mainfrom
flipperdevices:pylibfdt-address-cells-mem-rsv
Closed

pylibfdt: expose address cells, size cells and memory reservation add/delete accessors#190
alchark wants to merge 2 commits into
dgibson:mainfrom
flipperdevices:pylibfdt-address-cells-mem-rsv

Conversation

@alchark

@alchark alchark commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Currently the access to address-cells/size cells requires poking into the FdtRo._fdt private buffer. Similarly, adding or deleting memory reservations requires poking into the Fdt._fdt private buffer.

This complicates things such as inserting a /chosen node with a pre-set kernel command line and initrd location/size properties into an existing device tree (as is required for preparing a device tree blob for booting with no runtime patching by a bootloader, e.g. using U-Boot's Falcon mode), so add public accessors for these.

alchark added 2 commits August 6, 2026 13:30
Finding out how many cells a node's children use for addresses and sizes
currently requires calling the raw fdt_address_cells()/fdt_size_cells()
wrappers with the private FdtRo._fdt buffer, as the class exposes no
methods for them.

Add them to FdtRo alongside the other node accessors, and test them.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
The memory reserve map can be read through num_mem_rsv() and
get_mem_rsv(), but changing it requires calling the raw fdt_* wrappers
with the private Fdt._fdt buffer, as the class exposes no methods for
the write side.

Add them next to the existing accessors, and test them.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
@dgibson

dgibson commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Merged, thanks (it will show as closed, not merged in github, because I merged via my private tree, not via github).

@dgibson dgibson closed this Aug 8, 2026
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
Finding out how many cells a node's children use for addresses and sizes
currently requires calling the raw fdt_address_cells()/fdt_size_cells()
wrappers with the private FdtRo._fdt buffer, as the class exposes no
methods for them. Add them to FdtRo alongside the other node accessors.

This is a local addition to the imported copy of pylibfdt, to be dropped
on the next resync once it lands upstream.

Link: dgibson/dtc#190
Signed-off-by: Alexey Charkov <alchark@flipper.net>
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
The memory reserve map can be read through num_mem_rsv() and
get_mem_rsv(), but changing it requires calling the raw fdt_* wrappers
with the private Fdt._fdt buffer, as the class exposes no methods for
the write side. Add them next to the existing accessors.

This is a local addition to the imported copy of pylibfdt, to be dropped
on the next resync once it lands upstream.

Link: dgibson/dtc#190
Signed-off-by: Alexey Charkov <alchark@flipper.net>
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
When a generated FIT is used to boot Linux directly, bypassing U-Boot
proper (Falcon mode), there is no runtime code to discover the kernel
command line and (optional) initrd location and include them in a FDT.

To facilitate easier preparation of a ready-to-boot FIT, add support for
pre-patching the FDTs in a FIT with a preconfigured /chosen node including
the bootargs and initrd location.

Note that the initrd part needs a pylibfdt providing address_cells() and
add_mem_rsv(), which the in-tree copy does, but a system one only will
once the respective pull request [1] lands and gets released.

Link: dgibson/dtc#190 [1]
Signed-off-by: Alexey Charkov <alchark@flipper.net>
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
Finding out how many cells a node's children use for addresses and sizes
currently requires calling the raw fdt_address_cells()/fdt_size_cells()
wrappers with the private FdtRo._fdt buffer, as the class exposes no
methods for them. Add them to FdtRo alongside the other node accessors.

This is a local addition to the imported copy of pylibfdt, to be dropped
on the next resync once it lands upstream.

Link: dgibson/dtc#190
Signed-off-by: Alexey Charkov <alchark@flipper.net>
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
The memory reserve map can be read through num_mem_rsv() and
get_mem_rsv(), but changing it requires calling the raw fdt_* wrappers
with the private Fdt._fdt buffer, as the class exposes no methods for
the write side. Add them next to the existing accessors.

This is a local addition to the imported copy of pylibfdt, to be dropped
on the next resync once it lands upstream.

Link: dgibson/dtc#190
Signed-off-by: Alexey Charkov <alchark@flipper.net>
alchark added a commit to flipperdevices/u-boot that referenced this pull request Aug 11, 2026
When a generated FIT is used to boot Linux directly, bypassing U-Boot
proper (Falcon mode), there is no runtime code to discover the kernel
command line and (optional) initrd location and include them in a FDT.

To facilitate easier preparation of a ready-to-boot FIT, add support for
pre-patching the FDTs in a FIT with a preconfigured /chosen node including
the bootargs and initrd location.

Note that the initrd part needs a pylibfdt providing address_cells() and
add_mem_rsv(), which the in-tree copy does, but a system one only will
once the respective pull request [1] lands and gets released.

Link: dgibson/dtc#190 [1]
Signed-off-by: Alexey Charkov <alchark@flipper.net>
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