3 * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
5 * SPDX-License-Identifier: GPL-2.0+
13 int spl_nand_load_image(void)
16 struct image_header *header;
17 int *src __attribute__((unused));
18 int *dst __attribute__((unused));
20 debug("spl: nand - using hw ecc\n");
23 /*use CONFIG_SYS_TEXT_BASE as temporary storage area */
24 header = (struct image_header *)CONFIG_SYS_TEXT_BASE;
25 #ifdef CONFIG_SPL_OS_BOOT
26 if (!spl_start_uboot()) {
28 * load parameter image
29 * load to temp position since nand_spl_load_image reads
30 * a whole block which is typically larger than
31 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite
32 * following sections like BSS
34 nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS,
35 CONFIG_CMD_SPL_WRITE_SIZE,
36 (void *)CONFIG_SYS_TEXT_BASE);
37 /* copy to destintion */
38 for (dst = (int *)CONFIG_SYS_SPL_ARGS_ADDR,
39 src = (int *)CONFIG_SYS_TEXT_BASE;
40 src < (int *)(CONFIG_SYS_TEXT_BASE +
41 CONFIG_CMD_SPL_WRITE_SIZE);
43 writel(readl(src), dst);
47 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
48 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
49 spl_parse_image_header(header);
50 if (header->ih_os == IH_OS_LINUX) {
51 /* happy - was a linux */
52 nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
53 spl_image.size, (void *)spl_image.load_addr);
57 printf("The Expected Linux image was not"
58 "found. Please check your NAND"
60 printf("Trying to start u-boot now...\n");
64 #ifdef CONFIG_NAND_ENV_DST
65 nand_spl_load_image(CONFIG_ENV_OFFSET,
66 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
67 spl_parse_image_header(header);
68 nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
69 (void *)spl_image.load_addr);
70 #ifdef CONFIG_ENV_OFFSET_REDUND
71 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
72 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
73 spl_parse_image_header(header);
74 nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
75 (void *)spl_image.load_addr);
79 ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
80 CONFIG_SYS_NAND_PAGE_SIZE, (void *)header);
82 spl_parse_image_header(header);
83 ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
84 spl_image.size, (void *)spl_image.load_addr);