return 0;
}
-void spl_board_load_image(void)
+int spl_board_load_image(void)
{
debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
return_to_fel(fel_stash.sp, fel_stash.lr);
+
+ return 0;
}
void s_init(void)
};
#endif
-/* Board-specific load method */
-void spl_board_load_image(void);
+/**
+ * Board specific load method for boards that have a special way of loading
+ * U-Boot, which does not fit with the existing SPL code.
+ *
+ * @return 0 on success, negative errno value on failure.
+ */
+
+int spl_board_load_image(void);
/* Linker symbols. */
extern char __bss_start[], __bss_end[];
}
#ifdef CONFIG_SPL_RAM_DEVICE
-static void spl_ram_load_image(void)
+static int spl_ram_load_image(void)
{
const struct image_header *header;
(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
spl_parse_image_header(header);
+
+ return 0;
}
#endif
switch (boot_device) {
#ifdef CONFIG_SPL_RAM_DEVICE
case BOOT_DEVICE_RAM:
- spl_ram_load_image();
+ if (spl_ram_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_MMC_SUPPORT
case BOOT_DEVICE_MMC1:
case BOOT_DEVICE_MMC2:
case BOOT_DEVICE_MMC2_2:
- spl_mmc_load_image();
+ if (spl_mmc_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_NAND_SUPPORT
case BOOT_DEVICE_NAND:
- spl_nand_load_image();
+ if (spl_nand_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_ONENAND_SUPPORT
case BOOT_DEVICE_ONENAND:
- spl_onenand_load_image();
+ if (spl_onenand_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_NOR_SUPPORT
case BOOT_DEVICE_NOR:
- spl_nor_load_image();
+ if (spl_nor_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_YMODEM_SUPPORT
case BOOT_DEVICE_UART:
- spl_ymodem_load_image();
+ if (spl_ymodem_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_SPI_SUPPORT
case BOOT_DEVICE_SPI:
- spl_spi_load_image();
+ if (spl_spi_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_ETH_SUPPORT
case BOOT_DEVICE_CPGMAC:
#ifdef CONFIG_SPL_ETH_DEVICE
- spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
+ if (spl_net_load_image(CONFIG_SPL_ETH_DEVICE))
+ hang();
#else
- spl_net_load_image(NULL);
+ if (spl_net_load_image(NULL))
+ hang();
#endif
break;
#endif
#ifdef CONFIG_SPL_USBETH_SUPPORT
case BOOT_DEVICE_USBETH:
- spl_net_load_image("usb_ether");
+ if (spl_net_load_image("usb_ether"))
+ hang();
break;
#endif
#ifdef CONFIG_SPL_USB_SUPPORT
case BOOT_DEVICE_USB:
- spl_usb_load_image();
+ if (spl_usb_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_SATA_SUPPORT
case BOOT_DEVICE_SATA:
- spl_sata_load_image();
+ if (spl_sata_load_image())
+ hang();
break;
#endif
#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
case BOOT_DEVICE_BOARD:
- spl_board_load_image();
+ if (spl_board_load_image())
+ hang();
break;
#endif
default:
#include <dm.h>
#include <spl.h>
#include <linux/compiler.h>
+#include <errno.h>
#include <asm/u-boot.h>
#include <errno.h>
#include <mmc.h>
}
#endif
-void spl_mmc_load_image(void)
+int spl_mmc_load_image(void)
{
struct mmc *mmc;
u32 boot_mode;
int err = 0;
__maybe_unused int part;
- if (spl_mmc_find_device(&mmc))
- hang();
+ err = spl_mmc_find_device(&mmc);
+ if (err)
+ return err;
err = mmc_init(mmc);
if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: mmc init failed with error: %d\n", err);
#endif
- hang();
+ return err;
}
boot_mode = spl_boot_mode();
+ err = -EINVAL;
switch (boot_mode) {
case MMCSD_MODE_EMMCBOOT:
/*
if (part == 7)
part = 0;
- if (mmc_switch_part(0, part)) {
+ err = mmc_switch_part(0, part);
+ if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
puts("spl: mmc partition switch failed\n");
#endif
- hang();
+ return err;
}
/* Fall through */
case MMCSD_MODE_RAW:
if (!spl_start_uboot()) {
err = mmc_load_image_raw_os(mmc);
if (!err)
- return;
+ return err;
}
err = mmc_load_image_raw_partition(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
if (!err)
- return;
+ return err;
#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
err = mmc_load_image_raw_sector(mmc,
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
if (!err)
- return;
+ return err;
#endif
break;
case MMCSD_MODE_FS:
err = spl_mmc_do_fs_boot(mmc);
if (!err)
- return;
+ return err;
break;
case MMCSD_MODE_UNDEFINED:
#endif
}
- hang();
+ return err;
}
#include <nand.h>
#if defined(CONFIG_SPL_NAND_RAW_ONLY)
-void spl_nand_load_image(void)
+int spl_nand_load_image(void)
{
nand_init();
(void *)CONFIG_SYS_NAND_U_BOOT_DST);
spl_set_header_raw_uboot();
nand_deselect();
+
+ return 0;
}
#else
static int spl_nand_load_element(int offset, struct image_header *header)
(void *)(unsigned long)spl_image.load_addr);
}
-void spl_nand_load_image(void)
+int spl_nand_load_image(void)
{
+ int err;
struct image_header *header;
int *src __attribute__((unused));
int *dst __attribute__((unused));
spl_parse_image_header(header);
if (header->ih_os == IH_OS_LINUX) {
/* happy - was a linux */
- nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
- spl_image.size, (void *)spl_image.load_addr);
+ err = nand_spl_load_image(
+ CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
+ spl_image.size,
+ (void *)spl_image.load_addr);
nand_deselect();
- return;
+ return err;
} else {
puts("The Expected Linux image was not "
"found. Please check your NAND "
#endif
#endif
/* Load u-boot */
- spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
+ err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
nand_deselect();
+ return err;
}
#endif
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
+#include <errno.h>
#include <spl.h>
#include <net.h>
DECLARE_GLOBAL_DATA_PTR;
-void spl_net_load_image(const char *device)
+int spl_net_load_image(const char *device)
{
int rv;
rv = eth_initialize();
if (rv == 0) {
printf("No Ethernet devices found\n");
- hang();
+ return -ENODEV;
}
if (device)
setenv("ethact", device);
rv = net_loop(BOOTP);
if (rv < 0) {
printf("Problem booting with BOOTP\n");
- hang();
+ return rv;
}
spl_parse_image_header((struct image_header *)load_addr);
+
+ return 0;
}
#include <common.h>
#include <spl.h>
-void spl_nor_load_image(void)
+int spl_nor_load_image(void)
{
/*
* Loading of the payload to SDRAM is done with skipping of
(void *)(CONFIG_SYS_FDT_BASE),
(16 << 10));
- return;
+ return 0;
} else {
puts("The Expected Linux image was not found.\n"
"Please check your NOR configuration.\n"
memcpy((void *)spl_image.load_addr,
(void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
spl_image.size);
+
+ return 0;
}
#include <asm/io.h>
#include <onenand_uboot.h>
-void spl_onenand_load_image(void)
+int spl_onenand_load_image(void)
{
struct image_header *header;
spl_parse_image_header(header);
onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
spl_image.size, (void *)spl_image.load_addr);
+
+ return 0;
}
#include <asm/u-boot.h>
#include <sata.h>
#include <scsi.h>
+#include <errno.h>
#include <fat.h>
#include <image.h>
DECLARE_GLOBAL_DATA_PTR;
-void spl_sata_load_image(void)
+int spl_sata_load_image(void)
{
int err;
block_dev_desc_t *stor_dev;
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("spl: sata init failed: err - %d\n", err);
#endif
- hang();
+ return err;
} else {
/* try to recognize storage devices immediately */
scsi_scan(0);
stor_dev = scsi_get_dev(0);
+ if (!stor_dev)
+ return -ENODEV;
}
#ifdef CONFIG_SPL_OS_BOOT
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
if (err) {
puts("Error loading sata device\n");
- hang();
+ return err;
}
+
+ return 0;
}
#include <common.h>
#include <spl.h>
#include <asm/u-boot.h>
+#include <errno.h>
#include <usb.h>
#include <fat.h>
static int usb_stor_curr_dev = -1; /* current device */
#endif
-void spl_usb_load_image(void)
+int spl_usb_load_image(void)
{
int err;
block_dev_desc_t *stor_dev;
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
printf("%s: usb init failed: err - %d\n", __func__, err);
#endif
- hang();
+ return err;
}
#ifdef CONFIG_USB_STORAGE
/* try to recognize storage devices immediately */
usb_stor_curr_dev = usb_stor_scan(1);
stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
+ if (!stor_dev)
+ return -ENODEV;
#endif
debug("boot mode - FAT\n");
CONFIG_SYS_USB_FAT_BOOT_PARTITION,
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
- if (err) {
- puts("Error loading USB device\n");
- hang();
- }
+ if (err) {
+ puts("Error loading from USB device\n");
+ return err;
+ }
+
+ return 0;
}
return -1;
}
-void spl_ymodem_load_image(void)
+int spl_ymodem_load_image(void)
{
int size = 0;
int err;
}
} else {
printf("spl: ymodem err - %s\n", xyzModem_error(err));
- hang();
+ return ret;
}
xyzModem_stream_close(&err);
xyzModem_stream_terminate(false, &getcymodem);
printf("Loaded %d bytes\n", size);
+ return 0;
}
#include <common.h>
#include <spi.h>
#include <spi_flash.h>
+#include <errno.h>
#include <spl.h>
#ifdef CONFIG_SPL_OS_BOOT
* configured and available since this code loads the main U-Boot image
* from SPI into SDRAM and starts it from there.
*/
-void spl_spi_load_image(void)
+int spl_spi_load_image(void)
{
+ int err = 0;
struct spi_flash *flash;
struct image_header *header;
CONFIG_SF_DEFAULT_MODE);
if (!flash) {
puts("SPI probe failed.\n");
- hang();
+ return -ENODEV;
}
/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
#endif
{
/* Load u-boot, mkimage header is 64 bytes. */
- spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
- (void *)header);
+ err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
+ (void *)header);
+ if (err)
+ return err;
+
spl_parse_image_header(header);
- spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
+ err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
spl_image.size, (void *)spl_image.load_addr);
}
+
+ return err;
}
void spl_display_print(void);
/* NAND SPL functions */
-void spl_nand_load_image(void);
+int spl_nand_load_image(void);
/* OneNAND SPL functions */
-void spl_onenand_load_image(void);
+int spl_onenand_load_image(void);
/* NOR SPL functions */
-void spl_nor_load_image(void);
+int spl_nor_load_image(void);
/* MMC SPL functions */
-void spl_mmc_load_image(void);
+int spl_mmc_load_image(void);
/* YMODEM SPL functions */
-void spl_ymodem_load_image(void);
+int spl_ymodem_load_image(void);
/* SPI SPL functions */
-void spl_spi_load_image(void);
+int spl_spi_load_image(void);
/* Ethernet SPL functions */
-void spl_net_load_image(const char *device);
+int spl_net_load_image(const char *device);
/* USB SPL functions */
-void spl_usb_load_image(void);
+int spl_usb_load_image(void);
/* SATA SPL functions */
-void spl_sata_load_image(void);
+int spl_sata_load_image(void);
/* SPL FAT image functions */
int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);