[PATCH 01/20] scripts: imx-image: Only set DCD pointer when we have DCD data

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 23 09:15:47 EDT 2020


When we do not have any DCD data we can set the pointer to the
data to NULL.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 scripts/imx/imx-image.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index ec7444a772..2481ae6403 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -329,7 +329,8 @@ static size_t add_header_v2(const struct config_data *data, void *buf)
 	hdr->header.version	= IVT_VERSION;
 
 	hdr->entry		= loadaddr + HEADER_LEN;
-	hdr->dcd_ptr		= loadaddr + offset + offsetof(struct imx_flash_header_v2, dcd_header);
+	if (dcdsize)
+		hdr->dcd_ptr = loadaddr + offset + offsetof(struct imx_flash_header_v2, dcd_header);
 	if (create_usb_image) {
 		dcd_ptr_content = hdr->dcd_ptr;
 		dcd_ptr_offset = offsetof(struct imx_flash_header_v2, dcd_ptr) + offset;
@@ -357,13 +358,14 @@ static size_t add_header_v2(const struct config_data *data, void *buf)
 		hdr->boot_data.size += CSF_LEN;
 	}
 
-	hdr->dcd_header.tag	= TAG_DCD_HEADER;
-	hdr->dcd_header.length	= htobe16(sizeof(uint32_t) + dcdsize);
-	hdr->dcd_header.version	= DCD_VERSION;
-
 	buf += sizeof(*hdr);
 
-	memcpy(buf, dcdtable, dcdsize);
+	if (dcdsize) {
+		hdr->dcd_header.tag	= TAG_DCD_HEADER;
+		hdr->dcd_header.length	= htobe16(sizeof(uint32_t) + dcdsize);
+		hdr->dcd_header.version	= DCD_VERSION;
+		memcpy(buf, dcdtable, dcdsize);
+	}
 
 	return imagesize;
 }
-- 
2.27.0




More information about the barebox mailing list