diff mbox series

[v2,5/5] cmd: mvebu: bubt: show image boot device

Message ID 20200129145013.125237-5-mrjoel@lixil.net
State Superseded
Headers show
Series [v2,1/5] cmd: mvebu: bubt: add A38x support | expand

Commit Message

Joel Johnson Jan. 29, 2020, 2:50 p.m. UTC
When a mismatch is found trying to write an image for one boot method
to a different boot device, print an error message including the image
header marked target boot device type.

Signed-off-by: Joel Johnson <mrjoel at lixil.net>

---

v2 changes:
  - newly added in v2 series

---
 cmd/mvebu/bubt.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Stefan Roese March 23, 2020, 10:08 a.m. UTC | #1
On 29.01.20 15:50, Joel Johnson wrote:
> When a mismatch is found trying to write an image for one boot method
> to a different boot device, print an error message including the image
> header marked target boot device type.
> 
> Signed-off-by: Joel Johnson <mrjoel at lixil.net>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan
diff mbox series

Patch

diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 78061a6a2d..5e2877788a 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -678,6 +678,17 @@  static int a38x_check_boot_mode(const struct bubt_dev *dst)
 	if (a38x_boot_modes[mode].id == hdr->blockid)
 		return 0;
 
+	for (int i = 0; i < A38X_BOOT_MODE_MAX; i++) {
+		if (a38x_boot_modes[i].id == hdr->blockid) {
+			printf("Error: image meant to be booted from "
+			       " \"%s\", not \"%s\"!\n",
+			       a38x_boot_modes[i].name, dst->name);
+			return -ENOEXEC;
+		}
+	}
+
+	printf("Error: unknown boot device in image header: 0x%x\n",
+	       hdr->blockid);
 	return -ENOEXEC;
 }
 
@@ -747,10 +758,8 @@  static int bubt_verify(const struct bubt_dev *dst)
 
 #if defined(CONFIG_ARMADA_38X)
 	err = a38x_check_boot_mode(dst);
-	if (err) {
-		puts("Error: image not built for destination device!\n");
+	if (err)
 		return err;
-	}
 #endif
 
 	return 0;