mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
spl: ymodem: Fix loading of fit image
spl ymodem driver always assumes that 1 BUF_SIZE is read in one stream. This might not be true when image is not padded to BUF_SIZE and the last sector that gets loaded will be < BUF_SIZE. Drop this assumption and use the actual size that is loaded. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
This commit is contained in:
@@ -37,7 +37,7 @@ static int getcymodem(void) {
|
|||||||
static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
|
static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
|
||||||
ulong size, void *addr)
|
ulong size, void *addr)
|
||||||
{
|
{
|
||||||
int res, err;
|
int res, err, buf_offset;
|
||||||
struct ymodem_fit_info *info = load->priv;
|
struct ymodem_fit_info *info = load->priv;
|
||||||
char *buf = info->buf;
|
char *buf = info->buf;
|
||||||
|
|
||||||
@@ -51,7 +51,11 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset,
|
|||||||
|
|
||||||
if (info->image_read > offset) {
|
if (info->image_read > offset) {
|
||||||
res = info->image_read - offset;
|
res = info->image_read - offset;
|
||||||
memcpy(addr, &buf[BUF_SIZE - res], res);
|
if (info->image_read % BUF_SIZE)
|
||||||
|
buf_offset = (info->image_read % BUF_SIZE);
|
||||||
|
else
|
||||||
|
buf_offset = BUF_SIZE;
|
||||||
|
memcpy(addr, &buf[buf_offset - res], res);
|
||||||
addr = addr + res;
|
addr = addr + res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user