common: fit: support spl fit image check by tools/fit_check_sign
Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I0e03a90d50290e18c6fb2cd44516c352f3695290
This commit is contained in:
parent
8e3eb57c1c
commit
96f5441ec8
|
|
@ -30,6 +30,10 @@
|
||||||
#include <bootm.h>
|
#include <bootm.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
|
|
||||||
|
#ifdef USE_HOSTCC
|
||||||
|
#define CONFIG_SYS_BOOTM_LEN 0x4000000
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SYS_BOOTM_LEN
|
#ifndef CONFIG_SYS_BOOTM_LEN
|
||||||
/* use 8MByte as default max gunzip size */
|
/* use 8MByte as default max gunzip size */
|
||||||
#define CONFIG_SYS_BOOTM_LEN 0x800000
|
#define CONFIG_SYS_BOOTM_LEN 0x800000
|
||||||
|
|
@ -350,7 +354,8 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size,
|
||||||
const char *name = genimg_get_comp_name(comp_type);
|
const char *name = genimg_get_comp_name(comp_type);
|
||||||
|
|
||||||
if (uncomp_size >= unc_len)
|
if (uncomp_size >= unc_len)
|
||||||
printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n");
|
printf("Image too large(0x%lx >= 0x%lx): increase CONFIG_SYS_BOOTM_LEN\n",
|
||||||
|
(ulong)uncomp_size, (ulong)unc_len);
|
||||||
else
|
else
|
||||||
printf("%s: uncompress error %d\n", name, ret);
|
printf("%s: uncompress error %d\n", name, ret);
|
||||||
|
|
||||||
|
|
@ -978,7 +983,7 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
|
||||||
memmove(to, from, len);
|
memmove(to, from, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bootm_host_load_image(const void *fit, int req_image_type)
|
static int bootm_host_load_image(const void *fit, int req_image_type, int index)
|
||||||
{
|
{
|
||||||
const char *fit_uname_config = NULL;
|
const char *fit_uname_config = NULL;
|
||||||
ulong data, len;
|
ulong data, len;
|
||||||
|
|
@ -992,9 +997,9 @@ static int bootm_host_load_image(const void *fit, int req_image_type)
|
||||||
|
|
||||||
memset(&images, '\0', sizeof(images));
|
memset(&images, '\0', sizeof(images));
|
||||||
images.verify = 1;
|
images.verify = 1;
|
||||||
noffset = fit_image_load(&images, (ulong)fit,
|
noffset = fit_image_load_index(&images, (ulong)fit,
|
||||||
NULL, &fit_uname_config,
|
NULL, &fit_uname_config,
|
||||||
IH_ARCH_DEFAULT, req_image_type, -1,
|
IH_ARCH_DEFAULT, req_image_type, index, -1,
|
||||||
FIT_LOAD_IGNORED, &data, &len);
|
FIT_LOAD_IGNORED, &data, &len);
|
||||||
if (noffset < 0)
|
if (noffset < 0)
|
||||||
return noffset;
|
return noffset;
|
||||||
|
|
@ -1021,20 +1026,42 @@ static int bootm_host_load_image(const void *fit, int req_image_type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bootm_host_load_images(const void *fit, int cfg_noffset)
|
int bootm_host_load_images(const void *fit, int cfg_noffset, int is_spl)
|
||||||
{
|
{
|
||||||
static uint8_t image_types[] = {
|
static uint8_t image_types[] = {
|
||||||
IH_TYPE_KERNEL,
|
IH_TYPE_KERNEL,
|
||||||
IH_TYPE_FLATDT,
|
IH_TYPE_FLATDT,
|
||||||
IH_TYPE_RAMDISK,
|
IH_TYPE_RAMDISK,
|
||||||
};
|
};
|
||||||
|
static uint8_t image_types_spl[] = {
|
||||||
|
IH_TYPE_FLATDT,
|
||||||
|
IH_TYPE_FIRMWARE,
|
||||||
|
IH_TYPE_LOADABLE,
|
||||||
|
IH_TYPE_LOADABLE,
|
||||||
|
IH_TYPE_LOADABLE,
|
||||||
|
};
|
||||||
|
int loadable_index = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
int index;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(image_types); i++) {
|
for (i = 0; !is_spl && i < ARRAY_SIZE(image_types); i++) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = bootm_host_load_image(fit, image_types[i]);
|
ret = bootm_host_load_image(fit, image_types[i], 0);
|
||||||
|
if (!err && ret && ret != -ENOENT)
|
||||||
|
err = ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; is_spl && i < ARRAY_SIZE(image_types_spl); i++) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (image_types_spl[i] == IH_TYPE_LOADABLE)
|
||||||
|
index = loadable_index++;
|
||||||
|
else
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
ret = bootm_host_load_image(fit, image_types_spl[i], index);
|
||||||
if (!err && ret && ret != -ENOENT)
|
if (!err && ret && ret != -ENOENT)
|
||||||
err = ret;
|
err = ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1799,6 +1799,8 @@ static const char *fit_get_image_type_property(int type)
|
||||||
return FIT_KERNEL_PROP;
|
return FIT_KERNEL_PROP;
|
||||||
case IH_TYPE_RAMDISK:
|
case IH_TYPE_RAMDISK:
|
||||||
return FIT_RAMDISK_PROP;
|
return FIT_RAMDISK_PROP;
|
||||||
|
case IH_TYPE_FIRMWARE:
|
||||||
|
return FIT_FIRMWARE_PROP;
|
||||||
case IH_TYPE_X86_SETUP:
|
case IH_TYPE_X86_SETUP:
|
||||||
return FIT_SETUP_PROP;
|
return FIT_SETUP_PROP;
|
||||||
case IH_TYPE_LOADABLE:
|
case IH_TYPE_LOADABLE:
|
||||||
|
|
@ -1810,10 +1812,10 @@ static const char *fit_get_image_type_property(int type)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
int fit_image_load(bootm_headers_t *images, ulong addr,
|
int fit_image_load_index(bootm_headers_t *images, ulong addr,
|
||||||
const char **fit_unamep, const char **fit_uname_configp,
|
const char **fit_unamep, const char **fit_uname_configp,
|
||||||
int arch, int image_type, int bootstage_id,
|
int arch, int image_type, int image_index, int bootstage_id,
|
||||||
enum fit_load_op load_op, ulong *datap, ulong *lenp)
|
enum fit_load_op load_op, ulong *datap, ulong *lenp)
|
||||||
{
|
{
|
||||||
int cfg_noffset, noffset;
|
int cfg_noffset, noffset;
|
||||||
const char *fit_uname;
|
const char *fit_uname;
|
||||||
|
|
@ -1886,8 +1888,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||||
bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG);
|
bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
noffset = fit_conf_get_prop_node(fit, cfg_noffset,
|
noffset = fit_conf_get_prop_node_index(fit, cfg_noffset,
|
||||||
prop_name);
|
prop_name, image_index);
|
||||||
fit_uname = fit_get_name(fit, noffset, NULL);
|
fit_uname = fit_get_name(fit, noffset, NULL);
|
||||||
}
|
}
|
||||||
if (noffset < 0) {
|
if (noffset < 0) {
|
||||||
|
|
@ -1933,6 +1935,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||||
os_ok = image_type == IH_TYPE_FLATDT ||
|
os_ok = image_type == IH_TYPE_FLATDT ||
|
||||||
image_type == IH_TYPE_FPGA ||
|
image_type == IH_TYPE_FPGA ||
|
||||||
fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
|
fit_image_check_os(fit, noffset, IH_OS_LINUX) ||
|
||||||
|
fit_image_check_os(fit, noffset, IH_OS_ARM_TRUSTED_FIRMWARE) ||
|
||||||
|
fit_image_check_os(fit, noffset, IH_OS_OP_TEE) ||
|
||||||
fit_image_check_os(fit, noffset, IH_OS_U_BOOT) ||
|
fit_image_check_os(fit, noffset, IH_OS_U_BOOT) ||
|
||||||
fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);
|
fit_image_check_os(fit, noffset, IH_OS_OPENRTOS);
|
||||||
|
|
||||||
|
|
@ -2034,6 +2038,16 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||||
return noffset;
|
return noffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||||
|
const char **fit_unamep, const char **fit_uname_configp,
|
||||||
|
int arch, int image_type, int bootstage_id,
|
||||||
|
enum fit_load_op load_op, ulong *datap, ulong *lenp)
|
||||||
|
{
|
||||||
|
return fit_image_load_index(images, addr,fit_unamep, fit_uname_configp,
|
||||||
|
arch, image_type, 0, bootstage_id,
|
||||||
|
load_op, datap, lenp);
|
||||||
|
}
|
||||||
|
|
||||||
int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
|
int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
|
||||||
ulong *setup_start, ulong *setup_len)
|
ulong *setup_start, ulong *setup_len)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ void lynxkdi_boot(image_header_t *hdr);
|
||||||
|
|
||||||
boot_os_fn *bootm_os_get_boot_func(int os);
|
boot_os_fn *bootm_os_get_boot_func(int os);
|
||||||
|
|
||||||
int bootm_host_load_images(const void *fit, int cfg_noffset);
|
int bootm_host_load_images(const void *fit, int cfg_noffset, int is_spl);
|
||||||
|
|
||||||
int boot_selected_os(int argc, char * const argv[], int state,
|
int boot_selected_os(int argc, char * const argv[], int state,
|
||||||
bootm_headers_t *images, boot_os_fn *boot_fn);
|
bootm_headers_t *images, boot_os_fn *boot_fn);
|
||||||
|
|
|
||||||
|
|
@ -656,6 +656,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
|
||||||
int arch, int image_type, int bootstage_id,
|
int arch, int image_type, int bootstage_id,
|
||||||
enum fit_load_op load_op, ulong *datap, ulong *lenp);
|
enum fit_load_op load_op, ulong *datap, ulong *lenp);
|
||||||
|
|
||||||
|
int fit_image_load_index(bootm_headers_t *images, ulong addr,
|
||||||
|
const char **fit_unamep, const char **fit_uname_configp,
|
||||||
|
int arch, int image_type, int image_index, int bootstage_id,
|
||||||
|
enum fit_load_op load_op, ulong *datap, ulong *lenp);
|
||||||
|
|
||||||
#ifndef USE_HOSTCC
|
#ifndef USE_HOSTCC
|
||||||
/**
|
/**
|
||||||
* fit_get_node_from_config() - Look up an image a FIT by type
|
* fit_get_node_from_config() - Look up an image a FIT by type
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,6 @@
|
||||||
*/
|
*/
|
||||||
int fdt_remove_unused_strings(const void *old, void *new);
|
int fdt_remove_unused_strings(const void *old, void *new);
|
||||||
|
|
||||||
int fit_check_sign(const void *working_fdt, const void *key);
|
int fit_check_sign(const void *working_fdt, const void *key, int is_spl);
|
||||||
|
|
||||||
#endif /* __FDT_HOST_H__ */
|
#endif /* __FDT_HOST_H__ */
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,11 @@ int main(int argc, char **argv)
|
||||||
int ret;
|
int ret;
|
||||||
void *key_blob;
|
void *key_blob;
|
||||||
int c;
|
int c;
|
||||||
|
int is_spl = 0;
|
||||||
|
|
||||||
strncpy(cmdname, *argv, sizeof(cmdname) - 1);
|
strncpy(cmdname, *argv, sizeof(cmdname) - 1);
|
||||||
cmdname[sizeof(cmdname) - 1] = '\0';
|
cmdname[sizeof(cmdname) - 1] = '\0';
|
||||||
while ((c = getopt(argc, argv, "f:k:")) != -1)
|
while ((c = getopt(argc, argv, "f:k:s")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'f':
|
case 'f':
|
||||||
fdtfile = optarg;
|
fdtfile = optarg;
|
||||||
|
|
@ -57,6 +58,9 @@ int main(int argc, char **argv)
|
||||||
case 'k':
|
case 'k':
|
||||||
keyfile = optarg;
|
keyfile = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
is_spl = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(cmdname);
|
usage(cmdname);
|
||||||
break;
|
break;
|
||||||
|
|
@ -79,7 +83,7 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
image_set_host_blob(key_blob);
|
image_set_host_blob(key_blob);
|
||||||
ret = fit_check_sign(fit_blob, key_blob);
|
ret = fit_check_sign(fit_blob, key_blob, is_spl);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
fprintf(stderr, "Signature check OK\n");
|
fprintf(stderr, "Signature check OK\n");
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,7 @@ int fit_add_verification_data(const char *keydir, void *keydest, void *fit,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_FIT_SIGNATURE
|
#ifdef CONFIG_FIT_SIGNATURE
|
||||||
int fit_check_sign(const void *fit, const void *key)
|
int fit_check_sign(const void *fit, const void *key, int is_spl)
|
||||||
{
|
{
|
||||||
int cfg_noffset;
|
int cfg_noffset;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -741,7 +741,7 @@ int fit_check_sign(const void *fit, const void *key)
|
||||||
ret = fit_config_verify(fit, cfg_noffset);
|
ret = fit_config_verify(fit, cfg_noffset);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = bootm_host_load_images(fit, cfg_noffset);
|
ret = bootm_host_load_images(fit, cfg_noffset, is_spl);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue