From patchwork Tue Mar 24 14:23:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Johnson X-Patchwork-Id: 244214 List-Id: U-Boot discussion From: mrjoel at lixil.net (Joel Johnson) Date: Tue, 24 Mar 2020 08:23:51 -0600 Subject: [PATCH v5 5/5] cmd: mvebu: bubt: show image boot device In-Reply-To: <20200324142351.400920-1-mrjoel@lixil.net> References: <20200324142351.400920-1-mrjoel@lixil.net> Message-ID: <20200324142351.400920-5-mrjoel@lixil.net> 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 Reviewed-by: Stefan Roese --- v2 changes: - newly added in v2 series v3 changes: - none v4 changes: - adjust to ARRAY_SIZE usage v5 changes: - remove double space (one each line) in error message --- cmd/mvebu/bubt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index b03924ca06..728633e60a 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -676,6 +676,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 < ARRAY_SIZE(a38x_boot_modes); 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; } @@ -746,7 +757,6 @@ static int bubt_verify(const struct bubt_dev *dst) if (IS_ENABLED(CONFIG_ARMADA_38X)) { err = a38x_check_boot_mode(dst); if (err) { - puts("Error: image not built for destination device!\n"); return err; } }