archs38: build dtb files in Image/Prepare so that they are available for Device/*
[openwrt/openwrt.git] / target / linux / archs38 / image / Makefile
index 505ed0262540b7911936184b70ae63ba1e6f6929..e9aac1f688f47633bfc18feef51fc939fd3d3cf2 100644 (file)
@@ -11,11 +11,7 @@ include $(INCLUDE_DIR)/image.mk
 # in memory from build to built. Thus we need to extract EP from vmlinux
 # every time before generation of uImage.
 define Build/calculate-ep
-       $(eval KERNEL_ENTRY=$(shell $(KERNEL_CROSS)readelf -h $(LINUX_DIR)/vmlinux | grep "Entry point address" | grep -o 0x.*))
-endef
-
-define Build/build-dtb
-       $(call Image/BuildDTB,$(DTS_DIR)/$(DEVICE_DTS).dts,$(DTS_DIR)/$(DEVICE_DTS).dtb)
+       $(eval KERNEL_ENTRY=$(shell $(KERNEL_CROSS)readelf -h $(1) | grep "Entry point address" | grep -o 0x.*))
 endef
 
 define Build/patch-dtb
@@ -26,7 +22,7 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
 # Root FS built-in
 define Device/vmlinux
        KERNEL_SUFFIX := .elf
-       KERNEL := kernel-bin | build-dtb | patch-dtb
+       KERNEL := kernel-bin | patch-dtb
        KERNEL_INITRAMFS_NAME = vmlinux-initramfs.elf
 endef
 
@@ -36,16 +32,24 @@ define Device/nsim_hs
        DEVICE_DTS := nsim_hs_idu
 endef
 TARGET_DEVICES += nsim_hs
-else
+endif
+
 # Root FS on SD-card
 KERNEL_LOADADDR := 0x80000000
-DEVICE_DTS_LIST:= axs103_idu
+DEVICE_DTS_LIST:= axs103_idu nsim_hs_idu
 FAT32_BLOCK_SIZE=1024
 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_AXS10X_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
 
+define Image/Prepare
+       # Build .dtb for all boards we may run on
+       $(foreach dts,$(DEVICE_DTS_LIST),
+               $(call Image/BuildDTB,$(DTS_DIR)/$(dts).dts,$(DTS_DIR)/$(dts).dtb)
+       )
+endef
+
 define Image/Build/SDCard
        rm -f $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
-       mkdosfs $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
+       mkfs.fat $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
        mkimage -C none -A arc -T script -d uEnv.txt $(BIN_DIR)/uEnv.scr
        mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/uEnv.scr ::boot.scr
        mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/*.dtb ::
@@ -65,15 +69,12 @@ endef
 
 define Image/BuildKernel
        # Build unified uImage
-       $(call Build/calculate-ep)
+       $(call Build/calculate-ep, $(KDIR)/vmlinux.elf)
        $(call Image/BuildKernel/MkuImage, \
                none, $(KERNEL_LOADADDR), $(KERNEL_ENTRY), \
                $(KDIR)/vmlinux, \
                $(BIN_DIR)/$(IMG_PREFIX)-uImage \
        )
-
-       # Build .dtb for all boards we may run on
-       $(foreach DEVICE_DTS,$(shell echo $(DEVICE_DTS_LIST)), $(call Build/build-dtb))
 endef
 
 define Image/Build
@@ -81,6 +82,5 @@ define Image/Build
        $(call Image/Build/SDCard,$(1))
        dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
 endef
-endif
 
 $(eval $(call BuildImage))