Skip to contentSkip to conversation

spl: fit: Fix the number of bytes read in raw mode

PATCH In review Lokesh Vutla 2 participants 3 messages Jul 19, 2016 – Jul 23, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: fit: Fix the number of bytes read in raw mode

In raw mode a full sector is to be read even if image covers part of a sector. Number of sectors are calculated as ROUND_UP(size)/sec_size by FIT framework. This calculation assumes that image is at the 0th offset of a sector, which is not true always in FIT case. So, include the image offset while calculating number of sectors.

---
 common/spl/spl_fit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/spl/spl_fit.c +3 -1
index 069e94d..be86072 100644
@@ -115,8 +115,10 @@ static int get_aligned_image_overhead(struct spl_load_info *info, int offset)
 static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 				  int offset)
 {
+	data_size = data_size + get_aligned_image_overhead(info, offset);
+
 	if (info->filename)
-		return data_size + get_aligned_image_overhead(info, offset);
+		return data_size;
 
 	return (data_size + info->bl_len - 1) / info->bl_len;
 }
Signature · 1 line
2.9.2
#1 lore raw

PATCH 1/1 spl: fit: Fix the number of bytes read in raw mode

Quoted 7 lines · Lokesh Vutla

In raw mode a full sector is to be read even if image covers part of a sector. Number of sectors are calculated as ROUND_UP(size)/sec_size by FIT framework. This calculation assumes that image is at the 0th offset of a sector, which is not true always in FIT case. So, include the image offset while calculating number of sectors.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160719/7465cd8d/attachment.sig>
#2 lore raw
In reply to Lokesh Vutla
Quoted 8 lines · Lokesh Vutla

In raw mode a full sector is to be read even if image covers part of a sector. Number of sectors are calculated as ROUND_UP(size)/sec_size by FIT framework. This calculation assumes that image is at the 0th offset of a sector, which is not true always in FIT case. So, include the image offset while calculating number of sectors.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160722/c608f406/attachment.sig>