
On Sun, Sep 29, 2024 at 6:55 PM Marek Vasut marex@denx.de wrote:
On 9/28/24 12:47 AM, Lothar Rubusch wrote:
[...]
Ideally I like to setup some Kconfig choice for base board selection and one for boot-mode.
1.) In the documentation control.rst I read that the u-boot.dts is combined of several elements. Is there a way to take this base .dts, then add a base board .dtsi by Kconfig option, and similar a boot-mode?
The -u-boot.dtsi is preprocessed by C preprocessor, just like all the other DTs, so you can have a -u-boot.dtsi file which contains C preprocessor conditional statements in it to conditionally include other .dtsi files:
#if IS_ENABLED(...) #include ... #else ... ... #endif
Going through the include list setup by the Makefile made me find my mistake. Currently I may use u-boot specific stuff in arch/arm/dts and include generic .dtsi fragments from dts/upstream. Note: I'm not setting CONFIG_OF_UPSTREAM since I'm using the regular include list which already contains dts/upstream/src/arm/intel. Is this ok? Or, shall I try a different approach, which involves having CONFIG_OF_UPSTREAM explicitely set in the defconfig?
I'm not quite sure I understand the question. Once this platform DTs land in mainline and the DTs get synchronized into U-Boot, you should then set CONFIG_OF_UPSTREAM. Until then, you could patch the DTs into dts/upstream/ to test the result with OF_UPSTREAM enabled .
Ah, sorry. I did not explain well. Currently I patch the DTs which should go to kernel/mainline into my local u-boot: dts/upstream/src/arm/intel/socfpga/ as a preparation for my test builds.
For U-boot I will need to build a devicetree file from archarm/dts. I cannot rely just on the upstream fragments for u-boot. Imagine settings like initial fpga bitstream loading, handoff file setup for initialization, etc. In parts I may use .dtsi files from dts/upstream, though, but most of the u-boot particular devicetree setup will reside in arch/arm/dts, I guess (you may see later in the patches).
I noticed when setting the option CONFIG_OF_UPSTREAM in `make menuconfig`, it prepends `dts/upstream/` to the included paths of the devicetree files. The resulting path for the .dts was then dts/upstream/arch/arm/dts/ and could not be found anymore. When I don't activate CONFIG_OF_UPSTREAM, dts/upstream is in the Makefile's include list anyway so that I easily can include from both locations.
In conclusion, currently I'm calling a .dts for building the u-boot DT from arch/arm/dts. The file includes upstream stuff as .dtsi fragment from dts/upstream and handoff from local. CONFIG_OF_UPSTREAM does not seem to be necessary in this case.
This approach currently works for me. If you strongly disagree, I may invest more time to find a way (or why there is currently no way) with CONFIG_OF_UPSTREAM.
This was my question about. Anyway you may wait on v3 to understand better in source what I'm doing, or if I'm just messing around.
3.) What would be the best possibility to have a u-boot.dts with handoff setup in arch/arm/dts and append .dtsi files from the general dts/upstream - in case are there other boards are doing something similar?
See above, maybe some of it helps.
Yes. This helped. I can set base-board and boot mode now by Kconfig option with a generic .dts file. Note, it may still take some time, since I'd like to test the stuff still a bit on hardware before submitting something to the list.
Sure
I still found some bugs. When it's working (again), I'll let you guys know..