From 4a5b6176a6150ffce8951b31ea60f3c8195fe970 Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@forissier.org>
Date: Mon, 12 Jul 2021 13:04:41 +0200
Subject: [PATCH] hikey: fix 'invalid partition' error during recovery

After trying to use upstream EDK2 on my HiKey board without success,
I reached a point where even 'make recovery' would not make the board
bootable again. The recovery process failed like so:

 $ make recovery
 [...]
 Waiting for device... [35][34][33][32][31][30][29][28][27][26][25][24][23][22][21][20][19][18]
 Sending /home/jerome/work/optee_repo_hikey/build/../l-loader/recovery.bin ...
 Done

 fastboot flash loader /home/jerome/work/optee_repo_hikey/build/../l-loader/l-loader.bin
 < waiting for any device >
 Sending 'loader' (39 KB)                           FAILED (remote: 'invalid partition')
 fastboot: error: Command failed
 make: *** [Makefile:351: recovery] Error 1

The solution to this problem is mentioned in [1] and consists in
running 'fastboot getvar partition-size:ptable' before the fastboot
flash command.

Link: [1] https://github.com/96boards/documentation/issues/751.
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Victor Chong <victor.chong@linaro.org>
---
 hikey.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hikey.mk b/hikey.mk
index 7fa8115..4181c92 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -348,6 +348,7 @@ recovery:
 	$(call flash_help)
 	@echo
 	$(ROOT)/burn-boot/hisi-idt.py --img1=$(LLOADER_PATH)/recovery.bin
+	fastboot getvar partition-size:ptable
 	fastboot flash loader $(LLOADER_PATH)/l-loader.bin
 	@echo
 	@echo "3. Wait until you see the (UART) message"
-- 
GitLab