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: SPI NOR flash boot

Part Number: PROCESSOR-SDK-AM335X

Hi,

I m using AM335x processor for my project. Currently i m booting from Micro SD card.

I want to boot from SPI-Nor flash. My Device is M25P16-VMC6TP

I Cannot able to probe my device from UBoot.

U-boot-FMS#sf probe 0 0 0   
SF: unrecognized JEDEC id bytes: 20, 20, 15
Failed to initialize SPI flash at 0:0

I tried to initialize the spi with following link:

https://e2e.ti.com/support/embedded/linux/f/354/p/380964/1350572

I cannot find the exact location to perform this below action :

{
.id = 0x8014,
.pages_per_sector = 256,
.nr_sectors = 16,
.name = "M25PE80",
},
Can anyone help me to resolve this issue ?
  • Hi Biser,

    Thanks for the reply.
    My M25P16 spi-nor is not detecting @uboot level.

    As per mentioned above

    4. see if driver supports the chip you are using, for me ST M25PE80 support was not available so, i had to make    following    changes in the driver.
       I added following entry in the drivers/mtd/spi/st_micro.c in "stmicro_spi_flash_table[]" and now probe/read/write with    sf command works fine.

    1
    2
    3
    4
    5
    6
    {
    .id = 0x8014,
    .pages_per_sector = 256,
    .nr_sectors = 16,
    .name = "M25PE80",
    },

    I cannot find where to mention my device name in the Uboot Source.

    Can you help me to resolve it  ?

  • Hi Karthikeyan,

    AM335x TI EVM has SPI flash (64Mbit Winbond W25Q64) located on daughterboard, connected to McSPI0 module.

    You need to check if your SPI flash is connected also to McSPI0 and to the same pins. Regarding AM335x pinmux in u-boot refer to the below files:

    u-boot-2017.01/board/ti/am335x/mux.c
    u-boot-2017.01/arch/arm/dts/am335x-evm.c

    Regarding M25P16 porting in u-boot, you should explore the below files:

    u-boot-2017.01/drivers/mtd/spi/spi_flash_ids.c
    u-boot-2017.01/drivers/mtd/st_smi.c

    You should change from WINBOND to STMICRO in the below file:
    u-boot-2017.01/configs/am335x_evm_spiboot_defconfig


    stmicro_spi_flash_table[] is not valid for u-boot-2017.01.

  • Hi pavel,

    Its really helpful.

    I have configured the things which you mentioned. Even though the device doesn't found

    The pin configuration from the am335x-evm.dts file is mentioned below.

            volume_keys_s0: volume_keys_s0 {
                    pinctrl-single,pins = <
                            0x150 (PIN_INPUT_PULLDOWN | MUX_MODE7)  /* spi0_sclk.gpio0_2 */
                            0x154 (PIN_INPUT_PULLDOWN | MUX_MODE7)  /* spi0_d0.gpio0_3 */
                    >;
            };

    0x150 is representing what ?

            i2c1_pins: pinmux_i2c1_pins {
                    pinctrl-single,pins = <
                            0x158 (PIN_INPUT_PULLUP | MUX_MODE2)    /* spi0_d1.i2c1_sda */
                            0x15c (PIN_INPUT_PULLUP | MUX_MODE2)    /* spi0_cs0.i2c1_scl */
                    >;
            };

            mmc1_pins: pinmux_mmc1_pins {
                    pinctrl-single,pins = <
                            0x160 (PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
                    >;
            };

    There is no mux between the am335x and spi-nor.

    Anything I need to change related to M25P16 ?

  • Karthikeyan R said:

    The pin configuration from the am335x-evm.dts file is mentioned below.

            volume_keys_s0: volume_keys_s0 {
                    pinctrl-single,pins = <
                            0x150 (PIN_INPUT_PULLDOWN | MUX_MODE7)  /* spi0_sclk.gpio0_2 */
                            0x154 (PIN_INPUT_PULLDOWN | MUX_MODE7)  /* spi0_d0.gpio0_3 */
                    >;
            };

    0x150 is representing what ?

    0x150 is the offset of the pinctrl-single, 0x44E10000 + 0x800 + 0x150, full address is 0x44E10950, this is conf_spi0_sclk register, this register is described in AM335x TRM. You should set it to muxmode 0 (spi0_sclk), not to muxmode 7 (gpio0_2).

    l4_wkup (0x44c00000) + scm (0x210000) + am33xx_pinmux (0x800) + spi0_sclk (0x150)

    This is valid also for rest of the McSPI0 pinmux registers.

    Regards,
    Pavel

  • Hi Pavel,

    Thanks for the reply. I thinks it progressing

    I changed the modes as per your instructions. I kept the MLO and the U-boot in the SD card.

    ******************************************
    U-Boot SPL 2017.01-g9fd60700db (Nov 17 2017 - 11:35:12)
    Trying to boot from MMC1 [But my current device is MMC 0 – SD card ]
    reading uboot.env

    ** Unable to read "uboot.env" from mmc0:1 **
    Using default environment

    reading u-boot.img
    reading u-boot.img
    *********************************************

    and its Strucking here.

    I m not getting the u-boot prompt. I think i need to flash the uboot and MLO into the spi-nor
    How to flash ? From where i need to proceed the operation.
  • Karthikeyan,

    Once you port your SPI NOR flash in u-boot source code (we already discussed how) you should build new MLO/SPL and u-boot files using the am335x_evm_spiboot_defconfig file. Do not forget to change from WINBOND to STMICRO in this file.

    Then you should place these new MLO/SPL and u-boot files in the SD card, boot from this SD card and flash MLO/SPL and u-boot files into the SPI flash. Then power off the board, change sysboot pins from SD boot to SPI boot, and power on.

    For more detail how to build u-boot source code for SPI boot and then how to flash in SPI, refer to the u-boot user guide:

    processors.wiki.ti.com/.../Linux_Core_U-Boot_User's_Guide

    Regards,
    Pavel
  • Hi pavel,

    Thanks for the reply.
    I can able to probe my device now.

    Hit any key to stop autoboot: 0
    => sf probe 0
    SF: Detected m25p16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB

    I am following the below steps to flash.

    => sf erase 0 +80000
    SF: 524288 bytes @ 0x0 Erased: OK
    => fatload mmc 0 ${loadaddr} MLO
    reading MLO
    62404 bytes read in 10 ms (6 MiB/s)

    => setenv filesize 0xf3c4
    => sf write ${loadaddr} 0 ${filesize}
    device 0 offset 0x0, size 0xf3c4
    SF: 62404 bytes @ 0x0 Written: OK
    => fatload mmc 0 ${loadaddr} u-boot.img
    reading u-boot.img
    359104 bytes read in 38 ms (9 MiB/s)

    => setenv filesize 0x57ac0
    => sf write ${loadaddr} 0x20000 ${filesize}
    device 0 offset 0x20000, size 0x57ac0
    SF: 359104 bytes @ 0x20000 Written: OK

    But my Board is not booting Once I remove the SD card.
    I cannot find the issue, Am I doing anything wrong ?
    Help to me to resolve this issue.

    I have tried with the working windows MLO aslo.

    That also not booting. Is my flash commands are correct ?

  • Karthikeyan R said:
    => fatload mmc 0 ${loadaddr} MLO
    reading MLO
    62404 bytes read in 10 ms (6 MiB/s)

    Please use MLO.byteswap file instead of MLO, when flashing the SPI. MLO.byteswap is used for SPI boot, MLO is used for SD card boot.

    Regards,
    Pavel

  • Hi Paval,

    Thanks for the reply. I just changed the MLO file into MLO.byteswap.
    Its Booting from SPI-NOR.

    *****************************************************************
    U-Boot SPL 2017.01-g9fd60700db (Nov 21 2017 - 20:19:45)
    SPL: Unsupported Boot Device!
    SPL: failed to boot from all boot devices
    ### ERROR ### Please RESET the board ###
    ******************************************************************

    I m getting this prompt continuously.

    Commands used for flashing:


    U-boot-FMS#sf erase 0 +80000
    SF: 524288 bytes @ 0x0 Erased: OK

    U-boot-FMS#fatload mmc 0 ${loadaddr} spi/MLO.byteswap (spi is my folder name)
    reading spi/MLO.byteswap
    71364 bytes read in 14 ms (4.9 MiB/s)
    U-boot-FMS#sf write ${loadaddr} 0 0x116c4
    device 0 offset 0x0, size 0x116c4
    SF: 71364 bytes @ 0x0 Written: OK

    U-boot-FMS#fatload mmc 0 ${loadaddr} spi/u-boot.img
    reading spi/u-boot.img
    445096 bytes read in 50 ms (8.5 MiB/s)

    U-boot-FMS#sf write ${loadaddr} 0x20000 0x6caa8
    device 0 offset 0x20000, size 0x6caa8
    SF: 445096 bytes @ 0x20000 Written: OK
    U-boot-FMS#reset

    plz help me to proceed further

  • Hi paval,

    Thanks for the support.
    It Works. Successfully booted from SPI-NOR with your support.
  • Karthikeyan,

    I am glad to see you have fix it. Could you please share what was the last fix you have applied? Could you also close/verify/resolve this thread.

    Regards,
    Pavel
  • Hi ,

    I was using my custom defconfig file. It doesn't have some flags enabled.
    I modified with respect spi-defconfig. It works.
    Thank you.
  • Thanks for the info.

    Could you also close/verify/resolve this thread.

    Regards,
    Pavel