[PATCH 5/7] spl: fit: Support loading FPGA images from list of "loadables"

Alex G. mr.nuke.me at gmail.com
Mon Mar 29 17:35:45 CEST 2021


On 3/29/21 2:43 AM, Simon Glass wrote:
> Hi Alexandru,
> 
> On Thu, 11 Mar 2021 at 07:04, Alexandru Gagniuc <mr.nuke.me at gmail.com> wrote:
>>
>> Commit 4afc4f37c70e ("doc: FIT image: Clarify format and simplify
>> syntax") and delegated FPGA images to be added via the list of
>> "loadables" in lieu of the "fpga" property. Now actually implement
>> this in code.
>>
>> Note that the "compatible" property is ignored for the time being, as
>> implementing "compatible" loading is beyond the scope of this change.
>> However, "u-boot,fpga-legacy" is accepted without warning.
>>
>> Signed-off-by: Alexandru Gagniuc <mr.nuke.me at gmail.com>
>> ---
>>   common/spl/spl_fit.c | 24 ++++++++++++++++++++++++
>>   1 file changed, 24 insertions(+)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index 68f29c0026..ca6be6a839 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -477,6 +477,20 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index,
>>          return ret;
>>   }
>>
>> +static int spl_fit_image_is_fpga(const void *fit, int node)
>> +{
>> +       const char *type;
>> +
>> +       if (!IS_ENABLED(CONFIG_SPL_FPGA))
>> +               return 0;
>> +
>> +       type = fdt_getprop(fit, node, FIT_TYPE_PROP, NULL);
>> +       if (!type)
>> +               return 0;
>> +
>> +       return !strcmp(type, "fpga");
>> +}
>> +
>>   static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
>>   {
>>          if (!CONFIG_IS_ENABLED(FIT_IMAGE_TINY) || CONFIG_IS_ENABLED(OS_BOOT))
>> @@ -536,11 +550,18 @@ static void warn_deprecated(const char *msg)
>>   static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,
>>                                 struct spl_image_info *fpga_image)
>>   {
>> +       const char *compatible;
>>          int ret;
>>
>>          debug("FPGA bitstream at: %x, size: %x\n",
>>                (u32)fpga_image->load_addr, fpga_image->size);
>>
>> +       compatible = fdt_getprop(ctx->fit, node, "compatible", NULL);
>> +       if (!compatible)
>> +               warn_deprecated("'fpga' image without 'compatible' property");
>> +       else if (strcmp(compatible, "u-boot,fpga-legacy"))
>> +               printf("Ignoring compatible = %s property\n", compatible);
>> +
>>          ret = fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size,
>>                          BIT_FULL);
>>          if (ret) {
>> @@ -739,6 +760,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
>>                          return ret;
>>                  }
>>
>> +               if (spl_fit_image_is_fpga(ctx.fit, node))
>> +                       spl_fit_upload_fpga(&ctx, node, &image_info);
>> +
> 
> Given the code-size increase I think a new Kconfig option for SPL FPGA
> FIT support would be useful.

The "if !IS_ENABLED(CONFIG_SPL_FPGA))" makes spl_fit_image_is_fpga() a 
no-op, with no size increase when "# CONFIG_SPL_FPGA is not set". This 
is also confirmed by comparing the size of .text ( "objdump -h 
spl/u-boot-spl" ). So there isn't a size increase for non-FPGA use cases.

Also, FPGA support in SPL is only possible through FIT images. So 
SPL_FPGA vs SPL_FIT_FPGA distinction doesn't make sense.

Alex

>>                  if (!spl_fit_image_get_os(ctx.fit, node, &os_type))
>>                          debug("Loadable is %s\n", genimg_get_os_name(os_type));
>>
>> --
>> 2.26.2
>>
> 
> Regards,
> Simon
> 


More information about the U-Boot mailing list