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.

AM335x General Purpose EVM SPI problem!!!



I have tried ALL MY BEST in searching google and TI support documents to get SPI communication in the TI’s AM335x General Purpose EVM Board (GPEVM). The debug terminal finally only show up the “/dev/spidev1.0” for spi driver to open. It seems everything is ok in the debug terminal when I trigger the SPI driver. HOWEVER, I still can’t see anything from the oscilloscope. Only AM335X_SPI0_CS0 pin goes down when I trigger the spi driver.

I measured 4 singles:

  1. (Expension Connector - EXP2) J5, Pin13 => AM335X_SPI0_SCLK => Nothing!
  2. (Expension Connector - EXP2) J5, Pin15 => AM335X_SPI0_D0 => Nothing!
  3. (Expension Connector – EXP0) J3, Pin23 => AM335X_SPI0_D1 => Nothing!
  4. (Expension Connector – EXP0) J3, Pin24 => AM335X_SPI0_CS0 => goes low when trigger.

Please anyone can help me?? PLEASE!!!

The following is what I have done so far:

1st step:

edit arch/arm/config/tisdk_am335x-evm_defconfig

Enable: CONFIG_SPI_SPIDEV=y

Then, all following steps I edited to enable spidev for TI's AM335x General Purpose EVM occur is in this file:

SDK/board-support/linux-3.2-psp04.06.00.07.sdk/arch/arm/mach-omap2/board-am335xevm.c

2nd Step:

edit this struct: "gen_purp_evm_dev_cfg[]"
static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
.....

// take this out

//    {spi0_init,    DEV_ON_DGHTR_BRD, PROFILE_2},

.....

// put this in
    {spi0_init, DEV_ON_BASEBOARD, PROFILE_0},
...

};

3rd Step: Revise the following struct

static struct spi_board_info am335x_spi0_slave_info[] = { 
  {
    .modalias = "spidev",
    .max_speed_hz = 1000000, 

    .irq = -1,
    .bus_num = 1, 
    .chip_select = 0,
    .mode = SPI_MODE_1 

    },
};

4th Step: Revise the following struct

static void spi0_init(int evm_id, int profile)
{
    setup_pin_mux(spi0_pin_mux);       
    spi_register_board_info(am335x_spi0_slave_info,
            ARRAY_SIZE(am335x_spi0_slave_info));
    return;
}

5th Step:Revise the following struct

static struct pinmux_config spi0_pin_mux[] = {
    {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT | AM33XX_PULL_UP | AM33XX_PULL_ENBL},
    {"spi0_d0.spi0_d0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},
    {"spi0_d1.spi0_d1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
    {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},
    {NULL, 0},
};

6th Step:

Re-compile Kernel and flash it to target board

 

7th Step:

Compiler  SDK/board-support/linux-3.2-psp04.06.00.07.sdk/Documentation/spi/spidev_test.c  and put it into NFS filesystem. Then, connect MOSI and MISO.

8th Step:

Power the EVM and type in:

#./spidev_test -D /dev/spidev1.0

It shows:

root@am335x-evm:~# ./spidev_test -D /dev/spidev1.0

mode = 0

spi mode: 0

bits per word: 8

max speed: 500000 Hz (500 KHz)

 

00 00 00 00 00 00

00 00 00 00 00 00

00 00 00 00 00 00

00 00 00 00 00 00

00 00 00 00 00 00

00 00 00 00 00 00

00 00

9th Step:

Obviously, there is something wrong. So, I disconnect MOSI and MISO and measure all these four singles with oscillscope. Only AM335X_SPI0_CS0 goes down when I trigger the driver.

Please anyone can help me?? PLEASE!!!

  • Do you remove any conflicting pins mux configuration?

    SPI signals can be used also for other purposes, that's why spi0_init is called only on boot profile PROFILE_2. I would suggest to select this boot profile using the dip switch and not to modify gen_purp_evm_dev_cfg. Consider also that some signals are muxed by the CPLD depending on its profile (do not know it that's the case). Otherwise try to avoid conflicting pins mux config: volume_keys_init, first of all, but also others.

    Regards, Max

  • After a quick check: yes, it's exactly you case, you need to set CPLD dip switch configuration to PROFILE_2, and then there should no need to modify gen_purp_evm_dev_cfg.

    See the following links and the document linked in the second page for all the details:
    http://processors.wiki.ti.com/index.php/AM335x_General_Purpose_EVM_HW_User_Guide#Configuration.2FSetup
    http://processors.wiki.ti.com/index.php/AM335x_General_Purpose_EVM_HW_User_Guide#Pin_Use_Description

    Max

  • Hi, Max,

    Thanks so much for the quick response!!

    Actually, I also have tried profile2 and measured the output with oscilloscope. The result when I trigger the SPI driver goes as following:

    In the debug terminal:

    root@am335x-evm:~# ./spidev_test -D /dev/spidev1.0

    mode = 0

    spi mode: 0

    bits per word: 8

    max speed: 500000 Hz (500 KHz)

    00 00 00 00 00 00

    00 00 00 00 00 00

    00 00 00 00 00 00

    00 00 00 00 00 00

    00 00 00 00 00 00

    00 00 00 00 00 00

    00 00

    Measured with oscilloscope:

    1. (Expension Connector - EXP2) J5, Pin13 => AM335X_SPI0_SCLK => constant low!
    2. (Expension Connector - EXP2) J5, Pin15 => AM335X_SPI0_D0 => constant high!
    3. (Expension Connector – EXP0) J3, Pin23 => AM335X_SPI0_D1 => constant high!
    4. (Expension Connector – EXP0) J3, Pin24 => AM335X_SPI0_CS0 => constant high!

     

    The following is what I have done so far for the profile2 in SDK/board-support/linux-3.2-psp04.06.00.07.sdk/arch/arm/mach-omap2/board-am335xevm.c

    1.          I changed MODE0 to MODE2:

    static struct pinmux_config spi0_pin_mux[] = {

            {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL

                                                            | AM33XX_INPUT_EN},

            {"spi0_d0.spi0_d0", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL | AM33XX_PULL_UP

                                                            | AM33XX_INPUT_EN},

            {"spi0_d1.spi0_d1", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL

                                                            | AM33XX_INPUT_EN},

            {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL | AM33XX_PULL_UP

                                                            | AM33XX_INPUT_EN},

            {NULL, 0},

    };

    I also tried this, AM335X_SPI0_SCLK change to constant high:

    static struct pinmux_config spi0_pin_mux[] = {

        {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT | AM33XX_PULL_UP | AM33XX_PULL_ENBL},

        {"spi0_d0.spi0_d0", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},

        {"spi0_d1.spi0_d1", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL | AM33XX_INPUT_EN},

        {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE2 | AM33XX_PULL_ENBL | AM33XX_PULL_UP | AM33XX_INPUT_EN},

        {NULL, 0},

    };

    2.          This struct remain no changed:

    static void spi0_init(int evm_id, int profile)

    {

            setup_pin_mux(spi0_pin_mux);

            spi_register_board_info(am335x_spi0_slave_info,

                            ARRAY_SIZE(am335x_spi0_slave_info));

            return;

    }

    3.          I changed .modalias to "spidev"

    static struct spi_board_info am335x_spi0_slave_info[] = {

            {

                    .modalias = "spidev",

                    .max_speed_hz = 1000000,

                    .irq = -1,

                    .bus_num = 1,

                    .chip_select = 0,

                    .mode = SPI_MODE_1

            },

    };

    4.          This struct remain no changed:

    static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {

    …..

    {spi0_init,     DEV_ON_DGHTR_BRD, PROFILE_2},

    ……

    };

     

    PLEASE HELP!! Thanks!!

  • Why do you modify pins mux mode configuration to OMAP_MUX_MODE2? You have to leave OMAP_MUX_MODE0 value to use these pins as SPI interface signals: as a reference have a look at the datasheet, page 40 SPI0_SCLK pin name as an example.



  • Hi, Max,

    Thanks SO SO SO SO much. The problem has been solved!!

    I  post the whole CORRECT process in the following for someone who may need in the future and BIG thank you again!!!

    1st step:

    edit arch/arm/config/tisdk_am335x-evm_defconfig

    Enable: CONFIG_SPI_SPIDEV=y

     

    Then, all following steps I edited to enable spidev for TI's AM335x General Purpose EVM occur is in this file:

    SDK/board-support/linux-3.2-psp04.06.00.07.sdk/arch/arm/mach-omap2/board-am335xevm.c

    2nd Step:

    This struct: "gen_purp_evm_dev_cfg[]"
    static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
    .....

    //put this line in:

        {spi0_init,    DEV_ON_DGHTR_BRD, PROFILE_2},

    .....

    };

    3rd Step: Revise the following struct

    static struct spi_board_info am335x_spi0_slave_info[] = { 
      {
        .modalias = "spidev",
        .max_speed_hz = 48000000, 

        .irq = -1,
        .bus_num = 1, 
        .chip_select = 0,
        .mode = SPI_MODE_1 

        },
    };

    4th Step: Revise the following struct

    static void spi0_init(int evm_id, int profile)
    {
        setup_pin_mux(spi0_pin_mux);       
        spi_register_board_info(am335x_spi0_slave_info,
                ARRAY_SIZE(am335x_spi0_slave_info));
        return;
    }

    5th Step:

    This following struct remain NO change:

    static struct pinmux_config spi0_pin_mux[] = {

            {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL

                                                            | AM33XX_INPUT_EN},

            {"spi0_d0.spi0_d0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP

                                                            | AM33XX_INPUT_EN},

            {"spi0_d1.spi0_d1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL

                                                            | AM33XX_INPUT_EN},

            {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP

                                                            | AM33XX_INPUT_EN},

            {NULL, 0},

    };

    6th Step:

    Re-compile Kernel and flash it to target board

     

    7th Step:

    Compiler  SDK/board-support/linux-3.2-psp04.06.00.07.sdk/Documentation/spi/spidev_test.c  and put it into NFS filesystem.

    8th Step:

    Power the EVM and type in:

    #./spidev_test -D /dev/spidev1.0

    It shows:

    root@am335x-evm:~# ./spidev_test -D /dev/spidev1.0

    mode = 0

    spi mode: 0

    bits per word: 8

    max speed: 500000 Hz (500 KHz)

     

    DB 5D E6 B6 B7 25

    40 00 00 00 00 11

    6D 49 CF 6D CC 59

    09 6B FD 18 96 64

    2C 2D 2D 64 6D FB

    1E A5 B6 2E 2A 8D

    60 04

    The MISO contents may come from spi flash. You may take spi flash chip out to use MISO on your own purpose!

    9th Step:

    You can measured these 4 SPI singles:

    1. (Expension Connector - EXP2) J5, Pin13 => AM335X_SPI0_SCLK
    2. (Expension Connector - EXP2) J5, Pin15 => AM335X_SPI0_D0
    3. (Expension Connector – EXP0) J3, Pin23 => AM335X_SPI0_D1
    4. (Expension Connector – EXP0) J3, Pin24 => AM335X_SPI0_CS0

     

    Done!

     

  • I forget one thing:

    One need to configure the CPLD to profile 2:

    lSW8[1] = OFF, SW8[2] = ON, SW8[3:4] = OFF

  • I'm trying to use SPI0 to connect to  SPI devices on my custom am335x board.

    but  kernel halt  when  booting the board:

    [    1.637420] ThumbEE CPU extension supported.
    [    1.642272] mux: Failed to setup hwmod io irq -22
    [    1.647796] Power Management for AM33XX family
    [    1.652984] Trying to load am335x-pm-firmware.bin (60 secs timeout)
    [    1.659973] Copied the M3 firmware to UMEM
    [    1.664978] sr_init: platform driver register failed
    [    1.675445] clock: disabling unused clocks to save power
    [    1.694671] Detected MACID=0:18:31:93:e4:a9
    [    1.700408] cpsw: Detected MACID = 00:18:31:93:e4:aa
    [    1.706604] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
    [    1.713745] Waiting for root device /dev/mmcblk0p2...

    My configuration for SPI0 is below:

    1,

    static struct pinmux_config spi0_pin_mux[] = {
     {"spi0_sclk.spi0_sclk", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL
           | AM33XX_INPUT_EN},
     {"spi0_d0.spi0_d0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP
           | AM33XX_INPUT_EN},
     {"spi0_d1.spi0_d1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL
           | AM33XX_INPUT_EN},
     {"spi0_cs0.spi0_cs0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP
           | AM33XX_INPUT_EN},
     {NULL, 0},
    };

    static struct spi_board_info am335x_spi0_slave_info[] = {
     {
      .modalias      = "spidev",
      .irq           = -1,
      .max_speed_hz  = 24000000,
      .bus_num       = 1,
       .chip_select   = 0,

      .mode        = SPI_MODE_0,
     },


    };

    3

    static void spi0_init(int evm_id, int profile)
    {
     setup_pin_mux(spi0_pin_mux);
     spi_register_board_info(am335x_spi0_slave_info, 
      ARRAY_SIZE(am335x_spi0_slave_info));  
     
      return;
    }

    4  

     {spi0_init, DEV_ON_BASEBOARD, PROFILE_ALL},

    I find that the Linux kernel  called  spidev_probe function.

    Any idea for the issue? thanks!

  • I solved the issue,  but I don't know why.

    I only modified the position of spi0_init  as below:

     
    // {spi0_init, DEV_ON_BASEBOARD, PROFILE_ALL}, //

     {mcasp0_init, DEV_ON_BASEBOARD, PROFILE_ALL},
     {evm_nand_init, DEV_ON_BASEBOARD, PROFILE_ALL},
            {mmc0_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
     {usb0_init, DEV_ON_BASEBOARD, PROFILE_ALL},
     {usb1_init, DEV_ON_BASEBOARD, PROFILE_ALL},
     {wl12xx_init,   DEV_ON_BASEBOARD, PROFILE_ALL},
            {mfd_tscadc_init, DEV_ON_BASEBOARD, PROFILE_ALL},

    {spi0_init, DEV_ON_BASEBOARD, PROFILE_ALL},