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.

Linux/AM3359: spi flash programming

Other Parts Discussed in Thread: AM3359

Tool/software: Linux

Board Schematic Explanation:

In my AM3359 based custom board, SPI flash

Manufacturer: Micron

is connected to AM3359 & ARTIX-7 FPGA as shown in the figure below.

Our application is Master _Slave Programming of the FPGA

wherein Master- AM3359 will first write the boot file to the flash & then the Master AM3359 will read the file from the flash which eventually will be written to the FPGA i.e. the SLAVE.

Issue Faced:

When we tried to write the file from AM3359 to the SPI Flash, we found that the device driver is not available in the SDK. Please let us know if the flash part (details mentioned above) is supported by the processor.

Regards,

Vamsi

  • Please post which Linux version you use.
  • ti-processor-sdk-linux-am335x-evm-05.00.00.15_3

    ubuntu 14.14 LTS

    block_diag.pdf

  • Vamsi,

    Yes, seems to me that this SPI flash is supported in AM335x PSDK Linux. Check below files:

    linux-kernel/drivers/mtd/devices/m25p80.c
    linux-kernel/drivers/mtd/spi-nor/spi-nor.c

    You need to use below string in your DTS file:

    compatible = "n25q256a", "jedec,spi-nor";

    See for example the below e2e thread:

    e2e.ti.com/.../2712319

    You should use at least "jedec,spi-nor" in your DTS file.

    Regards,
    Pavel
  • HI Pavel Botev



    included the following line in both the dts files, uboot and in linux
    compatible = "n25q256a", "jedec,spi-nor";

    even after that i am getting the following error

    => sf probe 0
    SF: unrecognized JEDEC id bytes: ff, ff, ff
    Failed to initialize SPI flash at 0:0


    NOTE: our dts details as follows


    1.


    spi0_pins: spi0_pins {
    pinctrl-single,pins = <
    AM33XX_IOPAD(0x950, PIN_OUTPUT_PULLUP | MUX_MODE0) //spi0_sclk
    AM33XX_IOPAD(0x954, PIN_OUTPUT_PULLUP | MUX_MODE0) //spi0_d0
    AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0) //spi0_d1
    AM33XX_IOPAD(0x95c, PIN_OUTPUT | MUX_MODE0) //spi0_cs0
    >;
    };




    2.


    &spi0 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins>;

    spi_nor: flash@0 {
    #address-cells = <1>;
    #size-cells = <1>;
    #compatible = "jedec,spi-nor";
    compatible = "n25q256a", "jedec,spi-nor";
    spi-max-frequency = <24000000>;
    m25p,fast-read;
    reg = <0>;

    partition@0 {
    label = "u-boot-spl";
    reg = <0x0 0x80000>;
    read-only;
    };

    partition@1 {
    label = "u-boot";
    reg = <0x80000 0x100000>;
    read-only;
    };

    partition@2 {
    label = "u-boot-env";
    reg = <0x180000 0x20000>;
    read-only;
    };

    partition@3 {
    label = "misc";
    reg = <0x1A0000 0x1E60000>;
    };
    };
    };
  • Vamsi,

    Vamsi Siddhani said:
    even after that i am getting the following error

    => sf probe 0
    SF: unrecognized JEDEC id bytes: ff, ff, ff
    Failed to initialize SPI flash at 0:0


    NOTE: our dts details as follows

    From what I understand, this console log (sf probe 0) and DTS file at for u-boot, is that correct?

    Vamsi Siddhani said:
    spi0_pins: spi0_pins {
    pinctrl-single,pins = <
    AM33XX_IOPAD(0x950, PIN_OUTPUT_PULLUP | MUX_MODE0) //spi0_sclk
    AM33XX_IOPAD(0x954, PIN_OUTPUT_PULLUP | MUX_MODE0) //spi0_d0
    AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0) //spi0_d1
    AM33XX_IOPAD(0x95c, PIN_OUTPUT | MUX_MODE0) //spi0_cs0

    You need to change spi0_sclk from output only, to in/out. See AM335x TRM section 24.2.3 McSPI Pin List

    SPIx_SCLK - This output signal is also used as a re-timing input. The associated CONF_<module>_<pin>_RXACTIVE bit for the output clock
    must be set to 1 to enable the clock input back to the module.

    Then at u-boot stage, please provide:

    - register dump of the McSPI0 pinmux register (conf_spi0_sclk, conf_spi0_d0, conf_spi0_d1, conf_spi0_cs0)

    - register dump of the McSPI0 register

    You cam make the register dump with the u-boot "md" command.

    Regards,
    Pavel

  • Hi Fragline,


    Following is the dumped McSPI0 registers using md command in u-boot

    => md 0x48030110 0xA0
    48030110: 00000311 00000001 00000001 00000000 ................
    48030120: 00000000 00000000 00000001 00010fcb ................
    48030130: 00000006 00000001 00000000 ffffffff ................
    48030140: 00060000 00000000 00000000 00000000 ................
    48030150: 00000000 00060000 00000000 00000000 ................
    48030160: 00000000 00000000 00060000 00000000 ................
    48030170: 00000000 00000000 00000000 00000000 ................
    48030180: 00000000 00000000 00000000 00000000 ................
    48030190: 00000000 00000000 00000000 00000000 ................
    480301a0: 00000000 00000000 00000000 00000000 ................
    480301b0: 00000000 00000000 00000000 00000000 ................
    480301c0: 00000000 00000000 00000000 00000000 ................
    480301d0: 00000000 00000000 00000000 00000000 ................
    480301e0: 00000000 00000000 00000000 00000000 ................
    480301f0: 00000000 00000000 00000000 00000000 ................
    48030200: 00000000 00000000 00000000 00000000 ................
    48030210: 00000000 00000000 00000000 00000000 ................
    48030220: 00000000 00000000 00000000 00000000 ................
    48030230: 00000000 00000000 00000000 00000000 ................
    48030240: 00000000 00000000 00000000 00000000 ................
    48030250: 00000000 00000000 00000000 00000000 ................
    48030260: 00000000 00000000 00000000 00000000 ................
    48030270: 00000000 00000000 00000000 00000000 ................
    48030280: 00000000 00000000 00000000 00000000 ................
    48030290: 00000000 00000000 00000000 00000000 ................
    480302a0: 00000000 00000000 00000000 00000000 ................
    480302b0: 00000000 00000000 00000000 00000000 ................
    480302c0: 00000000 00000000 00000000 00000000 ................
    480302d0: 00000000 00000000 00000000 00000000 ................
    480302e0: 00000000 00000000 00000000 00000000 ................
    480302f0: 00000000 00000000 00000000 00000000 ................
    48030300: 00000000 00000000 00000000 00000000 ................
    48030310: 00000000 00000000 00000000 00000000 ................
    48030320: 00000000 00000000 00000000 00000000 ................
    48030330: 00000000 00000000 00000000 00000000 ................
    48030340: 00000000 00000000 00000000 00000000 ................
    48030350: 00000000 00000000 00000000 00000000 ................
    48030360: 00000000 00000000 00000000 00000000 ................
    48030370: 00000000 00000000 00000000 00000000 ................
    48030380: 00000000 00000000 00000000 00000000 ................


    I hope i have given you the exact info which u asked for

    I couldn't get the address for the following

    - register dump of the McSPI0 pinmux register (conf_spi0_sclk, conf_spi0_d0, conf_spi0_d1, conf_spi0_cs0)

    - register dump of the McSPI0 register?
  • Hi Pavel,

    Following is the dumped McSPI0 registers using md command in u-boot

    => md 0x48030110 0xA0
    48030110: 00000311 00000001 00000001 00000000 ................
    48030120: 00000000 00000000 00000001 00010fcb ................
    48030130: 00000006 00000001 00000000 ffffffff ................
    48030140: 00060000 00000000 00000000 00000000 ................
    48030150: 00000000 00060000 00000000 00000000 ................
    48030160: 00000000 00000000 00060000 00000000 ................
    48030170: 00000000 00000000 00000000 00000000 ................
    48030180: 00000000 00000000 00000000 00000000 ................
    48030190: 00000000 00000000 00000000 00000000 ................
    480301a0: 00000000 00000000 00000000 00000000 ................
    480301b0: 00000000 00000000 00000000 00000000 ................
    480301c0: 00000000 00000000 00000000 00000000 ................
    480301d0: 00000000 00000000 00000000 00000000 ................
    480301e0: 00000000 00000000 00000000 00000000 ................
    480301f0: 00000000 00000000 00000000 00000000 ................
    48030200: 00000000 00000000 00000000 00000000 ................
    48030210: 00000000 00000000 00000000 00000000 ................
    48030220: 00000000 00000000 00000000 00000000 ................
    48030230: 00000000 00000000 00000000 00000000 ................
    48030240: 00000000 00000000 00000000 00000000 ................
    48030250: 00000000 00000000 00000000 00000000 ................
    48030260: 00000000 00000000 00000000 00000000 ................
    48030270: 00000000 00000000 00000000 00000000 ................
    48030280: 00000000 00000000 00000000 00000000 ................
    48030290: 00000000 00000000 00000000 00000000 ................
    480302a0: 00000000 00000000 00000000 00000000 ................
    480302b0: 00000000 00000000 00000000 00000000 ................
    480302c0: 00000000 00000000 00000000 00000000 ................
    480302d0: 00000000 00000000 00000000 00000000 ................
    480302e0: 00000000 00000000 00000000 00000000 ................
    480302f0: 00000000 00000000 00000000 00000000 ................
    48030300: 00000000 00000000 00000000 00000000 ................
    48030310: 00000000 00000000 00000000 00000000 ................
    48030320: 00000000 00000000 00000000 00000000 ................
    48030330: 00000000 00000000 00000000 00000000 ................
    48030340: 00000000 00000000 00000000 00000000 ................
    48030350: 00000000 00000000 00000000 00000000 ................
    48030360: 00000000 00000000 00000000 00000000 ................
    48030370: 00000000 00000000 00000000 00000000 ................
    48030380: 00000000 00000000 00000000 00000000 ................


    I hope i have given you the exact info which u asked for

    I couldn't get the address for the following

    - register dump of the McSPI0 pinmux register (conf_spi0_sclk, conf_spi0_d0, conf_spi0_d1, conf_spi0_cs0)

    - register dump of the McSPI0 register?
  • Hi Pavel

    I could find the addresses for the McSPI0 pinmux register (conf_spi0_sclk, conf_spi0_d0, conf_spi0_d1, conf_spi0_cs0) which you asked for and following are the configures register statuses

    => md 0x44E10950 16
    44e10950: 00000020 00000030 00000020 00000030 ...0... ...0...
    44e10960: 00000037 00000027 00000037 00000037 7...'...7...7...
    44e10970: 00000030 00000000 00000037 00000037 0.......7...7...
    44e10980: 00000037 00000037 00000060 00000060 7...7...`...`...
    44e10990: 00000027 00000027 00000027 00000027 '...'...'...'...
    44e109a0: 00000024 00000027 $...'...

    i.e
    conf_spi0_sclk = 0x00000020
    conf_spi0_d0 = 0x00000030
    conf_spi0_d1 = 0x00000020
    conf_spi0_cs0 = 0x0000030
  • Vamsi,

    MCSPI_CH0CONF/0x4803012C = 0x00010fcb

    Your current configuration is for:

    AM335x pin spi0_d0 is input, should be connected to SPI NOR device DOUT pin
    AM335x pin spi0_d1 is output, should be connected to SPI NORl device DIN pin.

    Is your board schematic align with this?

    Can you also change below string back to "jedec, spi-not" only and try again:

    compatible = "jedec,spi-nor";

    Can you also provide the console boot up log?

    I can also suggest you to:

    - check what activity there is on the SPI0 lines with an oscilloscope?
    - enable debug messages in below u-boot file and see if you will have more verbose output

    u-boot/drivers/mtd/spi/spi_flash.c
    u-boot/drivers/mtd/spi/sf_probe.c
    u-boot/cmd/sf.c


    Regards,
    Pavel