Skip to content

Commit

Permalink
ANDROID: ARM64: add option to build Image.gz/dtb combo
Browse files Browse the repository at this point in the history
Allows a defconfig to set a list of dtbs to concatenate with an
Image.gz to create a Image.gz-dtb.

Includes 8adb162 arm64: Fix correct dtb clean-files location

Change-Id: I0b462322d5c970f1fdf37baffece7ad058099f4a
Signed-off-by: Alex Ray <[email protected]>
[rishabhb] Use subdir to descend into device tree directories
Signed-off-by: Rishabh Bhatnagar <[email protected]>

konrad: fast-forward it to msm-5.4
  • Loading branch information
Alex Ray authored and Konrad Dybcio committed Jan 4, 2022
1 parent 1db68e9 commit a98e79a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
15 changes: 15 additions & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,21 @@ config DMI
However, even with this option, the resultant kernel should
continue to boot on existing non-UEFI platforms.

config BUILD_ARM64_APPENDED_DTB_IMAGE
bool "Build a concatenated Image.gz/dtb by default"
depends on OF
help
Enabling this option will cause a concatenated Image.gz and list of
DTBs to be built by default (instead of a standalone Image.gz.)
The image will built in arch/arm64/boot/Image.gz-dtb

config BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES
string "Default dtb names"
depends on BUILD_ARM64_APPENDED_DTB_IMAGE
help
Space separated list of names of dtbs to append when
building a concatenated Image.gz-dtb.

endmenu

choice
Expand Down
13 changes: 11 additions & 2 deletions arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ endif

# Default target when executing plain make
boot := arch/arm64/boot
KBUILD_IMAGE := $(boot)/$(KBUILD_TARGET)

all: $(KBUILD_TARGET)
ifeq ($(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE),y)
# Warning! Uncompressed kernel + appended DTB + DTBO WILL NOT WORK!
KBUILD_IMAGE := $(KBUILD_TARGET)-dtb
else
KBUILD_IMAGE := $(KBUILD_TARGET)
endif

all: $(KBUILD_IMAGE)

Image: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
Expand All @@ -158,6 +164,9 @@ Image.%: Image
zinstall install:
$(Q)$(MAKE) $(build)=$(boot) $@

$(KBUILD_TARGET)-dtb: vmlinux scripts dtbs
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

PHONY += vdso_install
vdso_install:
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
Expand Down
2 changes: 2 additions & 0 deletions arch/arm64/boot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Image
Image-dtb
Image.gz
Image.gz-dtb
16 changes: 16 additions & 0 deletions arch/arm64/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# Based on the ia64 boot/Makefile.
#

include $(srctree)/arch/arm64/boot/dts/Makefile

OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S

targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo
Expand All @@ -33,6 +35,14 @@ rtic_mp.dtb: vmlinux FORCE

endif

DTB_NAMES := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES))
ifneq ($(DTB_NAMES),)
DTB_LIST := $(addsuffix .dtb,$(DTB_NAMES))
else
DTB_LIST := $(dtb-y)
endif
DTB_OBJS := $(addprefix $(obj)/dts/,$(DTB_LIST))

$(obj)/Image: vmlinux FORCE
$(call if_changed,objcopy)

Expand All @@ -51,6 +61,12 @@ $(obj)/Image.lzma: $(obj)/Image FORCE
$(obj)/Image.lzo: $(obj)/Image FORCE
$(call if_changed,lzo)

$(obj)/Image-dtb: $(obj)/Image $(DTB_OBJS) FORCE
$(call if_changed,cat)

$(obj)/Image.gz-dtb: $(obj)/Image.gz $(DTB_OBJS) FORCE
$(call if_changed,cat)

install:
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
$(obj)/Image System.map "$(INSTALL_PATH)"
Expand Down
20 changes: 17 additions & 3 deletions arch/arm64/boot/dts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,21 @@ subdir-y += xilinx
subdir-y += zte

dtstree := $(srctree)/$(src)
vendor := $(dtstree)/vendor
ifneq "$(wildcard $(vendor)/Makefile)" ""
subdir-y += vendor

dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(foreach d,$(subdir), $(wildcard $(dtstree)/$(d)/*.dts)))

always := $(dtb-y)

targets += dtbs

DTB_NAMES := $(subst $\",,$(CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES))
ifneq ($(DTB_NAMES),)
DTB_LIST := $(addsuffix .dtb,$(DTB_NAMES))
else
DTB_LIST := $(dtb-y)
endif
targets += $(DTB_LIST)

dtbs: $(addprefix $(obj)/, $(DTB_LIST))

clean-files := dts/*.dtb *.dtb

0 comments on commit a98e79a

Please sign in to comment.