mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ulf Samuelsson <linux-kernel@emagii.com>
To: LKML <linux-kernel@vger.kernel.org>
Subject: RFC: Copying Device Tree File into reserved area of VMLINUX before deployment
Date: Sat, 18 Nov 2017 18:59:17 +0100	[thread overview]
Message-ID: <0b31e22b-202f-6fca-28f2-e16e6af6c6b7@emagii.com> (raw)

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



-- 
Best Regards
Ulf Samuelsson

             reply	other threads:[~2017-11-18 18:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-18 17:59 Ulf Samuelsson [this message]
2017-11-20  4:23 ` Frank Rowand
2017-11-20  4:32   ` Frank Rowand
2017-11-20 20:19     ` Ulf Samuelsson
2017-11-20 21:39       ` Frank Rowand
2017-11-20 23:09         ` Ulf Samuelsson
2017-11-21  6:19           ` Ulf Samuelsson
2017-11-21 12:02             ` Ulf Samuelsson
2017-11-21 17:09         ` Rob Herring
2017-11-21 20:03           ` Ulf Samuelsson
2017-11-20 11:44   ` Mark Rutland
2017-11-20 16:38     ` Frank Rowand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b31e22b-202f-6fca-28f2-e16e6af6c6b7@emagii.com \
    --to=linux-kernel@emagii.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®