int fit_get_node_from_config(bootm_headers_t *images, const char *prop_name, ulong addr) { int cfg_noffset; void *fit_hdr; int noffset; debug("* %s: using config '%s' from image at 0x%08lx\n", prop_name, images->fit_uname_cfg, addr); /* Check whether configuration has this property defined */ fit_hdr = map_sysmem(addr, 0); cfg_noffset = fit_conf_get_node(fit_hdr, images->fit_uname_cfg); if (cfg_noffset < 0) { debug("* %s: no such config\n", prop_name); return -ENOENT; } noffset = fit_conf_get_prop_node(fit_hdr, cfg_noffset, prop_name); if (noffset < 0) { debug("* %s: no '%s' in config\n", prop_name, prop_name); return -ENOLINK; } return noffset; }
int fit_check_sign(const void *working_fdt, const void *key) { int cfg_noffset; int ret; cfg_noffset = fit_conf_get_node(working_fdt, NULL); if (!cfg_noffset) return -1; ret = fit_config_verify(working_fdt, cfg_noffset); return ret; }
int fit_check_sign(const void *fit, const void *key) { int cfg_noffset; int ret; cfg_noffset = fit_conf_get_node(fit, NULL); if (!cfg_noffset) return -1; printf("Verifying Hash Integrity ... "); ret = fit_config_verify(fit, cfg_noffset); if (ret) return ret; ret = bootm_host_load_images(fit, cfg_noffset); return ret; }
static int sec_firmware_get_data(const void *sec_firmware_img, const void **data, size_t *size) { int conf_node_off, fw_node_off; char *conf_node_name = NULL; char *desc; int ret; conf_node_name = SEC_FIRMEWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(sec_firmware_img, conf_node_name); if (conf_node_off < 0) { printf("SEC Firmware: %s: no such config\n", conf_node_name); return -ENOENT; } fw_node_off = fit_conf_get_prop_node(sec_firmware_img, conf_node_off, SEC_FIRMWARE_FIT_IMAGE); if (fw_node_off < 0) { printf("SEC Firmware: No '%s' in config\n", SEC_FIRMWARE_FIT_IMAGE); return -ENOLINK; } /* Verify secure firmware image */ if (!(fit_image_verify(sec_firmware_img, fw_node_off))) { printf("SEC Firmware: Bad firmware image (bad CRC)\n"); return -EINVAL; } if (fit_image_get_data(sec_firmware_img, fw_node_off, data, size)) { printf("SEC Firmware: Can't get %s subimage data/size", SEC_FIRMWARE_FIT_IMAGE); return -ENOENT; } ret = fit_get_desc(sec_firmware_img, fw_node_off, &desc); if (ret) printf("SEC Firmware: Can't get description\n"); else printf("%s\n", desc); return ret; }
/* * Get PFE firmware from FIT image * * @param data pointer to PFE firmware * @param size pointer to size of the firmware * @param fw_name pfe firmware name, either class or tmu * * @return 0 on success, a negative value on error */ static int pfe_get_fw(const void **data, size_t *size, char *fw_name) { int conf_node_off, fw_node_off; char *conf_node_name = NULL; char *desc; int ret = 0; conf_node_name = PFE_FIRMEWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(pfe_fit_addr, conf_node_name); if (conf_node_off < 0) { printf("PFE Firmware: %s: no such config\n", conf_node_name); return -ENOENT; } fw_node_off = fit_conf_get_prop_node(pfe_fit_addr, conf_node_off, fw_name); if (fw_node_off < 0) { printf("PFE Firmware: No '%s' in config\n", fw_name); return -ENOLINK; } if (!(fit_image_verify(pfe_fit_addr, fw_node_off))) { printf("PFE Firmware: Bad firmware image (bad CRC)\n"); return -EINVAL; } if (fit_image_get_data(pfe_fit_addr, fw_node_off, data, size)) { printf("PFE Firmware: Can't get %s subimage data/size", fw_name); return -ENOENT; } ret = fit_get_desc(pfe_fit_addr, fw_node_off, &desc); if (ret) printf("PFE Firmware: Can't get description\n"); else printf("%s\n", desc); return ret; }
int fit_image_load(bootm_headers_t *images, const char *prop_name, 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) { int cfg_noffset, noffset; const char *fit_uname; const char *fit_uname_config; const void *fit; const void *buf; size_t size; int type_ok, os_ok; ulong load, data, len; int ret; fit = map_sysmem(addr, 0); fit_uname = fit_unamep ? *fit_unamep : NULL; fit_uname_config = fit_uname_configp ? *fit_uname_configp : NULL; printf("## Loading %s from FIT Image at %08lx ...\n", prop_name, addr); bootstage_mark(bootstage_id + BOOTSTAGE_SUB_FORMAT); if (!fit_check_format(fit)) { printf("Bad FIT %s image format!\n", prop_name); bootstage_error(bootstage_id + BOOTSTAGE_SUB_FORMAT); return -ENOEXEC; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_FORMAT_OK); if (fit_uname) { /* get ramdisk component image node offset */ bootstage_mark(bootstage_id + BOOTSTAGE_SUB_UNIT_NAME); noffset = fit_image_get_node(fit, fit_uname); } else { /* * no image node unit name, try to get config * node first. If config unit node name is NULL * fit_conf_get_node() will try to find default config node */ bootstage_mark(bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME); if (IMAGE_ENABLE_BEST_MATCH && !fit_uname_config) { cfg_noffset = fit_conf_find_compat(fit, gd_fdt_blob()); } else { cfg_noffset = fit_conf_get_node(fit, fit_uname_config); } if (cfg_noffset < 0) { puts("Could not find configuration node\n"); bootstage_error(bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME); return -ENOENT; } fit_uname_config = fdt_get_name(fit, cfg_noffset, NULL); printf(" Using '%s' configuration\n", fit_uname_config); if (image_type == IH_TYPE_KERNEL) { /* Remember (and possibly verify) this config */ images->fit_uname_cfg = fit_uname_config; if (IMAGE_ENABLE_VERIFY && images->verify) { puts(" Verifying Hash Integrity ... "); if (!fit_config_verify(fit, cfg_noffset)) { puts("Bad Data Hash\n"); bootstage_error(bootstage_id + BOOTSTAGE_SUB_HASH); return -EACCES; } puts("OK\n"); } bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG); } noffset = fit_conf_get_prop_node(fit, cfg_noffset, prop_name); fit_uname = fit_get_name(fit, noffset, NULL); } if (noffset < 0) { puts("Could not find subimage node\n"); bootstage_error(bootstage_id + BOOTSTAGE_SUB_SUBNODE); return -ENOENT; } printf(" Trying '%s' %s subimage\n", fit_uname, prop_name); ret = fit_image_select(fit, noffset, images->verify); if (ret) { bootstage_error(bootstage_id + BOOTSTAGE_SUB_HASH); return ret; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); if (!fit_image_check_target_arch(fit, noffset)) { puts("Unsupported Architecture\n"); bootstage_error(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); return -ENOEXEC; } if (image_type == IH_TYPE_FLATDT && !fit_image_check_comp(fit, noffset, IH_COMP_NONE)) { puts("FDT image is compressed"); return -EPROTONOSUPPORT; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL); type_ok = fit_image_check_type(fit, noffset, image_type) || (image_type == IH_TYPE_KERNEL && fit_image_check_type(fit, noffset, IH_TYPE_KERNEL_NOLOAD)); os_ok = image_type == IH_TYPE_FLATDT || fit_image_check_os(fit, noffset, IH_OS_LINUX); if (!type_ok || !os_ok) { printf("No Linux %s %s Image\n", genimg_get_arch_name(arch), genimg_get_type_name(image_type)); bootstage_error(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL); return -EIO; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK); /* get image data address and length */ if (fit_image_get_data(fit, noffset, &buf, &size)) { printf("Could not find %s subimage data!\n", prop_name); bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA); return -ENOENT; } len = (ulong)size; /* verify that image data is a proper FDT blob */ if (image_type == IH_TYPE_FLATDT && fdt_check_header((char *)buf)) { puts("Subimage data is not a FDT"); return -ENOEXEC; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_GET_DATA_OK); /* * Work-around for eldk-4.2 which gives this warning if we try to * case in the unmap_sysmem() call: * warning: initialization discards qualifiers from pointer target type */ { void *vbuf = (void *)buf; data = map_to_sysmem(vbuf); } if (load_op == FIT_LOAD_IGNORED) { /* Don't load */ } else if (fit_image_get_load(fit, noffset, &load)) { if (load_op == FIT_LOAD_REQUIRED) { printf("Can't get %s subimage load address!\n", prop_name); bootstage_error(bootstage_id + BOOTSTAGE_SUB_LOAD); return -EBADF; } } else { ulong image_start, image_end; ulong load_end; void *dst; /* * move image data to the load address, * make sure we don't overwrite initial image */ image_start = addr; image_end = addr + fit_get_size(fit); load_end = load + len; if (image_type != IH_TYPE_KERNEL && load < image_end && load_end > image_start) { printf("Error: %s overwritten\n", prop_name); return -EXDEV; } printf(" Loading %s from 0x%08lx to 0x%08lx\n", prop_name, data, load); dst = map_sysmem(load, len); memmove(dst, buf, len); data = load; } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_LOAD); *datap = data; *lenp = len; if (fit_unamep) *fit_unamep = (char *)fit_uname; if (fit_uname_configp) *fit_uname_configp = (char *)fit_uname_config; return noffset; }
/** * boot_get_kernel - find kernel image * @os_data: pointer to a ulong variable, will hold os data start address * @os_len: pointer to a ulong variable, will hold os data length * * boot_get_kernel() tries to find a kernel image, verifies its integrity * and locates kernel data. * * returns: * pointer to image header if valid image was found, plus kernel start * address and length, otherwise NULL */ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images, ulong *os_data, ulong *os_len) { image_header_t *hdr; ulong img_addr; #if defined(CONFIG_FIT) void *fit_hdr; const char *fit_uname_config = NULL; const char *fit_uname_kernel = NULL; const void *data; size_t len; int cfg_noffset; int os_noffset; #endif /* find out kernel image address */ if (argc < 2) { img_addr = load_addr; debug ("* kernel: default image load address = 0x%08lx\n", load_addr); #if defined(CONFIG_FIT) } else if (fit_parse_conf (argv[1], load_addr, &img_addr, &fit_uname_config)) { debug ("* kernel: config '%s' from image at 0x%08lx\n", fit_uname_config, img_addr); } else if (fit_parse_subimage (argv[1], load_addr, &img_addr, &fit_uname_kernel)) { debug ("* kernel: subimage '%s' from image at 0x%08lx\n", fit_uname_kernel, img_addr); #endif } else { img_addr = simple_strtoul(argv[1], NULL, 16); debug ("* kernel: cmdline image address = 0x%08lx\n", img_addr); } show_boot_progress (1); /* copy from dataflash if needed */ img_addr = genimg_get_image (img_addr); /* check image type, for FIT images get FIT kernel node */ *os_data = *os_len = 0; switch (genimg_get_format ((void *)img_addr)) { case IMAGE_FORMAT_LEGACY: printf ("## Booting kernel from Legacy Image at %08lx ...\n", img_addr); hdr = image_get_kernel (img_addr, images->verify); if (!hdr) return NULL; show_boot_progress (5); /* get os_data and os_len */ switch (image_get_type (hdr)) { case IH_TYPE_KERNEL: *os_data = image_get_data (hdr); *os_len = image_get_data_size (hdr); break; case IH_TYPE_MULTI: image_multi_getimg (hdr, 0, os_data, os_len); break; case IH_TYPE_STANDALONE: if (argc >2) { hdr->ih_load = htonl(simple_strtoul(argv[2], NULL, 16)); } *os_data = image_get_data (hdr); *os_len = image_get_data_size (hdr); break; default: printf ("Wrong Image Type for %s command\n", cmdtp->name); show_boot_progress (-5); return NULL; } /* * copy image header to allow for image overwrites during kernel * decompression. */ memmove (&images->legacy_hdr_os_copy, hdr, sizeof(image_header_t)); /* save pointer to image header */ images->legacy_hdr_os = hdr; images->legacy_hdr_valid = 1; show_boot_progress (6); break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: fit_hdr = (void *)img_addr; printf ("## Booting kernel from FIT Image at %08lx ...\n", img_addr); if (!fit_check_format (fit_hdr)) { puts ("Bad FIT kernel image format!\n"); show_boot_progress (-100); return NULL; } show_boot_progress (100); if (!fit_uname_kernel) { /* * no kernel image node unit name, try to get config * node first. If config unit node name is NULL * fit_conf_get_node() will try to find default config node */ show_boot_progress (101); cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config); if (cfg_noffset < 0) { show_boot_progress (-101); return NULL; } /* save configuration uname provided in the first * bootm argument */ images->fit_uname_cfg = fdt_get_name (fit_hdr, cfg_noffset, NULL); printf (" Using '%s' configuration\n", images->fit_uname_cfg); show_boot_progress (103); os_noffset = fit_conf_get_kernel_node (fit_hdr, cfg_noffset); fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL); } else { /* get kernel component image node offset */ show_boot_progress (102); os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel); } if (os_noffset < 0) { show_boot_progress (-103); return NULL; } printf (" Trying '%s' kernel subimage\n", fit_uname_kernel); show_boot_progress (104); if (!fit_check_kernel (fit_hdr, os_noffset, images->verify)) return NULL; /* get kernel image data address and length */ if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) { puts ("Could not find kernel subimage data!\n"); show_boot_progress (-107); return NULL; } show_boot_progress (108); *os_len = len; *os_data = (ulong)data; images->fit_hdr_os = fit_hdr; images->fit_uname_os = fit_uname_kernel; images->fit_noffset_os = os_noffset; break; #endif default: printf ("Wrong Image Format for %s command\n", cmdtp->name); show_boot_progress (-108); return NULL; } debug (" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n", *os_data, *os_len, *os_len); return (void *)img_addr; }
/** * boot_get_kernel - find kernel image * @os_data: pointer to a ulong variable, will hold os data start address * @os_len: pointer to a ulong variable, will hold os data length * * boot_get_kernel() tries to find a kernel image, verifies its integrity * and locates kernel data. * * returns: * pointer to image header if valid image was found, plus kernel start * address and length, otherwise NULL */ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], bootm_headers_t *images, ulong *os_data, ulong *os_len) { image_header_t *hdr; ulong img_addr; const void *buf; #if defined(CONFIG_FIT) const void *fit_hdr; const char *fit_uname_config = NULL; const char *fit_uname_kernel = NULL; const void *data; size_t len; int cfg_noffset; int os_noffset; #endif /* find out kernel image address */ if (argc < 2) { img_addr = load_addr; debug("* kernel: default image load address = 0x%08lx\n", load_addr); #if defined(CONFIG_FIT) } else if (fit_parse_conf(argv[1], load_addr, &img_addr, &fit_uname_config)) { debug("* kernel: config '%s' from image at 0x%08lx\n", fit_uname_config, img_addr); } else if (fit_parse_subimage(argv[1], load_addr, &img_addr, &fit_uname_kernel)) { debug("* kernel: subimage '%s' from image at 0x%08lx\n", fit_uname_kernel, img_addr); #endif } else { img_addr = simple_strtoul(argv[1], NULL, 16); debug("* kernel: cmdline image address = 0x%08lx\n", img_addr); } bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC); /* copy from dataflash if needed */ img_addr = genimg_get_image(img_addr); /* check image type, for FIT images get FIT kernel node */ *os_data = *os_len = 0; buf = map_sysmem(img_addr, 0); switch (genimg_get_format(buf)) { case IMAGE_FORMAT_LEGACY: printf("## Booting kernel from Legacy Image at %08lx ...\n", img_addr); hdr = image_get_kernel(img_addr, images->verify); if (!hdr) return NULL; bootstage_mark(BOOTSTAGE_ID_CHECK_IMAGETYPE); /* get os_data and os_len */ switch (image_get_type(hdr)) { case IH_TYPE_KERNEL: case IH_TYPE_KERNEL_NOLOAD: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break; case IH_TYPE_MULTI: image_multi_getimg(hdr, 0, os_data, os_len); break; case IH_TYPE_STANDALONE: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break; default: printf("Wrong Image Type for %s command\n", cmdtp->name); bootstage_error(BOOTSTAGE_ID_CHECK_IMAGETYPE); return NULL; } /* * copy image header to allow for image overwrites during * kernel decompression. */ memmove(&images->legacy_hdr_os_copy, hdr, sizeof(image_header_t)); /* save pointer to image header */ images->legacy_hdr_os = hdr; images->legacy_hdr_valid = 1; bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE); break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: fit_hdr = buf; printf("## Booting kernel from FIT Image at %08lx ...\n", img_addr); if (!fit_check_format(fit_hdr)) { puts("Bad FIT kernel image format!\n"); bootstage_error(BOOTSTAGE_ID_FIT_FORMAT); return NULL; } bootstage_mark(BOOTSTAGE_ID_FIT_FORMAT); if (!fit_uname_kernel) { /* * no kernel image node unit name, try to get config * node first. If config unit node name is NULL * fit_conf_get_node() will try to find default config * node */ bootstage_mark(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); #ifdef CONFIG_FIT_BEST_MATCH if (fit_uname_config) cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); else cfg_noffset = fit_conf_find_compat(fit_hdr, gd->fdt_blob); #else cfg_noffset = fit_conf_get_node(fit_hdr, fit_uname_config); #endif if (cfg_noffset < 0) { bootstage_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); return NULL; } /* save configuration uname provided in the first * bootm argument */ images->fit_uname_cfg = fdt_get_name(fit_hdr, cfg_noffset, NULL); printf(" Using '%s' configuration\n", images->fit_uname_cfg); bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG); os_noffset = fit_conf_get_kernel_node(fit_hdr, cfg_noffset); fit_uname_kernel = fit_get_name(fit_hdr, os_noffset, NULL); } else { /* get kernel component image node offset */ bootstage_mark(BOOTSTAGE_ID_FIT_UNIT_NAME); os_noffset = fit_image_get_node(fit_hdr, fit_uname_kernel); } if (os_noffset < 0) { bootstage_error(BOOTSTAGE_ID_FIT_CONFIG); return NULL; } printf(" Trying '%s' kernel subimage\n", fit_uname_kernel); bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); if (!fit_check_kernel(fit_hdr, os_noffset, images->verify)) return NULL; /* get kernel image data address and length */ if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { puts("Could not find kernel subimage data!\n"); bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); return NULL; } bootstage_mark(BOOTSTAGE_ID_FIT_KERNEL_INFO); *os_len = len; *os_data = (ulong)data; images->fit_hdr_os = (void *)fit_hdr; images->fit_uname_os = fit_uname_kernel; images->fit_noffset_os = os_noffset; break; #endif default: printf("Wrong Image Format for %s command\n", cmdtp->name); bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO); return NULL; } debug(" kernel data at 0x%08lx, len = 0x%08lx (%ld)\n", *os_data, *os_len, *os_len); return buf; }
int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, const ulong *ld_start, ulong * const ld_len) { /* * These variables are used to hold the current image location * in system memory. */ ulong tmp_img_addr; /* * These two variables are requirements for fit_image_load, but * their values are not used */ ulong img_data, img_len; void *buf; int loadables_index; int conf_noffset; int fit_img_result; char *uname; /* Check to see if the images struct has a FIT configuration */ if (!genimg_has_config(images)) { debug("## FIT configuration was not specified\n"); return 0; } /* * Obtain the os FIT header from the images struct * copy from dataflash if needed */ tmp_img_addr = map_to_sysmem(images->fit_hdr_os); tmp_img_addr = genimg_get_image(tmp_img_addr); buf = map_sysmem(tmp_img_addr, 0); /* * Check image type. For FIT images get FIT node * and attempt to locate a generic binary. */ switch (genimg_get_format(buf)) { case IMAGE_FORMAT_FIT: conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg); for (loadables_index = 0; fdt_get_string_index(buf, conf_noffset, FIT_LOADABLE_PROP, loadables_index, (const char **)&uname) == 0; loadables_index++) { fit_img_result = fit_image_load(images, tmp_img_addr, (const char **)&uname, &(images->fit_uname_cfg), arch, IH_TYPE_LOADABLE, BOOTSTAGE_ID_FIT_LOADABLE_START, FIT_LOAD_OPTIONAL_NON_ZERO, &img_data, &img_len); if (fit_img_result < 0) { /* Something went wrong! */ return fit_img_result; } } break; default: printf("The given image format is not supported (corrupt?)\n"); return 1; } return 0; }
int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, const ulong *ld_start, ulong * const ld_len) { ulong tmp_img_addr, img_data, img_len; void *buf; int conf_noffset; int fit_img_result; char *uname, *name; int err; int devnum = 0; /* TODO support multi fpga platforms */ const fpga_desc * const desc = fpga_get_desc(devnum); xilinx_desc *desc_xilinx = desc->devdesc; /* Check to see if the images struct has a FIT configuration */ if (!genimg_has_config(images)) { debug("## FIT configuration was not specified\n"); return 0; } /* * Obtain the os FIT header from the images struct * copy from dataflash if needed */ tmp_img_addr = map_to_sysmem(images->fit_hdr_os); tmp_img_addr = genimg_get_image(tmp_img_addr); buf = map_sysmem(tmp_img_addr, 0); /* * Check image type. For FIT images get FIT node * and attempt to locate a generic binary. */ switch (genimg_get_format(buf)) { case IMAGE_FORMAT_FIT: conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg); err = fdt_get_string_index(buf, conf_noffset, FIT_FPGA_PROP, 0, (const char **)&uname); if (err < 0) { debug("## FPGA image is not specified\n"); return 0; } fit_img_result = fit_image_load(images, tmp_img_addr, (const char **)&uname, &(images->fit_uname_cfg), arch, IH_TYPE_FPGA, BOOTSTAGE_ID_FPGA_INIT, FIT_LOAD_OPTIONAL_NON_ZERO, &img_data, &img_len); debug("FPGA image (%s) loaded to 0x%lx/size 0x%lx\n", uname, img_data, img_len); if (fit_img_result < 0) { /* Something went wrong! */ return fit_img_result; } if (img_len >= desc_xilinx->size) { name = "full"; err = fpga_loadbitstream(devnum, (char *)img_data, img_len, BIT_FULL); if (err) err = fpga_load(devnum, (const void *)img_data, img_len, BIT_FULL); } else { name = "partial"; err = fpga_loadbitstream(devnum, (char *)img_data, img_len, BIT_PARTIAL); if (err) err = fpga_load(devnum, (const void *)img_data, img_len, BIT_PARTIAL); } printf(" Programming %s bitstream... ", name); if (err) printf("failed\n"); else printf("OK\n"); break; default: printf("The given image format is not supported (corrupt?)\n"); return 1; } return 0; }