From 9860c9285322d15bdc94317f24ca51e430f3255f Mon Sep 17 00:00:00 2001
From: Victor Chong <victor.chong@linaro.org>
Date: Fri, 29 Sep 2017 18:25:37 +0100
Subject: [PATCH] hikey*: Use l-loader makefile

l-loader manual build instructions have been integrated into makefiles

Signed-off-by: Victor Chong <victor.chong@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 hikey.mk        | 29 +++++------------------------
 hikey960.mk     | 27 ++++++---------------------
 hikey_debian.mk | 31 ++++++-------------------------
 3 files changed, 17 insertions(+), 70 deletions(-)

diff --git a/hikey.mk b/hikey.mk
index ce53e34..a47246d 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -363,35 +363,16 @@ atf-fb-clean:
 ################################################################################
 # l-loader
 ################################################################################
-.PHONY: lloader-bin
-lloader-bin: arm-tf atf-fb
+.PHONY: lloader
+lloader:
 	cd $(LLOADER_PATH) && \
 		ln -sf $(ARM_TF_PATH)/build/hikey/$(ARM_TF_BUILD)/bl1.bin && \
 		ln -sf $(ATF_FB_PATH)/build/hikey/$(ATF_FB_BUILD)/bl1.bin fastboot.bin && \
-		$(AARCH32_CROSS_COMPILE)gcc -c -o start.o start.S && \
-		$(AARCH32_CROSS_COMPILE)ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader && \
-		$(AARCH32_CROSS_COMPILE)objcopy -O binary loader temp && \
-		python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin
-
-.PHONY: lloader-bin-clean
-lloader-bin-clean:
-	cd $(LLOADER_PATH) && \
-		rm -f l-loader.bin temp loader start.o
-
-.PHONY: lloader-ptbl
-lloader-ptbl:
-	cd $(LLOADER_PATH) && \
-		PTABLE=linux-$(CFG_FLASH_SIZE)g SECTOR_SIZE=512 bash -x generate_ptable.sh
-
-.PHONY: lloader-ptbl-clean
-lloader-ptbl-clean:
-	cd $(LLOADER_PATH) && rm -f prm_ptable.img sec_ptable.img
-
-.PHONY: lloader
-lloader: lloader-bin lloader-ptbl
+		$(MAKE) hikey PTABLE_LST=linux-$(CFG_FLASH_SIZE)g CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)"
 
 .PHONY: lloader-clean
-lloader-clean: lloader-bin-clean lloader-ptbl-clean
+lloader-clean:
+	$(MAKE) -C $(LLOADER_PATH) hikey-clean
 
 ################################################################################
 # nvme image
diff --git a/hikey960.mk b/hikey960.mk
index 96dc97e..d43310c 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -335,31 +335,16 @@ boot-img-clean:
 ################################################################################
 # l-loader
 ################################################################################
-.PHONY: lloader-bin
-lloader-bin: arm-tf
+.PHONY: lloader
+lloader:
 	cd $(LLOADER_PATH) && \
 		ln -sf $(ARM_TF_PATH)/build/hikey960/$(ARM_TF_BUILD)/bl1.bin && \
-		python gen_loader_hikey960.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=$(EDK2_BIN)
-
-.PHONY: lloader-bin-clean
-lloader-bin-clean:
-	cd $(LLOADER_PATH) && \
-		rm -f l-loader.bin
-
-.PHONY: lloader-ptbl
-lloader-ptbl:
-	cd $(LLOADER_PATH) && \
-		PTABLE=linux-32g SECTOR_SIZE=4096 SGDISK=./sgdisk bash -x generate_ptable.sh
-
-.PHONY: lloader-ptbl-clean
-lloader-ptbl-clean:
-	cd $(LLOADER_PATH) && rm -f prm_ptable.img sec_ptable.img
-
-.PHONY: lloader
-lloader: lloader-bin lloader-ptbl
+		ln -sf $(EDK2_BIN) && \
+		$(MAKE) hikey960 PTABLE_LST=linux-32g
 
 .PHONY: lloader-clean
-lloader-clean: lloader-bin-clean lloader-ptbl-clean
+lloader-clean:
+	$(MAKE) -C $(LLOADER_PATH) hikey960-clean
 
 ################################################################################
 # Flash
diff --git a/hikey_debian.mk b/hikey_debian.mk
index b0d1683..97e6a93 100644
--- a/hikey_debian.mk
+++ b/hikey_debian.mk
@@ -352,35 +352,16 @@ system-img-cleaner:
 ################################################################################
 # l-loader
 ################################################################################
-.PHONY: lloader-bin
-lloader-bin: arm-tf atf-fb
-	 cd $(LLOADER_PATH) && \
+.PHONY: lloader
+lloader:
+	cd $(LLOADER_PATH) && \
 		ln -sf $(ARM_TF_PATH)/build/hikey/$(ARM_TF_BUILD)/bl1.bin && \
 		ln -sf $(ATF_FB_PATH)/build/hikey/$(ATF_FB_BUILD)/bl1.bin fastboot.bin && \
-		$(AARCH32_CROSS_COMPILE)gcc -c -o start.o start.S && \
-		$(AARCH32_CROSS_COMPILE)ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader && \
-		$(AARCH32_CROSS_COMPILE)objcopy -O binary loader temp && \
-		python gen_loader_hikey.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin --img_ns_bl1u=fastboot.bin
-
-.PHONY: lloader-bin-clean
-lloader-bin-clean:
-	cd $(LLOADER_PATH) && \
-		rm -f l-loader.bin temp loader start.o
-
-.PHONY: lloader-ptbl
-lloader-ptbl:
-	cd $(LLOADER_PATH) && \
-		PTABLE=linux-$(CFG_FLASH_SIZE)g SECTOR_SIZE=512 bash -x generate_ptable.sh
-
-.PHONY: lloader-ptbl-clean
-lloader-ptbl-clean:
-	cd $(LLOADER_PATH) && rm -f prm_ptable.img sec_ptable.im
-
-.PHONY: lloader
-lloader: lloader-bin lloader-ptbl
+		$(MAKE) hikey PTABLE_LST=linux-$(CFG_FLASH_SIZE)g CROSS_COMPILE="$(CCACHE)$(AARCH32_CROSS_COMPILE)"
 
 .PHONY: lloader-clean
-lloader-clean: lloader-bin-clean lloader-ptbl-clean
+lloader-clean:
+	$(MAKE) -C $(LLOADER_PATH) hikey-clean
 
 ################################################################################
 # nvme image
-- 
GitLab