Re: [U-Boot] [PATCH v3 4/5] spl: fit: Support both external and embedded data

2017-09-12 Thread York Sun
On 08/15/2017 11:15 AM, York Sun wrote:
> SPL supports U-Boot image in FIT format which has data outside of
> FIT structure. This adds support for embedded data for normal FIT
> images.
> 
> Signed-off-by: York Sun 
> Reviewed-by: Tom Rini 
> 
> ---
> 
> Changes in v3:
> Update doc/uImage.FIT/source_file_format.txt with embedded and external data
> 
> Changes in v2:
> Rebase on top of "SPL: FIT: factor out spl_load_fit_image()" by Andre Przywara
> 

Applied to fsl-qoriq master.

York


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] spl: fit: Support both external and embedded data

2017-08-30 Thread York Sun
On 08/30/2017 10:12 AM, York Sun wrote:
> On 08/26/2017 06:39 AM, Simon Glass wrote:
>> On 15 August 2017 at 12:14, York Sun  wrote:
>>> SPL supports U-Boot image in FIT format which has data outside of
>>> FIT structure. This adds support for embedded data for normal FIT
>>> images.
>>>
>>> Signed-off-by: York Sun 
>>> Reviewed-by: Tom Rini 
>>>
>>> ---
>>>
>>> Changes in v3:
>>> Update doc/uImage.FIT/source_file_format.txt with embedded and external data
>>>
>>> Changes in v2:
>>> Rebase on top of "SPL: FIT: factor out spl_load_fit_image()" by Andre 
>>> Przywara
>>>
>>>common/spl/spl_fit.c  | 52 
>>> ++-
>>>doc/uImage.FIT/source_file_format.txt |  4 +++
>>>2 files changed, 37 insertions(+), 19 deletions(-)
>>
>> Reviewed-by: Simon Glass 
>>
>> Please see nit below.
>>
> 
> 
>>> diff --git a/doc/uImage.FIT/source_file_format.txt 
>>> b/doc/uImage.FIT/source_file_format.txt
>>> index 136d3d7..3ce47ed 100644
>>> --- a/doc/uImage.FIT/source_file_format.txt
>>> +++ b/doc/uImage.FIT/source_file_format.txt
>>> @@ -288,6 +288,10 @@ The 'data-offset' property can be substituted with 
>>> 'data-position', which
>>>defines an absolute position or address as the offset. This is helpful 
>>> when
>>>booting U-Boot proper before performing relocation.
>>>
>>> +Normal kernel FIT image has data embedded within FIT structure. Normal 
>>> U-Boot
>>> +image has external data. Existence of 'data-offset' can be used to identify
>>
>> I think actually external data is normal for SPL but not for U-Boot
>> proper. I don't know if that is worth mentioning though.
>>
> 
> I will change to "U-Boot SPL image has external data" when merging this
> patch.
> 

I should say "U-Boot image for SPL boot has external data".

York
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] spl: fit: Support both external and embedded data

2017-08-30 Thread York Sun
On 08/26/2017 06:39 AM, Simon Glass wrote:
> On 15 August 2017 at 12:14, York Sun  wrote:
>> SPL supports U-Boot image in FIT format which has data outside of
>> FIT structure. This adds support for embedded data for normal FIT
>> images.
>>
>> Signed-off-by: York Sun 
>> Reviewed-by: Tom Rini 
>>
>> ---
>>
>> Changes in v3:
>> Update doc/uImage.FIT/source_file_format.txt with embedded and external data
>>
>> Changes in v2:
>> Rebase on top of "SPL: FIT: factor out spl_load_fit_image()" by Andre 
>> Przywara
>>
>>   common/spl/spl_fit.c  | 52 
>> ++-
>>   doc/uImage.FIT/source_file_format.txt |  4 +++
>>   2 files changed, 37 insertions(+), 19 deletions(-)
> 
> Reviewed-by: Simon Glass 
> 
> Please see nit below.
> 


>> diff --git a/doc/uImage.FIT/source_file_format.txt 
>> b/doc/uImage.FIT/source_file_format.txt
>> index 136d3d7..3ce47ed 100644
>> --- a/doc/uImage.FIT/source_file_format.txt
>> +++ b/doc/uImage.FIT/source_file_format.txt
>> @@ -288,6 +288,10 @@ The 'data-offset' property can be substituted with 
>> 'data-position', which
>>   defines an absolute position or address as the offset. This is helpful when
>>   booting U-Boot proper before performing relocation.
>>
>> +Normal kernel FIT image has data embedded within FIT structure. Normal 
>> U-Boot
>> +image has external data. Existence of 'data-offset' can be used to identify
> 
> I think actually external data is normal for SPL but not for U-Boot
> proper. I don't know if that is worth mentioning though.
> 

I will change to "U-Boot SPL image has external data" when merging this 
patch.

York
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 4/5] spl: fit: Support both external and embedded data

2017-08-26 Thread Simon Glass
On 15 August 2017 at 12:14, York Sun  wrote:
> SPL supports U-Boot image in FIT format which has data outside of
> FIT structure. This adds support for embedded data for normal FIT
> images.
>
> Signed-off-by: York Sun 
> Reviewed-by: Tom Rini 
>
> ---
>
> Changes in v3:
> Update doc/uImage.FIT/source_file_format.txt with embedded and external data
>
> Changes in v2:
> Rebase on top of "SPL: FIT: factor out spl_load_fit_image()" by Andre Przywara
>
>  common/spl/spl_fit.c  | 52 
> ++-
>  doc/uImage.FIT/source_file_format.txt |  4 +++
>  2 files changed, 37 insertions(+), 19 deletions(-)

Reviewed-by: Simon Glass 

Please see nit below.

>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index fe41ce0..9449a22 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -132,14 +132,16 @@ static int spl_load_fit_image(struct spl_load_info 
> *info, ulong sector,
>   void *fit, ulong base_offset, int node,
>   struct spl_image_info *image_info)
>  {
> -   ulong offset;
> +   int offset;
> size_t length;
> +   int len;
> ulong load_addr, load_ptr;
> void *src;
> ulong overhead;
> int nr_sectors;
> int align_len = ARCH_DMA_MINALIGN - 1;
> uint8_t image_comp = -1, type = -1;
> +   const void *data;
>
> if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) {
> if (fit_image_get_comp(fit, node, &image_comp))
> @@ -153,28 +155,40 @@ static int spl_load_fit_image(struct spl_load_info 
> *info, ulong sector,
> debug("%s ", genimg_get_type_name(type));
> }
>
> -   offset = fdt_getprop_u32(fit, node, "data-offset");
> -   if (offset == FDT_ERROR)
> -   return -ENOENT;
> -   offset += base_offset;
> -   length = fdt_getprop_u32(fit, node, "data-size");
> -   if (length == FDT_ERROR)
> -   return -ENOENT;
> -   load_addr = fdt_getprop_u32(fit, node, "load");
> -   if (load_addr == FDT_ERROR && image_info)
> +   if (fit_image_get_load(fit, node, &load_addr))
> load_addr = image_info->load_addr;
> -   load_ptr = (load_addr + align_len) & ~align_len;
>
> -   overhead = get_aligned_image_overhead(info, offset);
> -   nr_sectors = get_aligned_image_size(info, length, offset);
> +   if (!fit_image_get_data_offset(fit, node, &offset)) {
> +   /* External data */
> +   offset += base_offset;
> +   if (fit_image_get_data_size(fit, node, &len))
> +   return -ENOENT;
>
> -   if (info->read(info, sector + get_aligned_image_offset(info, offset),
> -  nr_sectors, (void*)load_ptr) != nr_sectors)
> -   return -EIO;
> -   debug("image dst=%lx, offset=%lx, size=%lx\n", load_ptr, offset,
> - (unsigned long)length);
> +   load_ptr = (load_addr + align_len) & ~align_len;
> +   length = len;
> +
> +   overhead = get_aligned_image_overhead(info, offset);
> +   nr_sectors = get_aligned_image_size(info, length, offset);
> +
> +   if (info->read(info,
> +  sector + get_aligned_image_offset(info, 
> offset),
> +  nr_sectors, (void *)load_ptr) != nr_sectors)
> +   return -EIO;
> +
> +   debug("External data: dst=%lx, offset=%x, size=%lx\n",
> + load_ptr, offset, (unsigned long)length);
> +   src = (void *)load_ptr + overhead;
> +   } else {
> +   /* Embedded data */
> +   if (fit_image_get_data(fit, node, &data, &length)) {
> +   puts("Cannot get image data/size\n");
> +   return -ENOENT;
> +   }
> +   debug("Embedded data: dst=%lx, size=%lx\n", load_addr,
> + (unsigned long)length);
> +   src = (void *)data;
> +   }
>
> -   src = (void *)load_ptr + overhead;
>  #ifdef CONFIG_SPL_FIT_IMAGE_POST_PROCESS
> board_fit_image_post_process(&src, &length);
>  #endif
> diff --git a/doc/uImage.FIT/source_file_format.txt 
> b/doc/uImage.FIT/source_file_format.txt
> index 136d3d7..3ce47ed 100644
> --- a/doc/uImage.FIT/source_file_format.txt
> +++ b/doc/uImage.FIT/source_file_format.txt
> @@ -288,6 +288,10 @@ The 'data-offset' property can be substituted with 
> 'data-position', which
>  defines an absolute position or address as the offset. This is helpful when
>  booting U-Boot proper before performing relocation.
>
> +Normal kernel FIT image has data embedded within FIT structure. Normal U-Boot
> +image has external data. Existence of 'data-offset' can be used to identify

I think actually external data is normal for SPL but not for U-Boot
proper. I don't know if that is worth mentioning th