All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Draszik" <git@andred.net>
To: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v8 3/3] kernel-devicetree.bbclass: Add support to generate append to kernel
Date: Thu, 14 Sep 2017 11:19:55 +0100	[thread overview]
Message-ID: <1505384395.19222.2.camel@andred.net> (raw)
In-Reply-To: <20170912203608.14327-3-otavio@ossystems.com.br>

On Tue, 2017-09-12 at 17:36 -0300, Otavio Salvador wrote:
> The are use cases where the Device Tree appended to the kernel is
> convinient, so we generate the bundle concatenating the kernel (and
> potentionally the initramfs) and the Device Tree binaries.
> 
> To enable it, set KERNEL_DEVICETREE_BUNDLE variable to '1'
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
> 
> Changes in v8:
> - rework append support to support ARM and MIPS (obi)
> 
> Changes in v7:
> - simplified code
> - rename bundle to use .bin extension
> 
> Changes in v6: None
> Changes in v5:
> - add support for initramfs bundle
> 
> Changes in v4:
> - new patch
> 
> Changes in v3: None
> Changes in v2: None
> 
>  meta/classes/kernel-devicetree.bbclass | 62
> +++++++++++++++++++++++++++++++++-
>  1 file changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/kernel-devicetree.bbclass b/meta/classes/kernel-
> devicetree.bbclass
> index 8723f24212..c618594c96 100644
> --- a/meta/classes/kernel-devicetree.bbclass
> +++ b/meta/classes/kernel-devicetree.bbclass
> @@ -1,6 +1,13 @@
>  # Support for device tree generation
> -PACKAGES_append = " kernel-devicetree"
> +PACKAGES_append = " \
> +    kernel-devicetree \
> +    ${@['kernel-image-zimage-bundle',
> ''][d.getVar('KERNEL_DEVICETREE_BUNDLE') != '1']} \
> +"
>  FILES_kernel-devicetree = "/${KERNEL_IMAGEDEST}/*.dtb
> /${KERNEL_IMAGEDEST}/*.dtbo"
> +FILES_kernel-image-zimage-bundle = "/${KERNEL_IMAGEDEST}/zImage-
> *.dtb.bin"
> +
> +# Generate kernel+devicetree bundle
> +KERNEL_DEVICETREE_BUNDLE ?= "0"
>  
>  normalize_dtb () {
>  	DTB="$1"
> @@ -20,6 +27,38 @@ get_real_dtb_path_in_kernel () {
>  	echo "${DTB_PATH}"
>  }
>  
> +
> +do_configure_devicetree() {
> +	if [ "${KERNEL_DEVICETREE_BUNDLE}" = "1" ]; then
> +		if echo ${KERNEL_IMAGETYPE_FOR_MAKE} | grep -q 'zImage';
> then
> +			case "${ARCH}" in
> +				"arm")
> +				config="${B}/.config"
> +				if ! grep -q 'CONFIG_ARM_APPENDED_DTB=y'
> $config; then
> +					bbwarn 'CONFIG_ARM_APPENDED_DTB
> is NOT enabled in the kernel. Enabling it to allow the kernel to boot with
> the Device Tree appended!'
> +					sed -i "/CONFIG_ARM_APPENDED_DTB[
> =]/d" $config
> +					echo "CONFIG_ARM_APPENDED_DTB=y"
> >> $config
> +					echo "#
> CONFIG_ARM_ATAG_DTB_COMPAT is not set" >> $config
> +				fi
> +				;;
> +				"mips")
> +				config="${B}/.config"
> +				if ! grep -q 'CONFIG_MIPS_APPENDED_DTB=y'
> $config; then

Looking more into this, this Kconfig option doesn't actually exist on mips.
Instead, it has these three related options:
CONFIG_MIPS_NO_APPENDED_DTB
CONFIG_MIPS_ELF_APPENDED_DTB
CONFIG_MIPS_RAW_APPENDED_DTB

I've never used this, but I think you'd have to check for
CONFIG_MIPS_RAW_APPENDED_DTB=y for similar semantics to arm.

And the KERNEL_IMAGETYPE_FOR_MAKE can be either vmlinux.bin, or vmlinuz.bin
(where vmlinuz.bin is similar to the arm zImage).

i.e.:
cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb
cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb


To also support CONFIG_MIPS_ELF_APPENDED_DTB, you'd have to

objcopy --update-section .appended_dtb=<filename>.dtb vmlinux

instead.


All untested.


Cheers,
Andre'



  parent reply	other threads:[~2017-09-14 10:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 20:36 [PATCH v8 1/3] kernel: Move Device Tree support to kernel.bbclass Otavio Salvador
2017-09-12 20:36 ` [PATCH v8 2/3] kernel-devicetree.bbclass: Rework to use tasks Otavio Salvador
2017-09-12 20:36 ` [PATCH v8 3/3] kernel-devicetree.bbclass: Add support to generate append to kernel Otavio Salvador
2017-09-13  8:15   ` André Draszik
2017-09-13 12:30     ` Otavio Salvador
2017-09-14 10:26       ` André Draszik
2017-09-14 12:13         ` Otavio Salvador
2017-09-15  7:55           ` André Draszik
2017-09-14 10:19   ` André Draszik [this message]
2017-09-13  8:24 ` [PATCH v8 1/3] kernel: Move Device Tree support to kernel.bbclass Richard Purdie
  -- strict thread matches above, loose matches on Subject: below --
2017-09-12 13:45 Otavio Salvador
2017-09-12 13:45 ` [PATCH v8 3/3] kernel-devicetree.bbclass: Add support to generate append to kernel Otavio Salvador
2017-09-12 14:45   ` Andreas Oberritter
2017-09-12 17:00     ` Otavio Salvador
2017-09-12 19:10       ` Andreas Oberritter
2017-09-12 20:26         ` Otavio Salvador

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=1505384395.19222.2.camel@andred.net \
    --to=git@andred.net \
    --cc=openembedded-core@lists.openembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.