Skip to contentSkip to conversation

common: fitimage support for arbitrary fpga type

PATCH Superseded Dalon Westergreen 2 participants 6 messages Feb 20, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover common: fitimage support for arbitrary fpga type

The intent of these patches is to modify existing fitimage support for fpga configuration to allow configuration of any fpga type supported by the fpga_load command.

In the fpga node, two additional optional parameters are used to indicate the fpga device number (for systems with multiple fpgas) and whether the fpga image is a full or partial image.

fpga-devnum: FPGA device number, defaults to 0
fpga-partial-image: 0 = full, other = partial, defaults to full

Changes in v2:
- Add support for devnum and partial
- for backward compatibility, do check of image size for xilinx to determine if the image is a partial image

Dalon Westergreen (2):
common: image: update boot_get_fpga to support arbitrary fpga image
common: bootm: add support for arbitrary fgpa configuration

 common/bootm.c     |  2 +-
 common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/image.c     | 51 ++++++++++++++++++++++++++++++++-------------------
 include/image.h    |  5 +++++
 4 files changed, 89 insertions(+), 20 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 common: image: update boot_get_fpga to support arbitrary fpga image

The implementation of boot_get_fpga only supported one fpga family. This modification allows for any of the fpga devices supported by fpga_load to be used.

--
Changes in v2:
- Add fitimage support for fpga-devnum and fpga-partial-image
- Use above in boot_get_fpga
- for xilinx fpgas double check using image size to determine if image is a partial image

---
 common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/image.c     | 51 ++++++++++++++++++++++++++++++++-------------------
 include/image.h    |  5 +++++
 3 files changed, 88 insertions(+), 19 deletions(-)
common/image-fit.c +51 -0
index 109ecfa..eb0c633 100644
@@ -916,6 +916,57 @@ ulong fit_get_end(const void *fit)
 }
 
 /**
+ * fit_image_fpga_get_devnum - get fpga devnum
+ * @fit: pointer to the FIT format image header
+ * @noffset: fpga node offset
+ * @devnum: pointer to an int, will hold fpga devnum
+ *
+ * fit_image_fpga_get_devnum() finds the fpga devnum for which the fpga data is
+ * intended.  If the property is not found, we default to 0.
+ *
+ * returns:
+ *     0, on devnum not found
+ *     value, on devnum found
+ */
+int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum)
+{
+	int len;
+	int *value;
+
+	value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_DEVNUM_PROP, &len);
+	if (value == NULL || len != sizeof(int))
+		*devnum = 0;
+	else
+		*devnum = *value;
+
+	return 0;
+}
+
+/**
+ * fit_image_fpga_is_partial - is partial fpga
+ * @fit: pointer to the FIT format image header
+ * @noffset: fpga node offset
+ *
+ * fit_image_fpga_is_partial() checks if the fpga node sets the property
+ * indicating the data represents a partial fpga image.
+ *
+ * returns:
+ *     0, on devnum not found
+ *     value, on devnum found
+ */
+int fit_image_fpga_is_partial(const void *fit, int noffset)
+{
+	int len;
+	int *value;
+
+	value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_PARTIAL_PROP, &len);
+	if ((value == NULL || len != sizeof(int)) || (value == 0))
+		return 0;
+	else
+		return 1;
+}
+
+/**
  * fit_set_timestamp - set node timestamp property
  * @fit: pointer to the FIT format image header
  * @noffset: node offset
common/image.c +32 -19

74 lines not on this page · raw message

include/image.h +5 -0
index 1e686b7..75d2afc 100644
@@ -876,6 +876,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 #define FIT_COMP_PROP		"compression"
 #define FIT_ENTRY_PROP		"entry"
 #define FIT_LOAD_PROP		"load"
+#define FIT_FPGA_DEVNUM_PROP	"fpga-devnum"
+#define FIT_FPGA_PARTIAL_PROP	"fpga-partial-image"
 
 /* configuration node */
 #define FIT_KERNEL_PROP		"kernel"
@@ -955,6 +957,9 @@ int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value,
 
 int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
 
+int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum);
+int fit_image_fpga_is_partial(const void *fit, int noffset);
+
 /**
  * fit_add_verification_data() - add verification data to FIT image nodes
  *
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/2 common: image: update boot_get_fpga to support arbitrary fpga image

Quoted 5 lines · Dalon Westergreen

The implementation of boot_get_fpga only supported one fpga family. This modification allows for any of the fpga devices supported by fpga_load to be used.

IMO looks OK, minor nits below

Quoted 110 lines

--
Changes in v2:
- Add fitimage support for fpga-devnum and fpga-partial-image
- Use above in boot_get_fpga
- for xilinx fpgas double check using image size to determine if image is a partial image

---
 common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/image.c     | 51 ++++++++++++++++++++++++++++++++-------------------
 include/image.h    |  5 +++++
 3 files changed, 88 insertions(+), 19 deletions(-)
common/image-fit.c +51 -0
index 109ecfa..eb0c633 100644
@@ -916,6 +916,57 @@ ulong fit_get_end(const void *fit)
 }
 
 /**
+ * fit_image_fpga_get_devnum - get fpga devnum
+ * @fit: pointer to the FIT format image header
+ * @noffset: fpga node offset
+ * @devnum: pointer to an int, will hold fpga devnum
+ *
+ * fit_image_fpga_get_devnum() finds the fpga devnum for which the fpga data is
+ * intended.  If the property is not found, we default to 0.
+ *
+ * returns:
+ *     0, on devnum not found
+ *     value, on devnum found
+ */
+int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum)
+{
+	int len;
+	int *value;
+
+	value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_DEVNUM_PROP, &len);
+	if (value == NULL || len != sizeof(int))
+		*devnum = 0;
+	else
+		*devnum = *value;
+
+	return 0;
+}
+
+/**
+ * fit_image_fpga_is_partial - is partial fpga
+ * @fit: pointer to the FIT format image header
+ * @noffset: fpga node offset
+ *
+ * fit_image_fpga_is_partial() checks if the fpga node sets the property
+ * indicating the data represents a partial fpga image.
+ *
+ * returns:
+ *     0, on devnum not found
+ *     value, on devnum found
+ */
+int fit_image_fpga_is_partial(const void *fit, int noffset)
+{
+	int len;
+	int *value;
+
+	value = (int *)fdt_getprop(fit, noffset, FIT_FPGA_PARTIAL_PROP, &len);
+	if ((value == NULL || len != sizeof(int)) || (value == 0))
+		return 0;
+	else
+		return 1;
+}
+
+/**
  * fit_set_timestamp - set node timestamp property
  * @fit: pointer to the FIT format image header
  * @noffset: node offset
common/image.c +5 -9
index 0f88984..6a3d2c3 100644
@@ -1306,7 +1306,7 @@ int boot_get_setup(bootm_headers_t *images, uint8_t arch,
 }
 
 #if IMAGE_ENABLE_FIT
-#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+#if defined(CONFIG_FPGA)
 int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
 		  uint8_t arch, const ulong *ld_start, ulong * const ld_len)
 {
@@ -1316,9 +1316,10 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
 	int fit_img_result;
 	const 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;
+	int devnum;
+	const fpga_desc *desc;
+	xilinx_desc *desc_xilinx;
+	bitstream_type bstype = BIT_FULL;
 
 	/* Check to see if the images struct has a FIT configuration */
 	if (!genimg_has_config(images)) {
@@ -1365,26 +1366,38 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
 			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)

common/image.c int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, · line 1369

Quoted 10 lines
common/image.c +1 -9
-				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);
+		/* Get fpga devnum, defaults to 0 */

FPGA in caps , s/devnum/device number/

common/image.c int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, · line 1372

Quoted 3 lines
common/image.c +3 -0
+		fit_image_fpga_get_devnum(buf, conf_noffset, &devnum);
+
+		/* check bitstream type */

At least start the sentence with capital letter please.

common/image.c int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, · line 1374

Quoted 2 lines
common/image.c +2 -0
+		if (fit_image_fpga_is_partial(buf, conf_noffset))
+			bstype = BIT_PARTIAL;

Are there any chances there will be something else besides full and partial in the future ?

common/image.c int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images, · line 1376

Quoted 1 line
common/image.c +1 -0
+		/* legacy support detecting partial config files for xilinx */

DTTO, start with caps.

Quoted 52 lines
common/image.c +19 -1
+		desc = fpga_get_desc(devnum);
+		if (desc->devtype == fpga_xilinx) {
+			desc_xilinx = desc->devdesc;
+			if (img_len < desc_xilinx->size)
+				bstype = BIT_PARTIAL;
 		}
 
+		/* Try bitstream format first */
+		err = fpga_loadbitstream(devnum, (char *)img_data,
+					 img_len, bstype);
+		if (err)
+			err = fpga_load(devnum, (const void *)img_data,
+					img_len, bstype);
+
 		if (err)
 			return err;
 
-		printf("   Programming %s bitstream... OK\n", name);
+		if (bstype == BIT_PARTIAL)
+			name = "partial";
+		else
+			name = "full";
+
+		printf("   Programming %s bitstream into fpga %d... OK\n",
+		       name, devnum);
 		break;
 	default:
 		printf("The given image format is not supported (corrupt?)\n");
include/image.h +5 -0
index 1e686b7..75d2afc 100644
@@ -876,6 +876,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end);
 #define FIT_COMP_PROP		"compression"
 #define FIT_ENTRY_PROP		"entry"
 #define FIT_LOAD_PROP		"load"
+#define FIT_FPGA_DEVNUM_PROP	"fpga-devnum"
+#define FIT_FPGA_PARTIAL_PROP	"fpga-partial-image"
 
 /* configuration node */
 #define FIT_KERNEL_PROP		"kernel"
@@ -955,6 +957,9 @@ int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value,
 
 int fit_set_timestamp(void *fit, int noffset, time_t timestamp);
 
+int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum);
+int fit_image_fpga_is_partial(const void *fit, int noffset);
+
 /**
  * fit_add_verification_data() - add verification data to FIT image nodes
  *
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v2 1/2 common: image: update boot_get_fpga to support arbitrary fpga image

Quoted 31 lines · Marek Vasut
Quoted 6 lines · Dalon Westergreen

The implementation of boot_get_fpga only supported one fpga family. This modification allows for any of the fpga devices supported by fpga_load to be used.

IMO looks OK, minor nits below

Quoted 21 lines

--
Changes in v2:
?- Add fitimage support for fpga-devnum and fpga-partial-image ?- Use above in boot_get_fpga
?- for xilinx fpgas double check using image size to determine ???if image is a partial image
---

?common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
?common/image.c?????| 51 ++++++++++++++++++++++++++++++++-------------------
?include/image.h????|??5 +++++

?3 files changed, 88 insertions(+), 19 deletions(-)

common/image-fit.c +0 -0
index 109ecfa..eb0c633 100644
@@ -916,6 +916,57 @@ ulong fit_get_end(const void *fit)
 ?}

?
?

[...]

Quoted 8 lines

common/image-fit.c

Quoted 4 lines
common/image-fit.c +3 -0
+		fit_image_fpga_get_devnum(buf, conf_noffset, &devnum);
+
+		/* check bitstream type */

At least start the sentence with capital letter please.

Quoted 1 line
Quoted 5 lines

common/image-fit.c

Quoted 2 lines
common/image-fit.c +2 -0
+		if (fit_image_fpga_is_partial(buf, conf_noffset))
+			bstype = BIT_PARTIAL;

Are there any chances there will be something else besides full and partial in the future ?

It's plausible but i think not a likely use case here. In Arria10 there is the periphery/core image that configures just the io or fpga core. ?I believe, though, that this is just a special case of a partial image and is treated the same.

--dalon

Quoted 64 lines
Quoted 4 lines
common/image-fit.c +1 -0
+		/* legacy support detecting partial config files for xilinx

*/

DTTO, start with caps.

Quoted 55 lines
common/image-fit.c +5 -0
+		desc = fpga_get_desc(devnum);
+		if (desc->devtype == fpga_xilinx) {
+			desc_xilinx = desc->devdesc;
+			if (img_len < desc_xilinx->size)
+				bstype = BIT_PARTIAL;

? }
?

common/image-fit.c +7 -0
+		/* Try bitstream format first */
+		err = fpga_loadbitstream(devnum, (char *)img_data,
+					?img_len, bstype);
+		if (err)
+			err = fpga_load(devnum, (const void *)img_data,
+					img_len, bstype);
+

? if (err)
? return err;
?

common/image-fit.c +7 -1
-		printf("???Programming %s bitstream... OK\n", name);
+		if (bstype == BIT_PARTIAL)
+			name = "partial";
+		else
+			name = "full";
+
+		printf("???Programming %s bitstream into fpga %d... OK\n",
+		???????name, devnum);

? break;
? default:
? printf("The given image format is not supported
(corrupt?)\n");

include/image.h +0 -0
index 1e686b7..75d2afc 100644
@@ -876,6 +876,8 @@ int bootz_setup(ulong image, ulong *start, ulong *end);

?#define FIT_COMP_PROP "compression"
?#define FIT_ENTRY_PROP "entry"
?#define FIT_LOAD_PROP "load"

include/image.h +2 -0
+#define FIT_FPGA_DEVNUM_PROP	"fpga-devnum"
+#define FIT_FPGA_PARTIAL_PROP	"fpga-partial-image"

?
?/* configuration node */
?#define FIT_KERNEL_PROP "kernel"

include/image.h +0 -0
@@ -955,6 +957,9 @@ int fit_image_hash_get_value(const void *fit, int
 noffset, uint8_t **value,

?
?int fit_set_timestamp(void *fit, int noffset, time_t timestamp); ?

include/image.h +3 -0
+int fit_image_fpga_get_devnum(const void *fit, int noffset, int *devnum);
+int fit_image_fpga_is_partial(const void *fit, int noffset);
+

?/**
? * fit_add_verification_data() - add verification data to FIT image nodes ? *

#4 lore raw

PATCH v2 1/2 common: image: update boot_get_fpga to support arbitrary fpga image

Quoted 47 lines · Dalon Westergreen
Quoted 31 lines · Marek Vasut
Quoted 6 lines · Dalon Westergreen

The implementation of boot_get_fpga only supported one fpga family. This modification allows for any of the fpga devices supported by fpga_load to be used.

IMO looks OK, minor nits below

Quoted 21 lines

--
Changes in v2:
- Add fitimage support for fpga-devnum and fpga-partial-image
- Use above in boot_get_fpga
- for xilinx fpgas double check using image size to determine if image is a partial image

---
 common/image-fit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/image.c     | 51 ++++++++++++++++++++++++++++++++-------------------
 include/image.h    |  5 +++++
 3 files changed, 88 insertions(+), 19 deletions(-)
common/image-fit.c +0 -0
index 109ecfa..eb0c633 100644
@@ -916,6 +916,57 @@ ulong fit_get_end(const void *fit)
 }
 
 

[...]

Quoted 8 lines

common/image-fit.c

Quoted 4 lines
common/image-fit.c +3 -0
+		fit_image_fpga_get_devnum(buf, conf_noffset, &devnum);
+
+		/* check bitstream type */

At least start the sentence with capital letter please.

Quoted 1 line
Quoted 5 lines

common/image-fit.c

Quoted 2 lines
common/image-fit.c +2 -0
+		if (fit_image_fpga_is_partial(buf, conf_noffset))
+			bstype = BIT_PARTIAL;

Are there any chances there will be something else besides full and partial in the future ?

Quoted 4 lines

It's plausible but i think not a likely use case here. In Arria10 there is the periphery/core image that configures just the io or fpga core. I believe, though, that this is just a special case of a partial image and is treated the same.

IOCSR ? Hmmm, it'd be great if we could get a real pinmux driver for socfpga ;-) But that's totally out of context of this discussion ...

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH v2 2/2 common: bootm: add support for arbitrary fgpa configuration

In reply to Dalon Westergreen

This adds support for fpga configuration data in fitimages for any fpga device supported by fpga_load. At this point fitimages only support configuration of fpga images for fpga devnum 0.

---
 common/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bootm.c +1 -1
index b2c0912..4a4b47c 100644
@@ -248,7 +248,7 @@ int bootm_find_images(int flag, int argc, char * const argv[])
 #endif
 
 #if IMAGE_ENABLE_FIT
-#if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_XILINX)
+#if defined(CONFIG_FPGA)
 	/* find bitstreams */
 	ret = boot_get_fpga(argc, argv, &images, IH_ARCH_DEFAULT,
 			    NULL, NULL);
Signature · 1 line
2.7.4