mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-19 03:08:31 +00:00
36afd45136
Make spl_*_load_image() functions return a value instead of hanging if a problem is encountered. This enables main spl code to make the decision whether to hang or not, thus preparing it to support alternative boot devices. Some boot devices (namely nand and spi) do not hang on error. Instead, they return normally and SPL proceeds to boot the contents of the load address. This is considered a bug and is rectified by hanging on error for these devices as well. Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il> Cc: Igor Grinberg <grinberg@compulab.co.il> Cc: Tom Rini <trini@konsulko.com> Cc: Simon Glass <sjg@chromium.org> Cc: Ian Campbell <ijc@hellion.org.uk> Cc: Hans De Goede <hdegoede@redhat.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Jagan Teki <jteki@openedev.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
/*
|
|
* (C) Copyright 2000-2004
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
*
|
|
* (C) Copyright 2011
|
|
* Texas Instruments, <www.ti.com>
|
|
*
|
|
* Matt Porter <mporter@ti.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
#include <common.h>
|
|
#include <spl.h>
|
|
#include <xyzModem.h>
|
|
#include <asm/u-boot.h>
|
|
#include <asm/utils.h>
|
|
|
|
#define BUF_SIZE 1024
|
|
|
|
static int getcymodem(void) {
|
|
if (tstc())
|
|
return (getc());
|
|
return -1;
|
|
}
|
|
|
|
int spl_ymodem_load_image(void)
|
|
{
|
|
int size = 0;
|
|
int err;
|
|
int res;
|
|
int ret;
|
|
connection_info_t info;
|
|
char buf[BUF_SIZE];
|
|
ulong store_addr = ~0;
|
|
ulong addr = 0;
|
|
|
|
info.mode = xyzModem_ymodem;
|
|
ret = xyzModem_stream_open(&info, &err);
|
|
|
|
if (!ret) {
|
|
while ((res =
|
|
xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) {
|
|
if (addr == 0)
|
|
spl_parse_image_header((struct image_header *)buf);
|
|
store_addr = addr + spl_image.load_addr;
|
|
size += res;
|
|
addr += res;
|
|
memcpy((char *)(store_addr), buf, res);
|
|
}
|
|
} else {
|
|
printf("spl: ymodem err - %s\n", xyzModem_error(err));
|
|
return ret;
|
|
}
|
|
|
|
xyzModem_stream_close(&err);
|
|
xyzModem_stream_terminate(false, &getcymodem);
|
|
|
|
printf("Loaded %d bytes\n", size);
|
|
return 0;
|
|
}
|