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.

AM572x IDK SPI Flash Problem

Other Parts Discussed in Thread: AM5728, PMP

My customer has been having a problem getting the spi flash to save the environment variables.

He added this to am57xx_evm.h config file:

#define CONFIG_SPI_BOOT
#if defined(CONFIG_SPI_BOOT)
# undef CONFIG_ENV_IS_NOWHERE
# define CONFIG_ENV_IS_IN_SPI_FLASH
# define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
# define CONFIG_ENV_OFFSET 0x1D0000
# define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */
#endif  /*SPI support*/

but when uboot reads the environment he gets garbage back, the CRC's aren't matching.  Do you have any idea why?

He suspects that the SPI flash or driver isn't fully initialized when it tries to read the environment variables from flash and that's why he is receiving a CRC fail, but even after saving the environment variables to flash and re-reading them, they are not being retained after a boot.

Thanks. 

  • Biser,

    I believe this would be PROCESSOR-SDK-LINUX-AM57X v3.00.00 (Linux Kernel v4.4.12)

    - David
  • Thanks, I will notify the software team.
  • Dave,

    So, if he saves them, and then reads them back immediately, do they look right?

    If so, then he reboots and the environment is not what is expected?

    Can you post a log trace of these operations?

    Thanks.

  • Ron

    After he reads them once saved they don't look correct. Also below are the changes that was done to u-boot source. Not sure if we have to change other stuff on the u-boot source.

    I can get you the serial output of the commands in uboot also if you want.

    I hve added this to my am57xx_evm.h config file
    #define CONFIG_SPI_BOOT
    #if defined(CONFIG_SPI_BOOT)
    # undef CONFIG_ENV_IS_NOWHERE
    # define CONFIG_ENV_IS_IN_SPI_FLASH
    # define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
    # define CONFIG_ENV_OFFSET 0x1D0000
    # define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */
    #endif  /*SPI support*/

    Regards

    Mohsen

  • Ron
    sorry i forgot to add the other stuff below is what he has in the am57xx_evm.h

    /*
    * (C) Copyright 2014
    * Texas Instruments Incorporated.
    * Felipe Balbi <balbi@ti.com>
    *
    * Configuration settings for the TI Beagle x15 board.
    * See ti_omap5_common.h for omap5 common settings.
    *
    * SPDX-License-Identifier: GPL-2.0+
    */

    #ifndef __CONFIG_AM57XX_EVM_H
    #define __CONFIG_AM57XX_EVM_H

    #define CONFIG_AM57XX

    #define CONFIG_IODELAY_RECALIBRATION

    #define CONFIG_BOARD_EARLY_INIT_F

    #define CONFIG_NR_DRAM_BANKS 2

    #define CONFIG_ENV_SIZE (64 << 10)

    /*
    #define FAT_ENV_INTERFACE "mmc"
    #define FAT_ENV_DEVICE_AND_PART "0:1"
    #define FAT_ENV_FILE "uboot.env"
    */

    #define CONFIG_SPI_BOOT
    #if defined(CONFIG_SPI_BOOT)
    # undef CONFIG_ENV_IS_NOWHERE
    # define CONFIG_ENV_IS_IN_SPI_FLASH
    # define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
    # define CONFIG_ENV_OFFSET 0x1C0000
    # define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */
    #endif /*SPI support*/

    #define CONSOLEDEV "ttyO2"
    #define CONFIG_SYS_NS16550_COM1 UART1_BASE /* Base EVM has UART0 */
    #define CONFIG_SYS_NS16550_COM2 UART2_BASE /* UART2 */
    #define CONFIG_SYS_NS16550_COM3 UART3_BASE /* UART3 */
    #define CONFIG_BAUDRATE 115200

    #define CONFIG_SYS_OMAP_ABE_SYSCK

    /* Define the default GPT table for eMMC */
    #define PARTS_DEFAULT \
    "uuid_disk=${uuid_gpt_disk};" \
    "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}"

    #include <configs/ti_omap5_common.h>

    /* Enhance our eMMC support / experience. */
    #define CONFIG_CMD_GPT
    #define CONFIG_EFI_PARTITION

    /* CPSW Ethernet */
    #define CONFIG_BOOTP_DNS /* Configurable parts of CMD_DHCP */
    #define CONFIG_BOOTP_DNS2
    #define CONFIG_BOOTP_SEND_HOSTNAME
    #define CONFIG_BOOTP_GATEWAY
    #define CONFIG_BOOTP_SUBNETMASK
    #define CONFIG_NET_RETRY_COUNT 10
    #define CONFIG_DRIVER_TI_CPSW /* Driver for IP block */
    #define CONFIG_MII /* Required in net/eth.c */
    #define CONFIG_PHY_GIGE /* per-board part of CPSW */
    #define CONFIG_PHYLIB
    #define PHY_ANEG_TIMEOUT 8000 /* PHY needs longer aneg time at 1G */

    #define CONFIG_SUPPORT_EMMC_BOOT

    /* USB xHCI HOST */
    #define CONFIG_USB_HOST
    #define CONFIG_USB_XHCI_DWC3
    #define CONFIG_USB_XHCI
    #define CONFIG_USB_XHCI_OMAP
    #define CONFIG_USB_STORAGE
    #define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2

    #define CONFIG_OMAP_USB_PHY
    #define CONFIG_OMAP_USB3PHY1_HOST

    /* SATA */
    #define CONFIG_BOARD_LATE_INIT
    #define CONFIG_CMD_SCSI
    #define CONFIG_LIBATA
    #define CONFIG_SCSI_AHCI
    #define CONFIG_SCSI_AHCI_PLAT
    #define CONFIG_SYS_SCSI_MAX_SCSI_ID 1
    #define CONFIG_SYS_SCSI_MAX_LUN 1
    #define CONFIG_SYS_SCSI_MAX_DEVICE (CONFIG_SYS_SCSI_MAX_SCSI_ID * \
    CONFIG_SYS_SCSI_MAX_LUN)

    /* EEPROM */
    #define CONFIG_EEPROM_CHIP_ADDRESS 0x50
    #define CONFIG_EEPROM_BUS_ADDRESS 0

    /*
    * Default to using SPI for environment, etc.
    * 0x000000 - 0x040000 : QSPI.SPL (256KiB)
    * 0x040000 - 0x140000 : QSPI.u-boot (1MiB)
    * 0x140000 - 0x1C0000 : QSPI.u-boot-spl-os (512KiB)
    * 0x1C0000 - 0x1D0000 : QSPI.u-boot-env (64KiB)
    * 0x1D0000 - 0x1E0000 : QSPI.u-boot-env.backup1 (64KiB)
    * 0x1E0000 - 0x9E0000 : QSPI.kernel (8MiB)
    * 0x9E0000 - 0x2000000 : USERLAND
    */
    #define CONFIG_SYS_SPI_KERNEL_OFFS 0x1E0000
    #define CONFIG_SYS_SPI_ARGS_OFFS 0x140000
    #define CONFIG_SYS_SPI_ARGS_SIZE 0x80000

    #ifdef CONFIG_SPL_BUILD
    #undef CONFIG_DM_SPI
    #undef CONFIG_DM_SPI_FLASH
    #undef CONFIG_SPL_MAX_SIZE
    #define CONFIG_SPL_MAX_SIZE (256 << 10) /* 256 KiB */
    #endif

    /* SPI SPL */
    #define CONFIG_SPL_SPI_SUPPORT
    #define CONFIG_SPL_DMA_SUPPORT
    #define CONFIG_TI_EDMA3
    #define CONFIG_SPL_SPI_LOAD
    #define CONFIG_SPL_SPI_FLASH_SUPPORT
    #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x40000

    /* SPI */
    #undef CONFIG_OMAP3_SPI
    #define CONFIG_TI_SPI_MMAP
    #define CONFIG_SF_DEFAULT_SPEED 76800000
    #define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
    #define CONFIG_QSPI_QUAD_SUPPORT

    #endif /* __CONFIG_AM57XX_EVM_H */

    Regards
    Mohsen
  • Got more info and exactly what is going on. When i do a saveenv it says it worked fine. Once i boot again i get a CRC error when it reads the env from the QSPI flash. Sounds like that the CRC routine when used for the QSPI env might be the issue but not sure. I have included the changes that i had to do to the am57xx_evm.h file below also.

    => saveenv
    Saving Environment to SPI Flash...
    SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB, mapped at 5c000000
    Erasing SPI flash...Writing to SPI flash...done
    =>
    U-Boot SPL 2016.05-00100-g052f3bf-dirty (Sep 16 2016 - 12:05:03)
    DRA752-GP ES2.0
    Trying to boot from SPI


    U-Boot 2016.05-00100-g052f3bf-dirty (Sep 16 2016 - 12:05:03 -0400)

    CPU : DRA752-GP ES2.0
    Model: TI AM5728 IDK
    Board: AM572x IDK REV 1.3B
    DRAM: 2 GiB
    MMC: no pinctrl for sdr104
    no pinctrl for ddr50
    no pinctrl for sdr50
    no pinctrl for sdr25
    no pinctrl for sdr12
    OMAP SD/MMC: 0, OMAP SD/MMC: 1
    SF: Detected S25FL256S_64K with page size 256 Bytes, erase size 64 KiB, total 32 MiB, mapped at 5c000000
    *** Warning - bad CRC, using default environment

    SCSI: SATA link 0 timeout.
    AHCI 0001.0300 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
    flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst
    scanning bus for devices...
    Found 0 device(s).
    Net:
    Warning: ethernet@48484000 using MAC address from ROM
    eth0: ethernet@48484000
    Hit any key to stop autoboot: 0
    MMC: no card present
    MMC: no card present
    MMC: no card present
    MMC: no card present
    ** First descriptor is NOT a primary desc on 1:1 **
    switch to partitions #0, OK
    mmc1(part 0) is current device
    ** First descriptor is NOT a primary desc on 1:1 **
    SD/MMC found on device 1

    #define CONFIG_ENV_SIZE            (64 << 10)
    /*
    #define CONFIG_ENV_IS_IN_FAT
    #define FAT_ENV_INTERFACE        "mmc"
    #define FAT_ENV_DEVICE_AND_PART        "0:1"
    #define FAT_ENV_FILE            "uboot.env"
    */

    #define CONFIG_QSPI_BOOT
    #if defined(CONFIG_QSPI_BOOT)
    # undef CONFIG_ENV_IS_NOWHERE
    # define CONFIG_ENV_IS_IN_SPI_FLASH
    # define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
    # define CONFIG_ENV_OFFSET 0x1C0000
    # define CONFIG_ENV_SECT_SIZE (64 << 10) /* 4 KB sectors */
    #endif  /*SPI support*/

    Any help would be great.

    Thanks

    Regards

    Mohsen