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.

SPI Interface error Message(OMAP-L137)

Hi, I use L137.

I want spi interface.

I success /dev/spidev0.0

spi.c

    [0]={
      .modalias = "spidev",
      .mode = SPI_MODE_0,
      .max_speed_hz = 6500000,    /* max sample rate at 3V */
      .bus_num=1,
      .chip_select=0,

    }

When you run the test program, an error occurs.(spidev_test.c)

The error message is as follows.

//=====================================

Internal error: Oops: 17 [#1]                                                   
Modules linked in:                                                              
CPU: 0                                                                          
PC is at davinci_spi_bufs_prep+0xc/0x47c                                        
LR is at davinci_spi_bufs_dma+0xec/0x49c                                        
pc : [<c0230fa4>]    lr : [<c023228c>]    Not tainted                           
sp : c04d5ea0  ip : c04d5eb0  fp : c04d5eac                                     
r10: c04d4000  r9 : c04f3800  r8 : c34abef4                                     
r7 : c04f3aa0  r6 : c05f3be0  r5 : c03336a8  r4 : 00000000                      
r3 : 00000008  r2 : 00000000  r1 : c04f3aa0  r0 : c04f3800                      
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  Segment kernel                      
Control: 5317F                                                                  
Table: C34A4000  DAC: 00000017                                                  
Process dm_spi.1 (pid: 178, stack limit = 0xc04d4258)                           
Stack: (0xc04d5ea0 to 0xc04d6000)                                               
5ea0: c04d5efc c04d5eb0 c023228c c0230fa8 c04d4000 00000000 c04f3800 00000001   
5ec0: 00000001 c04d5ed0 c0049d70 01e12000 c04d5efc c34abef4 00000000 c34abec8   
5ee0: 00000000 c04f3aa0 c04f3800 c04d4000 c04d5f34 c04d5f00 c0230b5c c02321b0   
5f00: c04f3ad4 00000000 c04d5f54 80000013 c05732a0 c04d4000 c04f3aa4 00000000   
5f20: c02309d8 c04f3aa0 c04d5f6c c04d5f38 c00615b4 c02309e8 c05732b8 c05732a8   
5f40: 00000002 00000000 c05732a8 c04d4000 c05732a0 c05732b0 00000002 c04d5f84   
5f60: c04d5fcc c04d5f70 c0061dbc c00614e4 00000001 00000000 00000000 00010000   
5f80: 00000000 00000000 c05d4600 c00499b4 00100100 00200200 ffffffff ffffffff   
5fa0: 00000000 c05732a0 c04d4000 c0061cb4 c0471dd8 00000000 00000000 00000000   
5fc0: c04d5ff4 c04d5fd0 c0064da4 c0061cc4 ffffffff ffffffff 00000000 00000000   
5fe0: 00000000 00000000 00000000 c04d5ff8 c005172c c0064ccc 61747320 25206574   
Backtrace:                                                                      
[<c0230f98>] (davinci_spi_bufs_prep+0x0/0x47c) from [<c023228c>] (davinci_spi_b)
[<c02321a0>] (davinci_spi_bufs_dma+0x0/0x49c) from [<c0230b5c>] (bitbang_work+0)
[<c02309d8>] (bitbang_work+0x0/0x2d8) from [<c00615b4>] (run_workqueue+0xe0/0x1)
[<c00614d4>] (run_workqueue+0x0/0x170) from [<c0061dbc>] (worker_thread+0x108/0)
[<c0061cb4>] (worker_thread+0x0/0x144) from [<c0064da4>] (kthread+0xe8/0x128)   
[<c0064cbc>] (kthread+0x0/0x128) from [<c005172c>] (do_exit+0x0/0xa24)          
 r7 = 00000000  r6 = 00000000  r5 = 00000000  r4 = 00000000                     
Code: e89da800 e1a0c00d e92dd800 e24cb004 (e5923010)       

/=====================================

Help plz.

regard,

JG KIM

  • Hi JG Kim,

    Are you trying out the sample code which comes along with the board or your customized code?

     

    Regards,

    Shankari.

  • My code is as follows.

    The error message is as follows.

    #include <stdint.h>
    #include <unistd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <getopt.h>
    #include <fcntl.h>
    #include<string.h>
    #include <sys/ioctl.h>
    #include <linux/types.h>
    #include <linux/spi/spidev.h>

    #define SPI_DEV "/dev/spidev0.0"
    #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

    static void do_read(int fd, int len)
    {
        unsigned char    buf[32], *bp;
        int        status;

        /* read at least 2 bytes, no more than 32 */
        if (len < 2)
            len = 2;
        else if (len > sizeof(buf))
            len = sizeof(buf);
        memset(buf, 0, sizeof buf);

        status = read(fd, buf, len);
        if (status < 0) {
            perror("read");
            return;
        }
        if (status != len) {
            fprintf(stderr, "short read\n");
            return;
        }
    /*
        printf("read(%2d, %2d): %02x %02x,", len, status,
            buf[0], buf[1]);
        status -= 2;
        bp = buf + 2;
        while (status-- > 0)
            printf(" %02x", *bp++);
        printf("\n");
        */
    }
    static void pabort(const char *s)
    {
        perror(s);
        abort();
    }
    int main(int argc, char *argv[])
    {
       unsigned char mode, lsb, bits;
       unsigned int speed;
       int fd, ret;
       uint8_t tx[] = {0xFF, 0x00,0xFF,0x00,};
          struct spi_ioc_transfer mesg = {
            .tx_buf = (unsigned long)tx,
            .len = ARRAY_SIZE(tx),
        };
       
       fd = open(SPI_DEV, O_RDWR);
       if(fd < 0){
          pabort("can't open device");
          return 0;
       }
       if(ret = ioctl(fd, SPI_IOC_RD_MODE, &mode)<0){
          pabort("can't get spi mode");
          return 0;
       }
       if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) {
          perror("SPI rd_lsb_fist");
          return 0;
       }
       if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) {
          perror("SPI bits_per_word");
          return 0;
       }
       if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) {
         perror("SPI max_speed_hz");
         return 0;
       }
       printf("spi mode %d, %d bits %sper word, %d Hz max\n", mode, bits, lsb ? "(lsb first) " : "", speed);
       
       //while(1){
        if ( ioctl(fd, SPI_IOC_MESSAGE(1), mesg) < 0) {
            perror("SPI_IOC_MESSAGE");
            return;
        }
    //    }
        
        do_read(fd, 2);
       close(fd);
       return 0;
    }

    Regards,

    JG KIM

  • Hi JG Kim,

    You need not post the code. I am trying to understand your problem better.

    I would like to know where does this code comes from? I mean to ask whether you are using any sample code supplied from TI for testing SPI? or you have written your own code to do the same or you modified the sample code?

     

    Regards,

    Shankari

     

  • This code modify  [spidev_test.c ]  code. 

    I want to know the spidev interface is running. As a result, the above error message occurs, and stopped.

  • HI JG Kim,

    Please explain/describe your problem.

    1. What are you actually trying to do with SPI?

    2. Are you booting from SPI flash? For what purpose the SPI interface has been used.?

    3. Is the SPI driver is problematic for you? Is the SPI driver a part of Starterware ? or linux PSP? IS it a part of any SDK ( software development kit) supplied by TI?

    4. You have mentioned that it is a "test program". where did you pick this test program? From any TI websites? Please specify.

     

    Regards,

    Shankari.