mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 22:03:15 +00:00
11f834614e
This converts the nand load method to use spl_load. nand_page_size may not be valid until after nand_spl_load_image is called (see e.g. fsl_ifc_spl), so we set bl_len in spl_nand_read. Since spl_load reads the header for us, we can remove that argument from spl_nand_load_element. There are two possible regressions which could result from this commit. First, we ask for a negative address from spl_get_load_buffer. That is, instead of header = spl_get_load_buffer(0, sizeof(*header)); we do header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); this could cause a problem if spl_get_load_buffer does not return valid memory for negative offsets. Second, we now set bl_len for legacy images. This can cause memory up to a bl_len - 1 before the image load address to be written, which might not have been the case before. If this turns out to be a problem, we can add an option for a bounce buffer. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NAND_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
56 lines
1.5 KiB
C
56 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2023 Sean Anderson <seanga2@gmail.com>
|
|
*/
|
|
|
|
#include <nand.h>
|
|
#include <spl.h>
|
|
#include <test/spl.h>
|
|
#include <test/ut.h>
|
|
|
|
uint32_t spl_nand_get_uboot_raw_page(void);
|
|
|
|
static int spl_test_nand_write_image(struct unit_test_state *uts, void *img,
|
|
size_t img_size)
|
|
{
|
|
uint32_t off = spl_nand_get_uboot_raw_page();
|
|
struct mtd_info *mtd;
|
|
struct erase_info erase = { };
|
|
size_t length;
|
|
|
|
nand_reinit();
|
|
mtd = get_nand_dev_by_index(0);
|
|
ut_assertnonnull(mtd);
|
|
|
|
/* Mark the first block as bad to test that it gets skipped */
|
|
ut_assertok(mtd_block_markbad(mtd, off & ~mtd->erasesize_mask));
|
|
off += mtd->erasesize;
|
|
|
|
erase.mtd = mtd;
|
|
erase.len = img_size + (off & mtd->erasesize_mask);
|
|
erase.len += mtd->erasesize_mask;
|
|
erase.len &= ~mtd->erasesize_mask;
|
|
erase.addr = off & ~mtd->erasesize_mask;
|
|
erase.scrub = 1;
|
|
ut_assertok(mtd_erase(mtd, &erase));
|
|
|
|
ut_assertok(mtd_write(mtd, off, img_size, &length, img));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int spl_test_nand(struct unit_test_state *uts, const char *test_name,
|
|
enum spl_test_image type)
|
|
{
|
|
return do_spl_test_load(uts, test_name, type,
|
|
SPL_LOAD_IMAGE_GET(1, BOOT_DEVICE_NAND,
|
|
spl_nand_load_image),
|
|
spl_test_nand_write_image);
|
|
}
|
|
SPL_IMG_TEST(spl_test_nand, LEGACY, DM_FLAGS);
|
|
SPL_IMG_TEST(spl_test_nand, LEGACY_LZMA, DM_FLAGS);
|
|
SPL_IMG_TEST(spl_test_nand, IMX8, DM_FLAGS);
|
|
SPL_IMG_TEST(spl_test_nand, FIT_INTERNAL, DM_FLAGS);
|
|
#if !IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)
|
|
SPL_IMG_TEST(spl_test_nand, FIT_EXTERNAL, DM_FLAGS);
|
|
#endif
|