AM3354: AM3354 U-Boot failed to boot from NAND and solution found

Part Number: AM3354

Tool/software:

The "spl_nand_read" function in "spl_nand.c" use nand_page_size() to get NAND page size, but it's not initialized in SPL.

https://git.ti.com/cgit/ti-u-boot/ti-u-boot/tree/common/spl/spl_nand.c#n62

static ulong spl_nand_read(struct spl_load_info *load, ulong offs, ulong size,
			   void *dst)
{
	int err;
	ulong sector;

	debug("%s: offs %lx, size %lx, dst %p\n",
	      __func__, offs, size, dst);

	sector = *(int *)load->priv;
	offs = sector + nand_spl_adjust_offset(sector, offs - sector);
	err = nand_spl_load_image(offs, size, dst);
	spl_set_bl_len(load, nand_page_size());
	if (err)
		return 0;

	return size;
}

The fix is set "mtd->writesize" to CONFIG_SYS_NAND_PAGE_SIZE in nand_init() from drivers/mtd/nand/raw/am335x_spl_bch.c,

so that nand_page_size() API works in SPL.

diff --git a/drivers/mtd/nand/raw/am335x_spl_bch.c b/drivers/mtd/nand/raw/am335x_spl_bch.c
index 4b50f351d35..cb10fb9ac49 100644
--- a/drivers/mtd/nand/raw/am335x_spl_bch.c
+++ b/drivers/mtd/nand/raw/am335x_spl_bch.c
@@ -209,6 +209,9 @@ void nand_init(void)
                (void  __iomem *)CFG_SYS_NAND_BASE;
        board_nand_init(&nand_chip);
 
+       // Ensure SPL knows the page size, so nand_page_size() works in SPL.
+       mtd->writesize = CONFIG_SYS_NAND_PAGE_SIZE;
+
        if (nand_chip.select_chip)
                nand_chip.select_chip(mtd, 0);
 

  • I'm using the latest commit c5737097b4859362aa22260c5a1f2becd62af65c from ti-u-boot-2025.01 branch,

    could anyone upstream confirm the bug, include the fix in the next release, thanks.

  • Hi Ted,
    Thanks for reporting the issue with a potential fix.
    1/. Have you tested with AM335x Linux SDK 9.3.5.2
    https://www.ti.com/tool/download/PROCESSOR-SDK-LINUX-AM335X/09.03.05.02
    2/. Was your test done on TI board or customer one?
    Best,
    -Hong

  • Hi Hong,

    As I'm building Yocto image for our custom board, and updating u-boot from ti-u-boot-2021.01 to ti-u-boot-2025.01,

    So my test is done on our custom board, we don't have a TI board to test.

     

    Had a look at AM335x Linux SDK 9.3.5.2, the CI suggests it can boot correctly for am335x-evm,

    Not sure if the TI CI tests are booting from SD card or NAND ?

    https://software-dl.ti.com/cicd-report/linux/index.html?section=snapshot&platform=am335x&snapshot=cicd.scarthgap.202508281316

  • Hi Ted,
    The gpmc-nand booting works with AM335x Linux SDK 9.3.5.2.
    I'm attaching the gpmc-nand flashing/booting logs for your reference.
    Best,
    -Hong

    U-Boot SPL 2023.04-ti-g2a13324ec63c (Dec 04 2024 - 17:27:55 +0000)
    Trying to boot from MMC1
    
    
    U-Boot 2023.04-ti-g2a13324ec63c (Dec 04 2024 - 17:27:55 +0000)
    
    CPU  : AM335X-GP rev 2.1
    Model: TI AM335x EVM
    DRAM:  1 GiB
    Core:  156 devices, 17 uclasses, devicetree: separate
    WDT:   Started wdt@44e35000 with servicing every 1000ms (60s timeout)
    NAND:  256 MiB
    MMC:   OMAP SD/MMC: 0
    Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... 
    <ethaddr> not set. Validating first E-fuse MAC
    Net:   eth2: ethernet@4a100000, eth3: usb_ether
    Hit any key to stop autoboot:  2  0 
    => md.l 0x44e10040 1
    44e10040: 00400397                             ..@.
    => nand erase.chip
    
    NAND erase.chip: device 0 whole chip
    
    Erasing at 0x0 --   0% complete.
    Erasing at 0x280000 --   1% complete.
    Erasing at 0x500000 --   2% complete.
    Erasing at 0x7a0000 --   3% complete.
    Erasing at 0xa20000 --   4% complete.
    Erasing at 0xcc0000 --   5% complete.
    Erasing at 0xf40000 --   6% complete.
    Erasing at 0x11e0000 --   7% complete.
    Erasing at 0x1460000 --   8% complete.
    Erasing at 0x1700000 --   9% complete.
    Erasing at 0x1980000 --  10% complete.
    Erasing at 0x1c20000 --  11% complete.
    Erasing at 0x1ea0000 --  12% complete.
    Erasing at 0x2140000 --  13% complete.
    Erasing at 0x23c0000 --  14% complete.
    Erasing at 0x2660000 --  15% complete.
    Erasing at 0x28e0000 --  16% complete.
    Erasing at 0x2b80000 --  17% complete.
    Erasing at 0x2e00000 --  18% complete.
    Erasing at 0x30a0000 --  19% complete.
    Erasing at 0x3320000 --  20% complete.
    Erasing at 0x35c0000 --  21% complete.
    Erasing at 0x3840000 --  22% complete.
    Erasing at 0x3ae0000 --  23% complete.
    Erasing at 0x3d60000 --  24% complete.
    Erasing at 0x3fe0000 --  25% complete.
    Erasing at 0x4280000 --  26% complete.
    Erasing at 0x4500000 --  27% complete.
    Erasing at 0x47a0000 --  28% complete.
    Erasing at 0x4a20000 --  29% complete.
    Erasing at 0x4cc0000 --  30% complete.
    Erasing at 0x4f40000 --  31% complete.
    Erasing at 0x51e0000 --  32% complete.
    Erasing at 0x5460000 --  33% complete.
    Erasing at 0x5700000 --  34% complete.
    Erasing at 0x5980000 --  35% complete.
    Erasing at 0x5c20000 --  36% complete.
    Erasing at 0x5ea0000 --  37% complete.
    Erasing at 0x6140000 --  38% complete.
    Erasing at 0x63c0000 --  39% complete.
    Erasing at 0x6660000 --  40% complete.
    Erasing at 0x68e0000 --  41% complete.
    Erasing at 0x6b80000 --  42% complete.
    Erasing at 0x6e00000 --  43% complete.
    Erasing at 0x70a0000 --  44% complete.
    Erasing at 0x7320000 --  45% complete.
    Erasing at 0x75c0000 --  46% complete.
    Erasing at 0x7840000 --  47% complete.
    Erasing at 0x7ae0000 --  48% complete.
    Erasing at 0x7d60000 --  49% complete.
    Erasing at 0x7fe0000 --  50% complete.
    Erasing at 0x8280000 --  51% complete.
    Erasing at 0x8500000 --  52% complete.
    Erasing at 0x87a0000 --  53% complete.
    Erasing at 0x8a20000 --  54% complete.
    Erasing at 0x8cc0000 --  55% complete.
    Erasing at 0x8f40000 --  56% complete.
    Erasing at 0x91e0000 --  57% complete.
    Erasing at 0x9460000 --  58% complete.
    Erasing at 0x9700000 --  59% complete.
    Erasing at 0x9980000 --  60% complete.
    Erasing at 0x9c20000 --  61% complete.
    Erasing at 0x9ea0000 --  62% complete.
    Erasing at 0xa140000 --  63% complete.
    Erasing at 0xa3c0000 --  64% complete.
    Erasing at 0xa660000 --  65% complete.
    Erasing at 0xa8e0000 --  66% complete.
    Erasing at 0xab80000 --  67% complete.
    Erasing at 0xae00000 --  68% complete.
    Erasing at 0xb0a0000 --  69% complete.
    Erasing at 0xb320000 --  70% complete.
    Erasing at 0xb5c0000 --  71% complete.
    Erasing at 0xb840000 --  72% complete.
    Erasing at 0xbae0000 --  73% complete.
    Erasing at 0xbd60000 --  74% complete.
    Erasing at 0xbfe0000 --  75% complete.
    Erasing at 0xc280000 --  76% complete.
    Erasing at 0xc500000 --  77% complete.
    Erasing at 0xc7a0000 --  78% complete.
    Erasing at 0xca20000 --  79% complete.
    Erasing at 0xccc0000 --  80% complete.
    Erasing at 0xcf40000 --  81% complete.
    Erasing at 0xd1e0000 --  82% complete.
    Erasing at 0xd460000 --  83% complete.
    Erasing at 0xd700000 --  84% complete.
    Erasing at 0xd980000 --  85% complete.
    Erasing at 0xdc20000 --  86% complete.
    Erasing at 0xdea0000 --  87% complete.
    Erasing at 0xe140000 --  88% complete.
    Erasing at 0xe3c0000 --  89% complete.
    Erasing at 0xe660000 --  90% complete.
    Erasing at 0xe8e0000 --  91% complete.
    Erasing at 0xeb80000 --  92% complete.
    Erasing at 0xee00000 --  93% complete.
    Erasing at 0xf0a0000 --  94% complete.
    Erasing at 0xf320000 --  95% complete.
    Erasing at 0xf5c0000 --  96% complete.
    Erasing at 0xf840000 --  97% complete.
    Erasing at 0xfae0000 --  98% complete.
    Erasing at 0xfd60000 --  99% complete.
    Erasing at 0xffe0000 -- 100% complete.
    OK
    => nand info
    
    Device 0: nand0, sector size 128 KiB
      Page size         2048 b
      OOB size            64 b
      Erase size      131072 b
      ecc strength         8 bits
      ecc step size      512 b
      subpagesize        512 b
      options       0x4000400c
      bbt options   0x00008000
    => mtd
    
    device nand0 <nand.0>, # parts = 10
     #: name		size		offset		mask_flags
     0: NAND.SPL            0x00020000	0x00000000	0
     1: NAND.SPL.backup1    0x00020000	0x00020000	0
     2: NAND.SPL.backup2    0x00020000	0x00040000	0
     3: NAND.SPL.backup3    0x00020000	0x00060000	0
     4: NAND.u-boot-spl-os  0x00040000	0x00080000	0
     5: NAND.u-boot         0x00200000	0x000c0000	0
     6: NAND.u-boot-env     0x00020000	0x002c0000	0
     7: NAND.u-boot-env.backup10x00020000	0x002e0000	0
     8: NAND.kernel         0x00800000	0x00300000	0
     9: NAND.file-system    0x0f500000	0x00b00000	0
    
    active partition: nand0,0 - (NAND.SPL) 0x00020000 @ 0x00000000
    
    defaults:
    mtdids  : nand0=nand.0
    mtdparts: mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),2m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)
    => load mmc 0:1 ${loadaddr} MLO
    110356 bytes read in 11 ms (9.6 MiB/s)
    => nand write ${loadaddr} NAND.SPL ${filesize}
    
    NAND write: device 0 offset 0x0, size 0x1af14
     110356 bytes written: OK
    => load mmc 0:1 ${loadaddr} u-boot.img
    1453812 bytes read in 96 ms (14.4 MiB/s)
    => nand write ${loadaddr} NAND.u-boot ${filesize}
    
    NAND write: device 0 offset 0xc0000, size 0x162ef4
     1453812 bytes written: OK
    => load mmc 0:1 ${loadaddr} am335x-evm.dtb
    101861 bytes read in 9 ms (10.8 MiB/s)
    => nand write ${loadaddr} NAND.u-boot-spl-os ${filesize}
    
    NAND write: device 0 offset 0x80000, size 0x18de5
     101861 bytes written: OK
    => 

    U-Boot SPL 2023.04-ti-g2a13324ec63c (Dec 04 2024 - 17:27:55 +0000)
    Trying to boot from NAND
    
    
    U-Boot 2023.04-ti-g2a13324ec63c (Dec 04 2024 - 17:27:55 +0000)
    
    CPU  : AM335X-GP rev 2.1
    Model: TI AM335x EVM
    DRAM:  1 GiB
    Core:  156 devices, 17 uclasses, devicetree: separate
    WDT:   Started wdt@44e35000 with servicing every 1000ms (60s timeout)
    NAND:  256 MiB
    MMC:   OMAP SD/MMC: 0
    Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... 
    <ethaddr> not set. Validating first E-fuse MAC
    Net:   eth2: ethernet@4a100000, eth3: usb_ether
    Hit any key to stop autoboot:  2  0 
    => md.l 0x44e10040 1
    44e10040: 00400394                             ..@.
    => mtd
    
    device nand0 <nand.0>, # parts = 10
     #: name		size		offset		mask_flags
     0: NAND.SPL            0x00020000	0x00000000	0
     1: NAND.SPL.backup1    0x00020000	0x00020000	0
     2: NAND.SPL.backup2    0x00020000	0x00040000	0
     3: NAND.SPL.backup3    0x00020000	0x00060000	0
     4: NAND.u-boot-spl-os  0x00040000	0x00080000	0
     5: NAND.u-boot         0x00200000	0x000c0000	0
     6: NAND.u-boot-env     0x00020000	0x002c0000	0
     7: NAND.u-boot-env.backup10x00020000	0x002e0000	0
     8: NAND.kernel         0x00800000	0x00300000	0
     9: NAND.file-system    0x0f500000	0x00b00000	0
    
    active partition: nand0,0 - (NAND.SPL) 0x00020000 @ 0x00000000
    
    defaults:
    mtdids  : nand0=nand.0
    mtdparts: mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),2m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.file-system)
    => nand info
    
    Device 0: nand0, sector size 128 KiB
      Page size         2048 b
      OOB size            64 b
      Erase size      131072 b
      ecc strength         8 bits
      ecc step size      512 b
      subpagesize        512 b
      options       0x0000400c
      bbt options   0x00008000
    => 

  • Hi Hong,

    Thanks for sharing the log,

    looks like both logs are booting from MMC, as both showing loading enviroment variables from mmc0:1

    Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1...

    As the issue I report only affects NAND SPL boot stage,

    so flashing NAND and showing NAND info when booting from MMC works for me too.

    Only when trying to boot from NAND, it fails and print out log as following:

    U-Boot SPL 2025.01-00573-ga578b20f0017 (Sep 01 2025 - 16:07:08 +1200)
    Detected NAND width: 8
    SysBoot: 0x400b, Control Status: 0x0040030b
    XTAL: 24MHz
    Boot Mode: USB0, NAND, SPI0, MMC0
    Boot Device: NAND(5)
    PMIC INT status: 0x16
    Reset Cookie BCK1: 0x00, BCK2: 0x00, BCK3: 0x00
    Wakeup Source: Power Key
    Fuel Gauge flags(MSB): 0x02
    Trying to boot from NAND
    SPL: failed to boot from all boot devices

  • Hi Ted,
    I captured the two logs with AM335x Linux SDK 9.3.5.2 on AM335x EVM, where
    - "am3_9.3.5.2_nand_flash.log" is gpmc-nand flashing @u-boot which booted from SD as noted in the log

    Trying to boot from MMC1
    ...
    => md.l 0x44e10040 1
    44e10040: 00400397

    - "am3_9.3.5.2_nand_boot.log" is MOL/u-boot booting from gpmc-nand after flashing as noted in the log

    Trying to boot from NAND
    ...
    => md.l 0x44e10040 1
    44e10040: 00400394

    Best,
    -Hong

  • okay, thanks Hong for confirming the NAND boot does work for AM335x EVM,

    I'll mark this issue as resolved now, cheers.