Re: RFC: Copying Device Tree File into reserved area of VMLINUX before deployment

From: Frank Rowand
Date: Sun Nov 19 2017 - 23:25:40 EST


adding devicetree list, devicetree maintainers

On 11/18/17 12:59, Ulf Samuelsson wrote:
> I noticed when checking out the OpenWRT support for the board that they have a method to avoid having to pass the device tree address to the kernel, and can thus boot device tree based kernels with U-boots that
> does not support device trees.
>
> Is this something that would be considered useful for including in mainstream:
>
> BACKGROUND:
> Trying to load a yocto kernel into a MIPS target (MT7620A based),
> and the U-Boot is more than stupid.
> Does not support the "run" command as an example.
> They modified the U-Boot MAGIC Word to complicate things.
> The U-Boot is not configured to use device tree files.
> The board runs a 2.6 kernel right now.
>
> Several attempts by me a and others to rebuild U-Boot according to the H/W vendors source code and build instructions results in a bricked unit. Bricked units cannot be recovered.
>
> Not my choice of H/W, so I cannot change it.
>
>
> ===================================================================
> OPENWRT:
> I noticed when checking out the OpenWRT support for the board that they have a method to avoid having to pass the device tree address to the kernel, and can thus boot device tree based kernels with U-boots that
> does not support device trees.
>
> What they do is to reserve 16 kB of kernel space, and tag it with an ASCII string "OWRTDTB:".
> After the kernel and dtb is built, a utility "patch-dtb" will update the vmlinux binary, copying in the device tree file.
>
> ===================================================================
> It would be useful to me, and I could of course patch the mainstream kernel, but first I would like to check if this is of interest for mainstream.
>
> I envisage the support would look something like:
>
> ============
> Kconfig.
> config MIPS
> ÂÂÂÂselectÂÂÂ HAVE_IMAGE_DTB
>
> configÂÂÂ HAVE_IMAGE_DTB
> ÂÂÂÂbool
>
> if HAVE_IMAGE_DTB
> configÂÂÂÂ IMAGE_DTB
> ÂÂÂÂboolÂÂÂ "Allocated space for DTB within image
>
> configÂÂÂ DTB_SIZE
> ÂÂÂÂintÂÂÂ "DTB space (kB)
>
> configÂÂÂ DTB_TAG
> ÂÂÂÂstringÂÂÂ "DTB space tag"
> ÂÂÂÂdefaultÂÂÂ "OWRTDTB:"
> endif
>
> ============
> Some Makefile
> obj-$(CONFIG_INCLUDE_DTB) += image_dtb.o
>
> ============
> image_dtb.S:
> ÂÂÂÂ.text
> ÂÂÂÂ.alignÂÂÂ 5
> ÂÂÂÂ.asciiÂÂÂ CONFIG_DTB_TAG
> ÂÂÂÂEXPORT(__image_dtb)
> ÂÂÂÂ.fillÂÂÂ DTB_SIZE * 1024
>
> ===================
> arch/mips/xxx/of.c:
>
> #ifÂÂÂ defined(CONFIG_IMAGE_DTB)
> ÂÂÂÂif (<conditions to boot from dtb_space>)
> ÂÂÂÂÂÂÂ __dt_setup_arch(__dtb_start);
> ÂÂÂÂelse
> ÂÂÂÂÂÂÂ __dt_setup_arch(&__image_dtb);
> #else
> ÂÂÂÂ__dt_setup_arch(__dtb_start);
> #endif
>
> I imagine that if the support is enabled for a target, it should
> be possible to override it with a CMDLINE argument
> ÂÂÂÂ
> ÂÂÂÂ
> They do something similar for the CMDLINE; copying it into the vmlinux, to allow a smaller boot
>
>
>