Current implementation requires to provide the name of the FPGA image
within the FIT image. As the configuration node is mandatory according
to the spec and includes an optional property "fpga" to define the
bitstream image, use this approach instead.

This way there is no need for an additional information in the loadmk
command for FIT, and signature and hash verification of both the image
and configuration is performed.

Signed-off-by: Ibai Erkiaga <[email protected]>
---

 cmd/fpga.c | 46 ++++++++++++++++------------------------------
 1 file changed, 16 insertions(+), 30 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 9dc7b63db5d..7ff8802dd77 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -238,10 +238,6 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int flag, 
int argc,
 {
        size_t data_size = 0;
        void *fpga_data = NULL;
-#if defined(CONFIG_FIT)
-       const char *fit_uname = NULL;
-       ulong fit_addr;
-#endif
        ulong dev = do_fpga_get_device(argv[0]);
        char *datastr = env_get("fpgadata");
 
@@ -265,20 +261,10 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int 
flag, int argc,
                datastr = argv[0];
        }
 
-#if defined(CONFIG_FIT)
-       if (fit_parse_subimage(datastr, (ulong)fpga_data,
-                              &fit_addr, &fit_uname)) {
-               fpga_data = (void *)fit_addr;
-               debug("*  fpga: subimage '%s' from FIT image ",
-                     fit_uname);
-               debug("at 0x%08lx\n", fit_addr);
-       } else
-#endif
-       {
-               fpga_data = (void *)hextoul(datastr, NULL);
-               debug("*  fpga: cmdline image address = 0x%08lx\n",
+       fpga_data = (void *)hextoul(datastr, NULL);
+       debug("*  fpga: cmdline image address = 0x%08lx\n",
                      (ulong)fpga_data);
-       }
+
        debug("%s: fpga_data = 0x%lx\n", __func__, (ulong)fpga_data);
        if (!fpga_data) {
                puts("Zero fpga_data address\n");
@@ -323,24 +309,28 @@ static int do_fpga_loadmk(struct cmd_tbl *cmdtp, int 
flag, int argc,
        case IMAGE_FORMAT_FIT:
        {
                const void *fit_hdr = (const void *)fpga_data;
-               int err;
                const void *fit_data;
+               int err;
+               int noffset;
 
-               if (!fit_uname) {
-                       puts("No FIT subimage unit name\n");
+               noffset = fit_conf_get_node(fit_hdr, NULL);
+               if (noffset < 0) {
+                       log_err("Could not find default config node, err:%d\n",
+                               noffset);
                        return CMD_RET_FAILURE;
                }
 
-               if (fit_check_format(fit_hdr, IMAGE_SIZE_INVAL)) {
-                       puts("Bad FIT image format\n");
+               err = (fit_config_verify(fit_hdr, noffset));
+               if (err) {
+                       log_err("Configuration node verification failed, 
err:%d\n",
+                               err);
                        return CMD_RET_FAILURE;
                }
 
-               err = fit_get_data_node(fit_hdr, fit_uname, &fit_data,
-                                       &data_size);
+               err = fit_get_data_conf_prop(fit_hdr, "fpga", &fit_data,
+                                            &data_size);
                if (err) {
-                       printf("Could not load '%s' subimage (err %d)\n",
-                              fit_uname, err);
+                       log_err("Could not find fpga image, err:%d\n", err);
                        return CMD_RET_FAILURE;
                }
 
@@ -433,10 +423,6 @@ U_BOOT_CMD(fpga, 6, 1, do_fpga_wrapper,
 #endif
 #if defined(CONFIG_CMD_FPGA_LOADMK)
         "fpga loadmk <dev> <address>        Load device generated with 
mkimage\n"
-#if defined(CONFIG_FIT)
-        "            NOTE: loadmk operating on FIT must include subimage 
unit\n"
-        "            name in the form of addr:<subimg_uname>\n"
-#endif
 #endif
 #if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
         "fpga loads  <dev> <address> <size> <authflag> <encflag> [Userkey 
address]\n"
-- 
2.42.0.325.g3a06386e31

Reply via email to