Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arnout Vandecappelle <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/4] Add support for appended device tree blobs for arm
Date: Sun, 15 Jul 2012 14:41:15 +0200	[thread overview]
Message-ID: <5002BA6B.30408@mind.be> (raw)
In-Reply-To: <1341309676-18681-3-git-send-email-maxime.ripard@free-electrons.com>

On 07/03/12 12:01, Maxime Ripard wrote:
> Signed-off-by: Maxime Ripard<maxime.ripard@free-electrons.com>
> ---
>   linux/Config.in |    8 ++++++++
>   linux/linux.mk  |   38 +++++++++++++++++++++++++++++++++++++-
>   2 files changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/linux/Config.in b/linux/Config.in
> index 6f704b0..46b9756 100644
> --- a/linux/Config.in
> +++ b/linux/Config.in
> @@ -132,6 +132,14 @@ config BR2_LINUX_KERNEL_DTS_SUPPORT
>
>   if BR2_LINUX_KERNEL_DTS_SUPPORT
>
> +config BR2_LINUX_KERNEL_APPENDED_DTB
> +	bool "Append the Device Tree binary to the kernel"
> +	depends on BR2_arm || BR2_armeb

  From the code below, it looks like this also
	depends on BR2_LINUX_KERNEL_UBOOT_IMAGE || BR2_LINUX_KERNEL_ZIMAGE

> +	help
> +	  After building the device tree blob, append it to the
> +	  kernel image. If necessary generates a uImage from that
> +	  new kernel image afterward.
> +
>   choice
>   	prompt "Device tree source"
>   	default BR2_LINUX_KERNEL_USE_DEFAULT_DTS
> diff --git a/linux/linux.mk b/linux/linux.mk
> index 0540aeb..483974c 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -52,6 +52,13 @@ else ifeq ($(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),y)
>   KERNEL_DTS_NAME = $(basename $(notdir $(BR2_LINUX_KERNEL_CUSTOM_DTS_FILE)))
>   endif
>
> +ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
> +ifneq ($(words $(KERNEL_DTS_NAME)),1)
> +$(error Kernel with appended device tree needs exactly one DTS source.\
> +  Check BR2_LINUX_KERNEL_DTS_FILE or BR2_LINUX_KERNEL_CUSTOM_DTS_FILE.)
> +endif
> +endif
> +
>   ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y)
>   LINUX_IMAGE_NAME=$(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME))
>   else
> @@ -76,6 +83,12 @@ LINUX_IMAGE_NAME=vmlinuz
>   endif
>   endif
>
> +ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
> +LINUX_IMAGE_TARGET=zImage
> +else
> +LINUX_IMAGE_TARGET=$(LINUX_IMAGE_NAME)
> +endif
> +
>   # Compute the arch path, since i386 and x86_64 are in arch/x86 and not
>   # in arch/$(KERNEL_ARCH). Even if the kernel creates symbolic links
>   # for bzImage, arch/i386 and arch/x86_64 do not exist when copying the
> @@ -155,6 +168,8 @@ define LINUX_CONFIGURE_CMDS
>   		$(call KCONFIG_SET_OPT,CONFIG_UEVENT_HELPER_PATH,\"/sbin/mdev\",$(@D)/.config))
>   	$(if $(BR2_PACKAGE_SYSTEMD),
>   		$(call KCONFIG_ENABLE_OPT,CONFIG_CGROUPS,$(@D)/.config))
> +	$(if $(BR2_LINUX_KERNEL_APPENDED_DTB),
> +		$(call KCONFIG_ENABLE_OPT,CONFIG_ARM_APPENDED_DTB,$(@D)/.config))
>   	yes '' | $(TARGET_MAKE_ENV) $(MAKE1) $(LINUX_MAKE_FLAGS) -C $(@D) oldconfig
>   endef
>
> @@ -164,17 +179,38 @@ define LINUX_BUILD_DTB
>   endef
>   endif
>
> +ifeq ($(BR2_LINUX_KERNEL_APPENDED_DTB),y)
> +ifeq ($(BR2_LINUX_KERNEL_UBOOT_IMAGE),y)
> +define LINUX_APPEND_DTB
> +	cat $(KERNEL_ARCH_PATH)/boot/zImage $(KERNEL_ARCH_PATH)/boot/$(KERNEL_DTS_NAME).dtb>  $(KERNEL_ARCH_PATH)/boot/zImage_dtb
> +	mv $(KERNEL_ARCH_PATH)/boot/zImage_dtb $(KERNEL_ARCH_PATH)/boot/zImage
> +	LOAD=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) | sed -n 's/Load Address: \([0-9]*\)/\1/p'`; \
> +	ENTRY=`$(MKIMAGE) -l $(LINUX_IMAGE_PATH) | sed -n 's/Entry Point: \([0-9]*\)/\1/p'`; \
> +	$(MKIMAGE) -A $(KERNEL_ARCH) -O linux -T kernel -C none -a $${LOAD} -e $${ENTRY} -n 'Linux Buildroot' \
> +		-d $(KERNEL_ARCH_PATH)/boot/zImage $(KERNEL_ARCH_PATH)/boot/$(LINUX_IMAGE_NAME)
> +endef
> +else ifeq ($(BR2_LINUX_KERNEL_ZIMAGE),y)
> +define LINUX_APPEND_DTB
> +	cat $(KERNEL_ARCH_PATH)/boot/zImage $(KERNEL_ARCH_PATH)/boot/$(KERNEL_DTS_NAME).dtb>  $(KERNEL_ARCH_PATH)/boot/zImage_dtb
> +	mv $(KERNEL_ARCH_PATH)/boot/zImage_dtb $(KERNEL_ARCH_PATH)/boot/zImage
> +endef
> +else
> +$(error Appending DTB to the kernel image is only possible for u-boot images and zImage.)

  This is unnecessary with the Config.in change I proposed.

> +endif
> +endif
> +
>   # Compilation. We make sure the kernel gets rebuilt when the
>   # configuration has changed.
>   define LINUX_BUILD_CMDS
>   	$(if $(BR2_LINUX_KERNEL_USE_CUSTOM_DTS),
>   		mkdir $(KERNEL_ARCH_PATH)/boot/dts
>   		cp $(BR2_LINUX_KERNEL_CUSTOM_DTS_FILE) $(KERNEL_ARCH_PATH)/boot/dts/)
> -	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_NAME)
> +	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_IMAGE_TARGET)
>   	@if grep -q "CONFIG_MODULES=y" $(@D)/.config; then 	\
>   		$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) modules ;	\
>   	fi
>   	$(LINUX_BUILD_DTB)
> +	$(LINUX_APPEND_DTB)
>   endef
>
>

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

  reply	other threads:[~2012-07-15 12:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03 10:01 [Buildroot] [PATCHv2] Add some support for device tree kernels with appended trees Maxime Ripard
2012-07-03 10:01 ` [Buildroot] [PATCH 1/4] Rework support for the device tree Maxime Ripard
2012-07-15 12:34   ` Arnout Vandecappelle
2012-07-15 12:41     ` Arnout Vandecappelle
2012-07-16 12:57   ` Thomas Petazzoni
     [not found]     ` <5006E601.4080807@essensium.com>
2012-07-19  7:42       ` Thomas Petazzoni
2012-07-03 10:01 ` [Buildroot] [PATCH 2/4] Add support for appended device tree blobs for arm Maxime Ripard
2012-07-15 12:41   ` Arnout Vandecappelle [this message]
2012-07-16 13:01   ` Thomas Petazzoni
2012-07-16 13:10   ` Thomas Petazzoni
2012-07-03 10:01 ` [Buildroot] [PATCH 3/4] Factorise the u-boot images code Maxime Ripard
2012-07-15 12:42   ` Arnout Vandecappelle
2012-07-16 13:03   ` Thomas Petazzoni
2012-07-03 10:01 ` [Buildroot] [PATCH 4/4] Add cuImage(powerpc) and simpleImage(microblaze) as Linux kernel images variants Maxime Ripard
2012-07-15 12:43   ` Arnout Vandecappelle
2012-07-16 12:46 ` [Buildroot] [PATCHv2] Add some support for device tree kernels with appended trees Thomas Petazzoni

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=5002BA6B.30408@mind.be \
    --to=arnout@mind.be \
    --cc=buildroot@busybox.net \
    /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