Skip to content

SPIdev works just with max. 511 bytes per transfer #714

Closed

Description

@SICKUser

The SPIdev driver just works with transfer length limited to 511 byte. If you want to transfer more than 512 byte per transfer the driver sends nothing and returned without any error response.

In header file spidev.h the define:

define SPI_IOC_MESSAGE(N) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(N)])

has just a "char" variable for the message size.
Please change them to a size_t varialbe (unsigned int) like it's handled in the spidev.c

I'm new to linux and raspberry and hope this would be fixed.

Activity

  1. popcornmix commented on Oct 25, 2014

    @popcornmix
    Collaborator

    I believe the char in #define line you quoted is defining an array of SPI_MSGSIZE(N) chars as the buffer to transfer. It is not passing the size in a char variable.

    If that's not what you mean, can you provide a diff that shows exactly what change you are suggesting?

  2. SICKUser commented on Oct 27, 2014

    @SICKUser
    Author

    Sorry, I was completely wrong:
    The problem with SPI-Transfers over a C program is in this define:
    #define SPI_MSGSIZE(N)
    ((((N)_(sizeof (struct spi_ioc_transfer))) < (1 << IOC_SIZEBITS))
    ? ((N)
    (sizeof (struct spi_ioc_transfer))) : 0)

    If you now want to transfer perhaps 600 Byte over SPI, the "real" size is generated as 600 * struct spi_ioc_transfer, and the results in 600_32Byte. But that’s bigger than the 14 allowed _IOC_SIZEBITS and the define above makes it to 0 (no error message!!).
    For me it's not clear how to fix this (otherwise I would do it). My only idea is it to write an own UIO spi driver without the ioctl interface.
    Or is there anything I do wrong? I use the system call "retVal = ioctl(_spi_fd, SPI_IOC_MESSAGE(length), &spi) ;" to transfer data over spi. As I said, I am new with using linux.

  3. SICKUser commented on Oct 27, 2014

    @SICKUser
    Author

    ok, was my mistake, If you understand the ioctl call right and increase the SPI-Buffer over a config file all works fine....

  4. added a commit that references this issue on Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions