• OpenWrt kernel install分析(2)


    一. 前言

            接下来分析make -C image compile install TARGET_BUILD=。

    二. Makefile分析

    1. 命令首先运行target/linux/mediatek/image/Makefile,该文件内容如下:

    1. target/linux/mediatek/image/Makefile:
    2. include $(TOPDIR)/rules.mk
    3. include $(INCLUDE_DIR)/image.mk
    4. ......
    5. # build signed fit
    6. define Build/fit-sign
    7. $(TOPDIR)/scripts/mkits.sh \
    8. -D $(DEVICE_NAME) \
    9. -o $@.its \
    10. -k $@ \
    11. $(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
    12. -a $(KERNEL_LOADADDR) \
    13. -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
    14. -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
    15. -A $(LINUX_KARCH) \
    16. -v $(LINUX_VERSION) \
    17. -s $(KDIR)/$(DEVICE_NAME)-u-boot-script \
    18. $(if $(FIT_KEY_NAME),-S $(FIT_KEY_NAME)) \
    19. $(if $(FW_AR_VER),-r $(FW_AR_VER))
    20. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage \
    21. -f $@.its \
    22. $(if $(FIT_KEY_DIR),-k $(FIT_KEY_DIR)) \
    23. -r \
    24. $@.new
    25. @mv $@.new $@
    26. endef
    27. # default all platform image(fit) build
    28. define Device/Default
    29. PROFILES = Default $$(DEVICE_NAME)
    30. KERNEL_NAME := Image
    31. KERNEL = kernel-bin | lzma | \
    32. fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
    33. KERNEL_INITRAMFS = kernel-bin | lzma | \
    34. fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
    35. FILESYSTEMS := squashfs
    36. DEVICE_DTS_DIR := $(DTS_DIR)
    37. IMAGES := sysupgrade.bin
    38. IMAGE/sysupgrade.bin := append-kernel | pad-to 128k | append-rootfs | \
    39. pad-rootfs | append-metadata
    40. FIT_KEY_DIR :=
    41. FIT_KEY_NAME :=
    42. endef
    43. include $(SUBTARGET).mk
    44. define Image/Build
    45. $(call Image/Build/$(1),$(1))
    46. endef
    47. $(eval $(call BuildImage))

            BuildImage在include/image.mk中定义,install目标在里面,代码如下:

    1. include/image.mk:
    2. define BuildImage
    3. ......
    4. download:
    5. prepare:
    6. compile:
    7. clean:
    8. image_prepare:
    9. ifeq ($(IB),)
    10. .PHONY: download prepare compile clean image_prepare kernel_prepare install install-images
    11. compile:
    12. $(call Build/Compile)
    13. clean:
    14. $(call Build/Clean)
    15. image_prepare: compile
    16. mkdir -p $(BIN_DIR) $(KDIR)/tmp
    17. rm -rf $(BUILD_DIR)/json_info_files
    18. $(call Image/Prepare)
    19. else
    20. image_prepare:
    21. mkdir -p $(BIN_DIR) $(KDIR)/tmp
    22. endif
    23. kernel_prepare: image_prepare
    24. $(call Image/Build/targz)
    25. $(call Image/Build/cpiogz)
    26. $(call Image/BuildKernel)
    27. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs)))
    28. $(call Image/InstallKernel)
    29. $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
    30. install-images: kernel_prepare $(foreach fs,$(filter-out $(if $(UBIFS_OPTS),,ubifs),$(TARGET_FILESYSTEMS) $(fs-subtypes-y)),$(KDIR)/root.$(fs))
    31. $(foreach fs,$(TARGET_FILESYSTEMS),
    32. $(call Image/Build,$(fs))
    33. )
    34. install: install-images
    35. $(call Image/Manifest)
    36. endef

            由上可知,install依赖于install-images,install-images依赖于kernel_prepare,kernel_prepare依赖于image_prepare,由于IB未定义,所以image_prepare定义如下:

    1. compile:
    2. $(call Build/Compile)
    3. clean:
    4. $(call Build/Clean)
    5. image_prepare: compile
    6. mkdir -p $(BIN_DIR) $(KDIR)/tmp
    7. rm -rf $(BUILD_DIR)/json_info_files
    8. $(call Image/Prepare)

    image_prepare依赖于compile,这里,Build/Compile并未定义,所以什么都不干

    注意:image_prepare在另一处也有定义,如下:

    1. ifndef IB
    2. define Device/Build/dtb
    3. ifndef BUILD_DTS_$(1)
    4. BUILD_DTS_$(1) := 1
    5. $(KDIR)/image-$(1).dtb: FORCE
    6. $(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dts,$$@)
    7. image_prepare: $(KDIR)/image-$(1).dtb
    8. endif
    9. endef
    10. endif

            这里在执行完上面compile依赖,接下来会完成$(KDIR)/image-$(1).dtb这个依赖,也就是生成设备树文件。

    这种有两个相同目标的执行过程,下面用一个简单案例解释,如下:

    1. act1:
    2. @echo "act1"
    3. act2:
    4. @echo "act2"
    5. target:act1
    6. target:act2
    7. @echo "target finish"
    8. all: target
    9. @echo "all finish"

         这里有两个target目标,分别依赖act1和act2,注意,一个target是有执行动作的,一个没有,这里先执行act2依赖,再act1依赖,执行结果如下:

    1. act2
    2. act1
    3. target finish
    4. all finish

     回到分析,

    1. ifndef IB
    2. define Device/Build/dtb
    3. ifndef BUILD_DTS_$(1)
    4. BUILD_DTS_$(1) := 1
    5. $(KDIR)/image-$(1).dtb: FORCE
    6. $(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dts,$$@)
    7. image_prepare: $(KDIR)/image-$(1).dtb
    8. endif
    9. endef
    10. endif

    $(KDIR)/image-$(1).dtb也是一个目标,动作为$(call Image/BuildDTB,$(strip $(2))/$(strip $(3)).dts,$$@),Image/BuildDTB定义如下,

    1. define Image/BuildDTB
    2. $(TARGET_CROSS)cpp -nostdinc -x assembler-with-cpp \
    3. -I$(DTS_DIR) \
    4. -I$(DTS_DIR)/include \
    5. -I$(LINUX_DIR)/include/ \
    6. -undef -D__DTS__ $(3) \
    7. -o $(2).tmp $(1)
    8. $(LINUX_DIR)/scripts/dtc/dtc -O dtb \
    9. -i$(dir $(1)) $(DTC_FLAGS) $(4) \
    10. -o $(2) $(2).tmp
    11. $(RM) $(2).tmp
    12. endef

    完整命令展开如下:

    1. aarch64-openwrt-linux-musl-cpp -nostdinc -x assembler-with-cpp -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts/include -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/include/ -undef -D__DTS__ -o /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/image-mt7981-spim-nor-rfb.dtb.tmp /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts/mediatek/mt7981-spim-nor-rfb.dts
    2. aarch64-openwrt-linux-musl-cpp -nostdinc -x assembler-with-cpp -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts/include -I/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/include/ -undef -D__DTS__ -o /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/image-mt7981-spim-nor-rfb.dtb.tmp /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts/mediatek/mt7981-spim-nor-rfb.dts
    3. /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/scripts/dtc/dtc -O dtb -i/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/arch/arm64/boot/dts/mediatek/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address -o /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/image-mt7981-spim-nor-rfb.dtb /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/image-mt7981-spim-nor-rfb.dtb.tmp

    注意:

            Device/Build/dtb是由下面代码展开得到的:

    $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))

    TARGET_DEVICES定义在target/linux/mediatek/image/mt7981.mk 中,可以如下:

    1. openwrt# grep -rn "TARGET_DEVICES" target/linux/mediatek/image/mt7981.mk
    2. 10:TARGET_DEVICES += mt7981-spim-nor-rfb
    3. 27:TARGET_DEVICES += mt7981-spim-nand-2500wan-gmac2
    4. 44:TARGET_DEVICES += mt7981-spim-nand-rfb
    5. 61:TARGET_DEVICES += mt7981-spim-nand-gsw
    6. 74:TARGET_DEVICES += mt7981-emmc-rfb
    7. 87:TARGET_DEVICES += mt7981-sd-rfb
    8. 104:TARGET_DEVICES += mt7981-snfi-nand-2500wan-p5
    9. 113:TARGET_DEVICES += mt7981-fpga-spim-nor
    10. 130:TARGET_DEVICES += mt7981-fpga-snfi-nand
    11. 147:TARGET_DEVICES += mt7981-fpga-spim-nand
    12. 160:TARGET_DEVICES += mt7981-fpga-emmc
    13. 173:TARGET_DEVICES += mt7981-fpga-sd

    Device的定义如下:

    1. define Device
    2. $(call Device/InitProfile,$(1))
    3. $(call Device/Init,$(1))
    4. $(call Device/Default,$(1))
    5. $(call Device/$(1),$(1))
    6. $(call Device/Check,$(1))
    7. $(call Device/$(if $(DUMP),Dump,Build),$(1))
    8. endef

            Device/Default定义在target/linux/mediatek/image/Makefile,内容如下:

    1. define Device/Default
    2. PROFILES = Default $$(DEVICE_NAME)
    3. KERNEL_NAME := Image
    4. KERNEL = kernel-bin | lzma | \
    5. fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
    6. KERNEL_INITRAMFS = kernel-bin | lzma | \
    7. fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
    8. FILESYSTEMS := squashfs
    9. DEVICE_DTS_DIR := $(DTS_DIR)
    10. IMAGES := sysupgrade.bin
    11. IMAGE/sysupgrade.bin := append-kernel | pad-to 128k | append-rootfs | \
    12. pad-rootfs | append-metadata
    13. FIT_KEY_DIR :=
    14. FIT_KEY_NAME :=
    15. endef

            Device/$(1):由于$(1)=mt7981-spim-nor-rfb,表示Device/mt7981-spim-nor-rfb,定义在target/linux/mediatek/image/mt7981.mk,内容如下:

    1. define Device/mt7981-spim-nor-rfb
    2. DEVICE_VENDOR := MediaTek
    3. DEVICE_MODEL := mt7981-spim-nor-rfb
    4. DEVICE_DTS := mt7981-spim-nor-rfb
    5. DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
    6. SUPPORTED_DEVICES := mediatek,mt7981-spim-nor-rfb
    7. endef
    8. TARGET_DEVICES += mt7981-spim-nor-rfb

            由于DUMP未定义,$(call Device/$(if $(DUMP),Dump,Build),$(1))为Device/Build。

    2. Device/Build展开如下

    1. define Device/Build
    2. $$(eval $$(foreach image,$$(IMAGES), \
    3. $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
    4. $$(call Device/Build/per-device-fs,$$(fs),$$(image),$(1)))))
    5. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
    6. $(call Device/Build/kernel,$(1),$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)))
    7. $$(eval $$(foreach compile,$$(COMPILE), \
    8. $$(call Device/Build/compile,$$(compile),$(1))))
    9. $$(eval $$(foreach image,$$(IMAGES), \
    10. $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
    11. $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
    12. $$(eval $$(foreach artifact,$$(ARTIFACTS), \
    13. $$(call Device/Build/artifact,$$(artifact))))
    14. endef

             注意:这里Device/Build/initramfs是关键,内存根文件系统只会执行到这个,Device/Build/initramfs,内容如下:

    1. define split_args
    2. $(foreach data, \
    3. $(subst |,$(space),\
    4. $(subst $(space),^,$(1))), \
    5. $(call $(2),$(strip $(subst ^,$(space),$(data)))))
    6. endef
    7. define build_cmd
    8. $(if $(Build/$(word 1,$(1))),,$(error Missing Build/$(word 1,$(1))))
    9. $(call Build/$(word 1,$(1)),$(wordlist 2,$(words $(1)),$(1)))
    10. endef
    11. define concat_cmd
    12. $(call split_args,$(1),build_cmd)
    13. endef
    14. ifndef IB
    15. define Device/Build/initramfs
    16. $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1))
    17. $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) \
    18. $$(if $$(CONFIG_JSON_OVERVIEW_IMAGE_INFO), $(BUILD_DIR)/json_info_files/$$(KERNEL_INITRAMFS_IMAGE).json,))
    19. $(KDIR)/$$(KERNEL_INITRAMFS_NAME):: image_prepare
    20. $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
    21. cp $$^ $$@
    22. $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_INITRAMFS_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare
    23. @rm -f $$@
    24. $$(call concat_cmd,$$(KERNEL_INITRAMFS))
    25. ......
    26. endef
    27. endif

             注意:这里concat_cmd非常重要,lzma压缩,mkits.sh制作its文件以及mkimage打包最终镜像都是这里完成。展开结果命令如下:

    1. rm -f /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin
    2. cp /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/Image-initramfs /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin
    3. /home/work/openwrt/staging_dir/host/bin/lzma e /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin -lc1 -lp2 -pb2 /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.new
    4. @mv /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.new /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin
    5. /home/work/openwrt/scripts/mkits.sh -D mt7981-spim-nor-rfb -o /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.its -k /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin -d /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/image-mt7981-spim-nor-rfb.dtb -C lzma -a 0x48080000 -e 0x48080000 -c "config-1" -A arm64 -v 5.4.203
    6. PATH=/home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/linux-5.4.203/scripts/dtc:/home/work/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin:/home/work/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin:/home/work/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin:/home/work/openwrt/staging_dir/host/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/work/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-8.4.0_musl/bin/ mkimage -f /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.its /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.new
    7. @mv /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin.new /home/work/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7981/tmp/openwrt-mediatek-mt7981-mt7981-spim-nor-rfb-initramfs-kernel.bin

            

    (eval" role="presentation" style="text-align: center; position: relative;">(eval
    (foreach compile,
    (COMPILE)," role="presentation" style="text-align: center; position: relative;">(COMPILE),
    (call Device/Build/compile,$$(compile),$(1))))展开如下:
    1. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-spim-nor-rfb)))
    2. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-spim-nand-2500wan-gmac2)))
    3. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-spim-nand-rfb)))
    4. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-spim-nand-gsw)))
    5. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-emmc-rfb)))
    6. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-sd-rfb)))
    7. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-snfi-nand-2500wan-p5)))
    8. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-fpga-spim-nor)))
    9. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-fpga-snfi-nand)))
    10. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-fpga-spim-nand)))
    11. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-fpga-emmc)))
    12. Makefile:91: $(eval $(foreach compile,$(COMPILE), $(call Device/Build/compile,$(compile),mt7981-fpga-sd)))

            由于$(COMPILE)为空,所以这块执行没有效果。

    接下来,

    1. $$(eval $$(foreach image,$$(IMAGES), \
    2. $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
    3. $$(call Device/Build/image,$$(fs),$$(image),$(1)))))

            由于TARGET_FILESYSTEMS是要编译的镜像格式类型,如下:

    1. fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs
    2. fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE))
    3. fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE))
    4. fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
    5. fs-types-$(CONFIG_TARGET_ROOTFS_UBIFS) += ubifs
    6. fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
    7. TARGET_FILESYSTEMS := $(fs-types-y)

            由于CONFIG_TARGET_ROOTFS_SQUASHFS等我都没选,所以,TARGET_FILESYSTEMS为空,这里也是不执行的。可以看出Device/Build/image的作用是生成不同文件系统的镜像。

    接下来,

    1. $$(eval $$(foreach artifact,$$(ARTIFACTS), \
    2. $$(call Device/Build/artifact,$$(artifact))))

            由于ARTIFACTS变量为空,所以,这里Device/Build/artifact什么也不干。

    三. 总结

    这里需要注意的以下几点:

    1. image_prepare有两个目标,有动作的这个目标做的事情很少,没有目标的依赖是用于编译设备树的,要非常注意。

    2. 由于编译选项没选,Image/Build/targz,Image/Build/cpiogz这里什么也不做,Image/BuildKernelImage/InstallKernel没有定义(可能是用于自定义的,这里没用到而已),这里什么也不做。

    3. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs))),这里结果为$(call Image/BuildKernel/Initramfs),继续展开为$(call Image/Build/Initramfs),但是Image/Build/Initramfs未定义,所以这里什么也不干,也是用于自定义的。

    4. $(foreach device,$(TARGET_DEVICES),$(call Device,$(device))),这里TARGET_DEVICES定义在mt7981.mk中,表示不同的镜像(spi-nor,spi-nand,emmc等等),Device宏里面要关注Device/Default和Device/Build,Device/Default定义在target/linux/mediatek/image/Makefile中,定义了一些镜像相关的变量,Device/Build中要关注$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1))),结果是$(call Device/Build/initramfs,$(1)),重点要关注$$(call concat_cmd,$$(KERNEL_INITRAMFS))这里,这里面打包了最终的镜像(lzma压缩,its文件生成,mkimage都在这里执行)。

  • 相关阅读:
    Java_笔记_StringBuilder的基本操作_链式编程
    Vue3核心语法一
    MIGraphX推理框架第十章-MIGraphX常见问题
    vue3封装element-plus的Form表单
    【Akka】Akka 学习 akka 两本书的读后感
    尚医通(三)
    mysql日期月份相关函数
    UVA297 四分树 Quadtrees
    顺序表的实现及操作【C语言最详细版】
    vscode px转换rem插件 px to rem & rpx & vw (cssrem)
  • 原文地址:https://blog.csdn.net/to_be_better_wen/article/details/132894591