On Friday, 1 February 2019 13:03:42 CET Paul Spooren wrote:
> Hi all,
> 
> thanks to this[0] bug report I found that the ar71xx/generic
> ImageBuilder doesn't create any firmware images for profile OM2P when
> used with BIN_DIR.
> 
> My first guess is that it's somewhat related to a hard coded destination
> which doesn't handle BIN_DIR. At the very end of an "successful" build log:
> 
> > if [ -e 
> > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-factory.bin"
> >  ]; then cp 
> > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-factory.bin"
> >  
> > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-sysupgrade.bin";
> >  fi

Ehrm, no. These things are not hardcoded but your make just filled the 
placeholders before it prints it and sends it to your $SHELL.

The legacy build script is basically calling this helper:

    define Image/Build/OpenMesh
        -sh $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
                "$(4)" \
                "$(BUILD_DIR)/fwupgrade.cfg-$(4)" \
                "$(KDIR_TMP)/vmlinux-$(2).uImage" \
                "$(KDIR)/root.$(1)"
        -sh $(TOPDIR)/scripts/combined-ext-image.sh \
                "$(4)" "$(call factoryname,$(1),$(2))" \
                "$(BUILD_DIR)/fwupgrade.cfg-$(4)" "fwupgrade.cfg" \
                "$(KDIR_TMP)/vmlinux-$(2).uImage" "kernel" \
                "$(KDIR)/root.$(1)" "rootfs"
        if [ -e "$(call factoryname,$(1),$(2))" ]; then \
                cp "$(call factoryname,$(1),$(2))" "$(call 
sysupname,$(1),$(2))"; \
        fi
    endef

The output files are defined using:

    define sysupname
    $(call imgname,$(1),$(2))-sysupgrade.bin
    endef

    define factoryname
    $(call imgname,$(1),$(2))-factory.bin
    endef


And the imgname is:

    define imgname
    $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(call rootfs_type,$(1))
    endef


At least it looks to me like BIN_DIR is used. But yes, the second parameter to 
scripts/combined-ext-image.sh in the make output is really using something 
which is definitely not containing the user supplied BIN_DIR but the standard 
BIN_DIR from rules.mk.

If you replace the factoryname with imgname in this line (or directly 
$(BIN_DIR)), you will also see that it is not using the user supplied BIN_DIR.

You can also see this problem when you select "Linksys WRT400N" or "Zcomax 
ZCN-1523H-5-16" - which are also using factoryname/imgname. But also devices 
like "ALFA AP96"/"Atheros AP96", which are using the default "RKuImage", have 
this problem. Something tells me that all(?) legacy build scripts are 
affected. At least it works fine with ap121f from the non-legacy devices.

I would guess that this is caused by the way SingleProfile is defined and how 
it interacts with LegacyDevice (include/image-legacy.mk) vs. Device
(include/image.mk). If you look carefully, you will notice that legacy devices 
spawn a new sub-make - non-legacy devices don't do that.

You can try the attached mini-patch [1] to check whether this is your problem. 

Kind regards,
        Sven

[1] https://github.com/openwrt/openwrt/pull/1815
From: Sven Eckelmann <s...@narfation.org>
Date: Mon, 11 Feb 2019 16:26:42 +0100
Subject: build: Accept BIN_DIR parameter for legacy-images

BIN_DIR can be set to overwrite the output path for new images. This is an
advertised feature for the imagebuilder and is used by systems like
LibreMesh's chef.

The legacy images are build using a new sub-make which doesn't receive the
variable overwrites of the parent make process. As result, the BIN_DIR is
automatically defined to the default value from rules.mk. The images will
therefore not be placed in the output path which was selected by the user.

Providing BIN_DIR as an explicit variable override to the sub-make works
around this problem.

Fixes: 26c771452cd8 ("image.mk: add LegacyDevice wrapper to allow legacy image building code to be used for device profiles")
Reported-by: Paul Spooren <m...@aparcar.org>
Signed-off-by: Sven Eckelmann <s...@narfation.org>

diff --git a/include/image.mk b/include/image.mk
index a2b106d909831411c99a725c959c05f1df912ec9..b01cd2bf6848ebdba90f87850a9e9cbdad4233e5 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -581,7 +581,7 @@ define BuildImage
 		$(call Image/Prepare)
 
     legacy-images-prepare-make: image_prepare
-		$(MAKE) legacy-images-prepare
+		$(MAKE) legacy-images-prepare BIN_DIR="$(BIN_DIR)"
 
   else
     image_prepare:
@@ -605,7 +605,7 @@ define BuildImage
 
   legacy-images-make: install-images
 	$(call Image/mkfs/ubifs/legacy)
-	$(MAKE) legacy-images
+	$(MAKE) legacy-images BIN_DIR="$(BIN_DIR)"
 
   install: install-images
 	$(call Image/Manifest)

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to