[LEDE-DEV] [RFC 1/2] zynq: convert to new image build code

Jason Wu jason.wu.misc at gmail.com
Thu Jul 28 07:57:53 PDT 2016



On 29/07/2016 12:01 AM, Jo-Philipp Wich wrote:
> Convert the Zynq target to use the new image build code in order to fix
> broken image generation after 9945a1dca5bb6bc522393f7583baf3a64df6ce11
> changed the handling of CPIO images.
Can you check if you still have the build issue if you enabled the 
CONFIG_TARGET_ROOTFS_CPIOGZ options
>
> Also remove the misapplied ubifs feature flag since the image generation is
> not using UBIFS for building FIT images.
>
> As part of the conversion, move the DTB building and the uImage ramdisk
> generation into separate build steps which can be generalized and shared
> with other targets, like APM821xx, in the long run.
nice work.

>
> Signed-off-by: Jo-Philipp Wich <jo at mein.io>
> ---
>  target/linux/zynq/Makefile       |  2 +-
>  target/linux/zynq/image/Makefile | 86 ++++++++++++++++++----------------------
>  2 files changed, 39 insertions(+), 49 deletions(-)
>
> diff --git a/target/linux/zynq/Makefile b/target/linux/zynq/Makefile
> index 6495c59..a84f968 100644
> --- a/target/linux/zynq/Makefile
> +++ b/target/linux/zynq/Makefile
> @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/host.mk
>  ARCH:=arm
>  BOARD:=zynq
>  BOARDNAME:=Xilinx Zynq 7000 SoCs
> -FEATURES:=fpu gpio rtc usb usbgadget targz ubifs
> +FEATURES:=fpu gpio rtc usb usbgadget targz
>  CPU_TYPE:=cortex-a9
>  CPU_SUBTYPE:=neon
>  MAINTAINER:=Jason Wu <jason.wu.misc at gamil.com>
> diff --git a/target/linux/zynq/image/Makefile b/target/linux/zynq/image/Makefile
> index 4c85bc2..4452787 100644
> --- a/target/linux/zynq/image/Makefile
> +++ b/target/linux/zynq/image/Makefile
> @@ -11,33 +11,33 @@ include $(INCLUDE_DIR)/image.mk
>  # Images
>  #################################################
>
> -define Image/boot-imgs
> -	# Copy zImage to BIN_DIR
> -	$(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
> -
> -	$(call Image/BuildKernel/MkuImage, none, $(KERNEL_LOADADDR), \
> -		$(KERNEL_ENTRY_POINT), $(KDIR)/zImage, \
> -		$(BIN_DIR)/$(IMG_PREFIX)-uImage)
> -
> -	$(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,\
> -		$(BIN_DIR)/$(IMG_PREFIX)-system.dtb)
> +# $(1): rootfs contents directory
> +define Image/mkfs/cpio
should not this be Image/mkfs/cpiogz as you use gzip
> +	( cd $(call mkfs_target_dir,$(1))/; find . | cpio -o -H newc | gzip -9n > $@ )
> +endef
I don't think you need to add define Image/mkfs/cpio. The cpio.gz should 
be there if you enable CONFIG_TARGET_ROOTFS_TARGZ
>
> +define Build/uRamdisk
>  	# Create uboot cpio.gz
>  	mkimage -A arm -T ramdisk -C gzip -n "$(PROFILE) OpenWRT rootfs" \
> -		-d $(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz \
> -		$(BIN_DIR)/$(IMG_PREFIX)-uramdisk.image.gz
> +		-d $(KDIR)/root.cpio $@.new
> +	mv $@.new $@
> +endef
I think the problem that needs to be addressed is to setup correct cpio 
image base on the config options.
>
> +# $(1): dts file basename
> +define Build/dtb
> +	$(call Image/BuildDTB,$(DTS_DIR)/$(1).dts,$@.dtb)
> +endef
> +
> +# $(1): FIT name/description
> +define Build/fit
>  	# create FIT image with rootfs
>  	./mkits.sh \
> -		-D $(DEVICE_LC) -o $(KDIR)/fit-$(DEVICE_LC).its -k $(KDIR)/zImage \
> -		-d $(BIN_DIR)/$(IMG_PREFIX)-system.dtb \
> -		-C none -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY_POINT) \
> +		-D $(1) -o $@.its -k $(KDIR)/zImage -d $@.dtb \
> +		-C none -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) \
>  		-A $(ARCH) -v $(LINUX_VERSION) \
> -		-r $(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz -z gzip
> -	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(DEVICE_LC).its $(KDIR)/fit-$(DEVICE_LC).itb
> -	$(CP) $(KDIR)/fit-$(DEVICE_LC).itb $(BIN_DIR)/$(IMG_PREFIX)-fit.itb
> -	ln -fs $(IMG_PREFIX)-fit.itb $(BIN_DIR)/fit.itb
> +		-r $(KDIR)/root.cpio -z gzip
-r and -z options need to be set base on the config options.

>
> +	PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@
>  endef
>
>  #################################################
> @@ -46,36 +46,26 @@ endef
>
>  # default kernel load address
>  KERNEL_LOADADDR=0x8000
> -KERNEL_ENTRY_POINT=0x8000
> -
> -### Device macros ###
> -define Device/Default
> -	IMG_PREFIX := zynq
> -	PROFILE_SANITIZED :=
> -endef
> -
> -define Device/DefaultConfig
> -	DEVICE_LC = $(1)
> -	IMG_PREFIX = zynq-$(1)
> -	DEVICE_DTS = zynq-$(1)
> -endef
> -
> -### ZC702 ###
> -define Device/ZC702
> -	$(call Device/DefaultConfig,zc702)
> -endef
> -
> -define Device/ZED
> -	$(call Device/DefaultConfig,zed)
> -endef
> -
> -define Device/ZYBO
> -	$(call Device/DefaultConfig,zybo)
> +KERNEL_ENTRY=0x8000
> +
> +TARGET_FILESYSTEMS += cpio
> +
> +# $(1): uppercase profile name
> +# $(2): lowercase profile name
> +define ZynqDevice
> +  define Device/$(1)
> +	KERNEL := kernel-bin | uImage none
> +	KERNEL_NAME = zImage
> +	IMAGES := uramdisk.image.gz fit.itb
> +	IMAGE/uramdisk.image.gz := uRamdisk
> +	IMAGE/fit.itb := dtb zynq-$(2) | fit $(2)
> +	IMAGE_NAME = $$$$(IMG_PREFIX)-$(2)-$$$$(2)
> +  endef
> +  TARGET_DEVICES += $(1)
>  endef
>
> -define Image/BuildKernel
> -	$(eval $(call Device/$(PROFILE)))
> -	$(call Image/boot-imgs)
> -endef
> +$(eval $(call ZynqDevice,ZC702,zc702))
> +$(eval $(call ZynqDevice,ZED,zed))
> +$(eval $(call ZynqDevice,ZYBO,zybo))
>
>  $(eval $(call BuildImage))
>
nice work on cleaning it up.

Thanks.

Jason



More information about the Lede-dev mailing list