Re: [PATCH v3 05/15] pylibfdt: Add Fdt.set_boot_cpuid_phys()

From: David Gibson

Date: Sun Nov 01 2026 - 23:36:29 EST


On Sun, Nov 01, 2026 at 02:01:12PM -0800, Douglas Anderson wrote:
> `FdtRo` exposes `boot_cpuid_phys()` to read the physical boot CPU ID
> from the FDT header, and SWIG already wraps the underlying C function
> `fdt_set_boot_cpuid_phys()`, but `class Fdt` lacked a corresponding
> `set_boot_cpuid_phys()` method.
>
> Add `Fdt.set_boot_cpuid_phys()` and test it in
> `tests/pylibfdt_tests.py`.
>
> Assisted-by: Gemini:gemini-pro-prerelease
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
>
> Changes in v3:
> - New patch adding Fdt.set_boot_cpuid_phys() to pylibfdt (Simon Glass)
>
> pylibfdt/libfdt.i | 8 ++++++++
> tests/pylibfdt_tests.py | 3 +++
> 2 files changed, 11 insertions(+)
>
> diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> index eb14312986ea..51db9535bd39 100644
> --- a/pylibfdt/libfdt.i
> +++ b/pylibfdt/libfdt.i
> @@ -684,6 +684,14 @@ class Fdt(FdtRo):
> del self._fdt[self.totalsize():]
> return err
>
> + def set_boot_cpuid_phys(self, boot_cpuid_phys):
> + """Set the physical boot CPU ID
> +
> + Args:
> + boot_cpuid_phys: Physical boot CPU ID
> + """
> + fdt_set_boot_cpuid_phys(self._fdt, boot_cpuid_phys)
> +
> def add_mem_rsv(self, addr, size, quiet=()):
> """Add a memory reserve-map record
>
> diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
> index 20741d8f2df0..18730965bd02 100644
> --- a/tests/pylibfdt_tests.py
> +++ b/tests/pylibfdt_tests.py
> @@ -300,6 +300,9 @@ class PyLibfdtBasicTests(unittest.TestCase):
> self.assertEqual(self.fdt.version(), 17)
> self.assertEqual(self.fdt.last_comp_version(), 16)
> self.assertEqual(self.fdt.boot_cpuid_phys(), 0)
> + self.fdt.set_boot_cpuid_phys(0x42)
> + self.assertEqual(self.fdt.boot_cpuid_phys(), 0x42)
> + self.fdt.set_boot_cpuid_phys(0)
> self.assertEqual(self.fdt.size_dt_strings(), 105)
> self.assertEqual(self.fdt.size_dt_struct(), 564)
>
> --
> 2.56.0.317.g454f8302e1-goog
>
>

--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature