Esempio n. 1
0
static int kwbimage_generate(struct image_tool_params *params,
                             struct image_type_params *tparams)
{
    int alloc_len;
    void *hdr;
    int version = 0;

    version = image_version_file(params->imagename);
    if (version == 0) {
        alloc_len = sizeof(struct main_hdr_v0) +
                    sizeof(struct ext_hdr_v0);
    } else {
        alloc_len = image_headersz_v1(params, NULL);
    }

    hdr = malloc(alloc_len);
    if (!hdr) {
        fprintf(stderr, "%s: malloc return failure: %s\n",
                params->cmdname, strerror(errno));
        exit(EXIT_FAILURE);
    }

    memset(hdr, 0, alloc_len);
    tparams->header_size = alloc_len;
    tparams->hdr = hdr;

    return 0;
}
Esempio n. 2
0
static int kwbimage_generate(struct image_tool_params *params,
			     struct image_type_params *tparams)
{
	int alloc_len;
	void *hdr;
	int version = 0;

	version = image_version_file(params->imagename);
	if (version == 0) {
		alloc_len = sizeof(struct main_hdr_v0) +
			sizeof(struct ext_hdr_v0);
	} else {
		alloc_len = image_headersz_v1(params, NULL);
#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
		if (alloc_len > CONFIG_SYS_SPI_U_BOOT_OFFS) {
			fprintf(stderr, "Error: Image header (incl. SPL image) too big!\n");
			fprintf(stderr, "header=0x%x CONFIG_SYS_SPI_U_BOOT_OFFS=0x%x!\n",
				alloc_len, CONFIG_SYS_SPI_U_BOOT_OFFS);
			fprintf(stderr, "Increase CONFIG_SYS_SPI_U_BOOT_OFFS!\n");
		} else {
			alloc_len = CONFIG_SYS_SPI_U_BOOT_OFFS;
		}
#endif
	}

	hdr = malloc(alloc_len);
	if (!hdr) {
		fprintf(stderr, "%s: malloc return failure: %s\n",
			params->cmdname, strerror(errno));
		exit(EXIT_FAILURE);
	}

	memset(hdr, 0, alloc_len);
	tparams->header_size = alloc_len;
	tparams->hdr = hdr;

	return 0;
}
Esempio n. 3
0
static int kwbimage_generate(struct image_tool_params *params,
			     struct image_type_params *tparams)
{
	int alloc_len;
	void *hdr;
	int version = 0;

	version = image_version_file(params->imagename);
	if (version == 0) {
		alloc_len = sizeof(struct main_hdr_v0) +
			sizeof(struct ext_hdr_v0);
	} else {
		alloc_len = image_headersz_v1(params, NULL);
	}

	hdr = malloc(alloc_len);
	if (!hdr) {
		fprintf(stderr, "%s: malloc return failure: %s\n",
			params->cmdname, strerror(errno));
		exit(EXIT_FAILURE);
	}

	memset(hdr, 0, alloc_len);
	tparams->header_size = alloc_len;
	tparams->hdr = hdr;

	/*
	 * The resulting image needs to be 4-byte aligned. At least
	 * the Marvell hdrparser tool complains if its unaligned.
	 * By returning 1 here in this function, called via
	 * tparams->vrec_header() in mkimage.c, mkimage will
	 * automatically pad the the resulting image to a 4-byte
	 * size if necessary.
	 */
	return 1;
}