This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM335X: Unable to boot via SPI NOR

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: TPS65217, TPS65910

Hello,

We have a custom board based on AM335x where we are trying to enable to boot from SPI NOR.

The board initially booted via NAND. We then connected the NOR chip we wanted to add on to SPI 0:0 and made sure it was being detected fine in u-boot and Kernel.

From u-boot, we copied the MLO.byteswap and u-boot.img to the NOR. We then set the sysboot flags to boot from SPI.

When doing so, I get the following error:

U-Boot SPL 2020.10-rc5-00029-g686882937c-dirty (Feb 07 2023 - 13:25:32 +0100)
Trying to boot from SPI
Invalid bus 0 (err=-19)
SPI probe failed.
Trying to boot from NAND

...

The defconfig differences from the am335x_evm_spiboot_defconfig and our defconfig file are below:

-AUTOBOOT_DELAY_STR "d"
-AUTOBOOT_KEYED y
-AUTOBOOT_PROMPT "Press SPACE to abort autoboot in %d seconds\n"
-AUTOBOOT_STOP_STR " "
-BLK y
-BOOTCOUNT_ENV y
-BOOTM_NETBSD n
-BOOTM_PLAN9 n
-BOOTM_RTEMS n
-BOOTM_VXWORKS n
-BOOTP_PREFER_SERVERIP y
-CMD_ASKENV y
-CMD_DFU y
-CMD_DM y
-CMD_EEPROM y
-CMD_ELF n
-CMD_ERASEENV y
-CMD_EXT4_WRITE y
-CMD_MTD y
-CMD_NAND_TRIMFFS y
-CMD_SPI y
-CMD_TIME y
-CMD_USB y
-D_HOST_IPADDR "192.168.1.40"
-D_IPADDR "192.168.1.90"
-D_KERNEL_NFS_LOCATION "/nfs/d_rootfs"
-DEBUG_UART y
-DEBUG_UART_ANNOUNCE y
-DEBUG_UART_BASE 0x44E09000
-DEBUG_UART_CLOCK 48000000
-DEBUG_UART_OMAP y
-DEBUG_UART_SHIFT 2
-DEFAULT_SPI_BUS 1
-DM_ETH y
-DM_ETH_PHY y
-DM_MDIO y
-DM_MTD y
-DM_USB y
-EFI_LOADER n
-FAT_WRITE y
-INPUT n
-LEGACY_IMAGE_FORMAT n
-MMC n
-NET_RANDOM_ETHADDR y
-NR_DRAM_BANKS 1
-PARTITIONS n
-PHY_TI_GENERIC y
-RGMII y
-SPI_BOOT y
-SPI_FLASH_MTD y
-SPI_FLASH_SPANSION y
-SPI_FLASH_SST y
-SPL_AM33XX_ENABLE_RTC32K_OSC n
-SPL_DM y
-SPL_DM_SEQ_ALIAS y
-SPL_LIBCOMMON_SUPPORT y
-SPL_LIBGENERIC_SUPPORT y
-SPL_NAND_BASE y
-SPL_NAND_DRIVERS y
-SPL_PAYLOAD "u-boot.img"
-SPL_SEPARATE_BSS y
-SPL_SERIAL_SUPPORT y
-SPL_SPI_FLASH_MTD y
-SPL_SPI_SUPPORT y
-SPL_SYS_MALLOC_SIMPLE y
-SPL_USE_ARCH_MEMCPY n
-SPL_USE_ARCH_MEMSET n
-SPL_YMODEM_SUPPORT y
-SYS_MALLOC_LEN 0x800000
-SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR n
-USB2_IN_FULLSPEED_ONLY y
-USB_GADGET_DOWNLOAD y
 BOOTCOMMAND "if printenv bootargs; then echo \"bootargs found\"; else setenv bootargs ${bootargs_ubi_forbid_erase}; fi; run boot_mode" -> "run findfdt; run init_console; run finduuid; run distro_bootcmd"
 DEFAULT_DEVICE_TREE "am335x-d" -> "am335x-evm"
 ENV_OFFSET 0x300000 -> 0x100000
+CLK y
+CLK_CDCE9XX y
+CLK_TI_CTRL y
+CLOCK_SYNTHESIZER y
+CMD_FLASH n
+CMD_SPL y
+CUSTOM_SYS_INIT_SP_ADDR 0x4030ff00
+DFU_MMC y
+DFU_TFTP y
+DM_PMIC y
+DYNAMIC_CRC_TABLE y
+ENV_IS_IN_FAT n
+ENV_OVERWRITE y
+FASTBOOT_CMD_OEM_FORMAT y
+FASTBOOT_FLASH y
+FASTBOOT_FLASH_MMC_DEV 1
+HAS_CUSTOM_SYS_INIT_SP_ADDR y
+LOGLEVEL 3
+MMC_HW_PARTITIONING n
+MMC_OMAP_HS y
+NET_RETRY_COUNT 10
+OF_BOARD_SETUP y
+OF_LIST "am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2 am335x-pocketbeagle"
+PHY_ATHEROS y
+PHY_SMSC y
+PMIC_TPS65217 y
+SPI_FLASH_STMICRO y
+SPI_FLASH_WINBOND y
+SPL_CLK y
+SPL_DM_MMC n
+SPL_DM_PMIC n
+SPL_EFI_PARTITION n
+SPL_ENV_IS_NOWHERE y
+SPL_FIT_IMAGE_TINY y
+SPL_FS_EXT4 n
+SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
+SPL_LOAD_FIT y
+SPL_MMC n
+SPL_NAND_SUPPORT n
+SPL_OF_TRANSLATE y
+SPL_POWER_TPS65910 y
+SPL_SPI y
+SPL_TI_SYSC y
+SPL_WDT n
+SYS_BOOTCOUNT_BE y
+SYS_BOOTM_LEN 0x1000000
+SYS_I2C_EEPROM_ADDR 0x50
+SYS_I2C_EEPROM_ADDR_LEN 2
+SYS_MAXARGS 64
+SYS_NAND_ONFI_DETECTION y
+SYS_NAND_OOBSIZE 0x40
+SYS_NAND_PAGE_SIZE 0x800
+SYS_NAND_U_BOOT_LOCATIONS y
+SYS_NAND_U_BOOT_OFFS 0xc0000
+SYS_SPL_MALLOC y
+SYS_SPL_MALLOC_SIZE 0x800000
+TIMESTAMP y
+TI_COMMON_CMD_OPTIONS y
+USB_FUNCTION_FASTBOOT y
+WDT y

The DTS file has the NOR aded like below:

&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
status = "okay";
ti,spi-num-cs = <1>;
ti,pindir-d0-out-d1-in = <0>;
u-boot,dm-spl;
spi_nor0: spi_nor@0 {
   reg = <0>;
   compatible = "spansion,s25fl512s", "jedec,spi-nor";
   u-boot,dm-pre-reloc;
   spi-max-frequency = <25000000>;
   spi-tx-bus-width = <1>;
   spi-rx-bus-width = <1>;
   spi-cpol;
   spi-cpha;
   status = "okay";
   };
};

Any pointers where we should be looking at?

Regards

  • U-Boot SPL 2020.10-rc5-00029-g686882937c-dirty (Feb 07 2023 - 13:25:32 +0100)
    Trying to boot from SPI
    Invalid bus 0 (err=-19)
    SPI probe failed.

    It looks the MLO is loaded by RBL from SPI, and SPL starts to run, and somehow fails to probe SPI when trying to load the next stage u-boot/dtbs from SPI.
    On AM335x EVM:
    => sf probe 0
    SF: Detected w25q64cv with page size 256 Bytes, erase size 4 KiB, total 8 MiB

    I'd think <am335x_evm_spiboot_defconfig> would be a good reference...
    Best,
    -Hong

  • Hi HOng,

    we have tried to get our config as close to the evm_spi_defconfig, but tht has not resolved the issue unfortunately.

  • Hello,
    Some general pointers:
    - check u-boot tree on the same SPI device support.
    - add "debug" in SPI driver in SPL/u-boot
    - use JTAG debugger if accessible on your board.
    Best,
    -Hong

  • Hello Hong,

    I added a bit more logging and updated by defconfig to match the evm_spi boot as much as I could. I see the following log now:

    => CCCCCCCC
    <debug_uart>
    spl_early_init
    uclass_resolve_seq
    uclass_find_device_by_seq
    frs:0 bn:-1
    uclass_find_device_by_seq
    frs:0 bn:0
      - -1 -1 'root_driver'
      - not found
    SPL malloc() before relocation used 0x6c bytes (0 KB)
    >>SPL: board_init_r()
    spl_init
    uclass_resolve_seq
    uclass_find_device_by_seq
    frs:0 bn:0
      - 0 -1 'serial@44e09000'
      - not found

    U-Boot SPL 2020.10-rc5-00029-g686882937c-dirty (Feb 08 2023 - 22:16:39 +0100)
    Trying to boot from SPI
    spl_load_image
    spl_spi_load_image
    spi_flash_probe
    spi_flash_probe_bus_cs: bn:0, cs:0, m:3
    uclass_get_device_by_seq
    uclass_find_device_by_seq
    frs:0 bn:0
      - not found
    uclass_find_device_by_seq
    frs:1 bn:0
      - not found
    Invalid bus 0 (err=-19)
    SPI probe failed.
     BUS   : 0
     CS    : 0
     SPEED : 24000000
     MODE  : 3
    SPL: Unsupported Boot Device!
    SPL: failed to boot from all boot devices
    ### ERROR ### Please RESET the board ###

    Does this imply SPL is not reading the DTS properly and not finding any devices on SPI bus? I understand at this point, SPL is just parsing the DTS and trying to get the device list rather than probing the hardware.

    Thanks

  • Hello,
    Here is an early e2e for your reference, where <Spansion s25fl216k> was used.
    e2e.ti.com/.../3762105
    Best,
    -Hong

  • Hi Hong,

    I have gone through almost all posts on the forum to see something similar, but in most cases the problem is resolved after the correct config, which unfortunately hasn't worked for us.

    Also, one thing we observed is that once ROM selected the NOR, the chip select line and other lines are never accessed. It seems SPL is not even trying to talk to the NOR. This ties in a bit to my above comment where I mentioned that may be SPL is not getting the device information correctly. Unfortunately, the SDK also does not have any DTS where SPI0 is being used to boot. Do you have a suggestion there?

    Regards

  • Hello,
    From your originl log, SPL is booted by RBL from SPI-NOR, right?
    The e2e reference in my last reply was using <Spansion s25fl216k>.
    I thought "compatible = "spansion,s25fl512s", "jedec,spi-nor";" is on your board?
    Best,
    -Hong

  • Hi Hong,

    I made some progress. I had to add u-boot,dm-spl to the SPI0 and spi_nor@0 block for the above error to go away. But now I have a different error.

    The u-boot version we are using is not as new as in the 8.3 SDK, but I understand boot from SPI is a supported feature from before that. So I don't want to upgrade u-boot for the time being.

    If you have a working dts, that would be very helpful. I will keep debugging in the meantime.

    Regards

  • Hi Hong,

    After adding SPI MTD support in config, I can see the SPL probing the NOR now, but I get this error:

    unrecognized JEDEC id bytes: ff, ff, ff
    spi_get_bus_and_cs: Error -2 in device probe.
    spi_get_bus_and_cs: Error path, created=0, device 'spiflash@0'
    SPI probe failed.

    It looks like I may be missing some hardware config to enable the NOR. In my board .c, I enable the following during SPL:

    /* SPI0 initialization */
    static struct module_pin_mux spi0_pin_mux[] = {
    {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_SCLK */
    {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_D0 */
    {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN )}, /* SPI0_D1 */
    {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, /* SPI0_CS0 */
    {-1},
    };
    void set_mux_conf_regs(void)
    {
    configure_module_pin_mux(rtc_pwr_on_rstn_pin_mux);
    configure_module_pin_mux(nand_pin_mux);
    configure_module_pin_mux(spi0_pin_mux);
    configure_module_pin_mux(gpio0_18_pin_mux);
    }

    Is there anything else I should enable here?

    Thanks and Regards

    Muktabh

  • Hello,
    It is good news on your progress on enabling SPI-NOR on your platform.
    From your original log, SPL is booted by RBL from SPI-NOR, right?
    => pinmux on SPI-NOR on your board works?
    Best,
    -Hong

  • Hi Hong,

    Yes, RBL boots via SPI-NOR, but SPL is not able to boot u-boot via SPI-NOR. I have set up the pinmux as I posted above. Do I need to do anything else? Is there a clock to be enabled specifically for SPI?

    Regards

  • Hi Hong,

    I changed the d0,d1 pin direction setting in my DTS and it fixed the issue. The pins were being swapped in SPL, so the command was sent to the NOR on its output line.

    Now, I am getting this error:

    U-Boot SPL 2020.10-rc5-00038-g171693d9c0-dirty (Feb 14 2023 - 15:43:23 +0100)
    > > Trying to boot from SPI
    > > No valid device tree binary found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>
    > > initcall sequence 8083e124 failed at call 80836db9 (err=-1)
    > > ### ERROR ### Please RESET the board ###


    Just to confirm, this error is from the SPL not finding the u-boot DTS correct?

    I used the following commands in u-boot to program the NOR when booted via NAND:
    > sf probe 0; sf erase 0 +80000;tftp MLO.byteswap
    > setenv filesize 0xMLOSize
    > sf write ${loadaddr} 0 ${filesize}; tftp u-boot.img
    > setenv filesize 0xubootimgSize
    > sf write ${loadaddr} 0x20000 ${filesize}

    As I understand, u-boot.img already has the DTB appended at the end.
    I use the CONFIG_OF_SEPARATE setting, and have set the SPL u-boot payload as u-boot.img and CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000
    in the .config file.

    Why is it not finding the DTB?

    Regards

  • Hello,
    I'd recommend to add "DEBUG" print, or use JTAG debugger if accessible to sort it out...
    Best,
    -Hong

  • Hi Hong,

    I was able to boot by setting the DTS to CONFIG_OF_EMBED rather than CONFIG_OF_SEPARATE. and disabling support for FIT image.  It works, but looks more like a hack as this option is not recommended.

    Not sure why the default tools and settings are not providing a working config.

    My NAND u-boot is using FIT image and CONFIG_OF_SEPARATE options and seems to be OK.

    Regards

    Muktabh

  • Hello,
    It is goood to know SPI-NOR boot started working on your setup.
    I think which option to use for packing DTB is user's choice...
    Best,
    -Hong