am335x: NAND boot problem using the legacy u-boot.img

Yegor Yefremov yegorslists at googlemail.com
Thu Sep 25 08:09:05 CEST 2025


Hi Tom,

On Wed, Sep 24, 2025 at 4:14 PM Tom Rini <trini at konsulko.com> wrote:
>
> On Wed, Sep 24, 2025 at 11:09:16AM +0200, Yegor Yefremov wrote:
>
> > HI all,
> >
> > trying to boot using the latest master, I get the following error:
> >
> > U-Boot SPL 2025.10-rc4 (Sep 23 2025 - 16:45:07 +0200)
> > Trying to boot from NAND
> > Error: -5
> > SPL: failed to boot from all boot devices (err=-5)
> > ### ERROR ### Please RESET the board ###
> >
> > It turns out that bl_len will be set to 0 in spl_nand_read():
> >
> > spl_set_bl_len(load, nand_page_size());
> >
> > This sets the aligned image size to 0 in _spl_load():
> >
> > size = ALIGN(spl_image->size + overhead, spl_get_bl_len(info));
> >
> > Looks like FIT images with full FIT support will be also affected:
> >
> >                        read = info->read(info, offset,
> >                                            ALIGN(size, spl_get_bl_len(info)),
> >                                             buf);
> >
> > If I manually set bl_len to 1, I can boot without an issue. What am I missing?
>
> I wonder if this has always been an underlying problem. Looking at
> drivers/mtd/nand/raw/am335x_spl_bch.c we've always had nand_page_size()
> return nand_to_mtd(&nand_chip)->writesize and I assume that should have
> been being set to CONFIG_SYS_NAND_PAGE_SIZE but I don't see that as the
> case. If you change nand_page_size to just return
> CONFIG_SYS_NAND_PAGE_SIZE or nand_init to set writesize to
> CONFIG_SYS_NAND_PAGE_SIZE does it then work again?

yes, the following change makes the system bootable again:

diff --git a/drivers/mtd/nand/raw/am335x_spl_bch.c
b/drivers/mtd/nand/raw/am335x_spl_bch.c
index 4b50f351d35..a77206d3815 100644
--- a/drivers/mtd/nand/raw/am335x_spl_bch.c
+++ b/drivers/mtd/nand/raw/am335x_spl_bch.c
@@ -212,6 +212,8 @@ void nand_init(void)
        if (nand_chip.select_chip)
                nand_chip.select_chip(mtd, 0);

+       mtd->writesize = CONFIG_SYS_NAND_PAGE_SIZE;
+
        /* NAND chip may require reset after power-on */
        nand_command(0, 0, 0, NAND_CMD_RESET);
 }

Yegor


More information about the U-Boot mailing list