mkimxboot: small fixes and display a human readable error

Change-Id: I9362b62351925aef5b14656635875123942fe7e4
This commit is contained in:
Amaury Pouly 2017-11-05 18:27:18 +01:00
parent 5a3b30d8fd
commit ee2eb13b74
3 changed files with 25 additions and 2 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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
}