From ee2eb13b7407841e9c0dbc76d18878b241d3e9f2 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sun, 5 Nov 2017 18:27:18 +0100 Subject: [PATCH] mkimxboot: small fixes and display a human readable error Change-Id: I9362b62351925aef5b14656635875123942fe7e4 --- rbutil/mkimxboot/main.c | 2 +- rbutil/mkimxboot/mkimxboot.c | 23 ++++++++++++++++++++++- rbutil/mkimxboot/mkimxboot.h | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/rbutil/mkimxboot/main.c b/rbutil/mkimxboot/main.c index 90f2f20a5f..5b8cceb044 100644 --- a/rbutil/mkimxboot/main.c +++ b/rbutil/mkimxboot/main.c @@ -284,6 +284,6 @@ int main(int argc, char *argv[]) opt.force_version = force_version; opt.model = model; enum imx_error_t err = mkimxboot(infile, bootfile, outfile, opt); - printf("Result: %d\n", err); + printf("Result: %d (%s)\n", err, imx_error_to_string(err)); return 0; } diff --git a/rbutil/mkimxboot/mkimxboot.c b/rbutil/mkimxboot/mkimxboot.c index db18c769fb..369c397d51 100644 --- a/rbutil/mkimxboot/mkimxboot.c +++ b/rbutil/mkimxboot/mkimxboot.c @@ -233,6 +233,27 @@ static const struct imx_model_desc_t imx_models[] = #define MAGIC_NORMAL 0xcafebabe #define MAGIC_CHARGE 0x67726863 /* 'chrg' */ +const char *imx_error_to_string(enum imx_error_t err) +{ + switch(err) + { + case IMX_SUCCESS: return "success"; + case IMX_ERROR: return "error"; + case IMX_OPEN_ERROR: return "open error"; + case IMX_READ_ERROR: return "read error"; + case IMX_NO_MATCH: return "no match"; + case IMX_BOOT_INVALID: return "invalid"; + case IMX_BOOT_MISMATCH: return "mismatch"; + case IMX_BOOT_CHECKSUM_ERROR: return "checksum error"; + case IMX_DONT_KNOW_HOW_TO_PATCH: return "don't know how to patch"; + case IMX_VARIANT_MISMATCH: return "variant mismatch"; + case IMX_WRITE_ERROR: return "write error"; + case IMX_FIRST_SB_ERROR: return "sb error"; + case IMX_MODEL_MISMATCH: return "model mismatch"; + default: return "unknown error"; + } +} + static void add_key_list(struct crypto_key_t **list) { while(*list != NULL) @@ -987,7 +1008,7 @@ static enum imx_error_t make_boot(struct sb_file_t *sb_file, const char *bootfil /* produce file */ ret = patch_firmware(opt, sb_file, boot_fw); rb_fw_free(&boot_fw); - return IMX_SUCCESS; + return ret; } enum imx_error_t mkimxboot(const char *infile, const char *bootfile, diff --git a/rbutil/mkimxboot/mkimxboot.h b/rbutil/mkimxboot/mkimxboot.h index 59f28a98a0..6bf0415e9c 100644 --- a/rbutil/mkimxboot/mkimxboot.h +++ b/rbutil/mkimxboot/mkimxboot.h @@ -106,6 +106,8 @@ enum imx_error_t mkimxboot(const char *infile, const char *bootfile, enum imx_error_t compute_md5sum(const char *file, uint8_t file_md5sum[16]); /* Compute "soft" MD5 sum of a SB file */ enum imx_error_t compute_soft_md5sum(const char *file, uint8_t soft_md5sum[16]); +/* Translate error */ +const char *imx_error_to_string(enum imx_error_t err); #ifdef __cplusplus }