+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2015 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier: GPL-2.0+
+ * Copyright 2021 NXP
*/
#include <common.h>
+#include <dm.h>
+#include <flash.h>
#include <fsl_validate.h>
#include <fsl_secboot_err.h>
#include <fsl_sfp.h>
#include <fsl_sec.h>
#include <command.h>
+#include <log.h>
#include <malloc.h>
-#include <dm/uclass.h>
#include <u-boot/rsa-mod-exp.h>
#include <hash.h>
#include <fsl_secboot_err.h>
-#ifdef CONFIG_LS102XA
+#ifdef CONFIG_ARCH_LS1021A
#include <asm/arch/immap_ls102xa.h>
#endif
*/
void fsl_secboot_handle_error(int error)
{
+#ifndef CONFIG_SPL_BUILD
const struct fsl_secboot_errcode *e;
for (e = fsl_secboot_errcodes; e->errcode != ERROR_ESBC_CLIENT_MAX;
if (e->errcode == error)
printf("ERROR :: %x :: %s\n", error, e->name);
}
+#else
+ printf("ERROR :: %x\n", error);
+#endif
/* If Boot Mode is secure, transition the SNVS state and issue
* reset based on type of failure and ITS setting.
ret = algo->hash_init(algo, &ctx);
if (ret)
return ret;
-
/* Update hash for ESBC key */
#ifdef CONFIG_KEY_REVOCATION
if (check_srk(img)) {
img->img_key, img->key_len, 1);
if (ret)
return ret;
-
/* Copy hash at destination buffer */
ret = algo->hash_finish(algo, ctx, hash_val, algo->digest_size);
- if (ret)
+ if (ret) {
+ free(ctx);
return ret;
-
+ }
for (i = 0; i < SHA256_BYTES; i++)
img->img_key_hash[i] = hash_val[i];
#endif
if (ret)
return ret;
- if (!key_hash)
+ if (!key_hash) {
+ free(ctx);
return ERROR_KEY_TABLE_NOT_FOUND;
-
+ }
/* Update hash for actual Image */
ret = algo->hash_update(algo, ctx,
(u8 *)(*(img->img_addr_ptr)), img->img_size, 1);
/* Copy hash at destination buffer */
ret = algo->hash_finish(algo, ctx, hash_val, algo->digest_size);
- if (ret)
+ if (ret) {
+ free(ctx);
return ret;
-
+ }
return 0;
}
if (!p) {
return 0;
} else {
- tmp = simple_strtoul(p, &endptr, 16);
+ tmp = hextoul(p, &endptr);
if (sizeof(ulong) == 4)
*num = cpu_to_be32(tmp);
else