mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-01-25 03:15:17 +00:00
8502b5bf20
Add a SPL test for the NAND load method. We use some different functions to do the writing from the main test since things like nand_write_skip_bad aren't available in SPL. We disable BBT scanning, since scan_bbt is only populated when not in SPL. We use nand_spl_loaders.c as it seems to be common to at least a few boards already. However, we do not use nand_spl_simple.c because it would require us to implement cmd_ctrl. The various nand load functions are adapted from omap_gpmc. However, they have been modified for simplicity/correctness. Signed-off-by: Sean Anderson <seanga2@gmail.com>
54 lines
1.5 KiB
C
54 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);
|
|
SPL_IMG_TEST(spl_test_nand, FIT_EXTERNAL, DM_FLAGS);
|