diff --git a/scripts/imx/Makefile b/scripts/imx/Makefile index be0b490..ee0acc1 100644 --- a/scripts/imx/Makefile +++ b/scripts/imx/Makefile @@ -6,5 +6,7 @@ HOSTCFLAGS_imx-usb-loader.o = `pkg-config --cflags libusb-1.0` HOSTLOADLIBES_imx-usb-loader = `pkg-config --libs libusb-1.0` +HOSTCFLAGS_imx-image.o = -I$(srctree) + imx-usb-loader-objs := imx-usb-loader.o imx-image-objs := imx-image.o diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 25ea4d8..e765c1d 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -27,6 +27,8 @@ #include #include +#include + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) @@ -91,9 +93,12 @@ { struct imx_flash_header *hdr; int dcdsize = curdcd * sizeof(uint32_t); + uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET; - if (add_barebox_header) + if (add_barebox_header) { memcpy(buf, bb_header, sizeof(bb_header)); + *psize = imagesize; + } buf += offset; hdr = buf; @@ -177,6 +182,7 @@ { struct imx_flash_header_v2 *hdr; int dcdsize = curdcd * sizeof(uint32_t); + uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET; if (add_barebox_header) memcpy(buf, bb_header, sizeof(bb_header)); @@ -201,6 +207,9 @@ hdr->boot_data.size += CSF_LEN; } + if (add_barebox_header) + *psize = hdr->boot_data.size; + hdr->dcd_header.tag = TAG_DCD_HEADER; hdr->dcd_header.length = htobe16(sizeof(uint32_t) + dcdsize); hdr->dcd_header.version = DCD_VERSION;