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.

  • Resolved

Changing SPI Bufsiz on Beaglebone Black

Prodigy 60 points

Replies: 5

Views: 4441

Hello there,

I would like to increase the SPI's buffer size from default 4096 bytes to 65536 bytes (or highest possible) to do some real time sampling with the BBB.

I have tried various methods and none of them yielded any results-

modprobe spidev bufsiz=65536                I checked the spi bufsiz after " cat  /sys/module/spidev/parameters/bufsiz" and it reported 4096 still

I typed in   "rmmod spidev" afterwards and it reported spidev is being used by some program that I am not aware of.

Then, I tried to change the parameter directly by changing bufsiz through vim

cd /sys/module/spidev/parameters

chmod 066 bufsiz  //gives rw permissions

vim bufsiz

Vim reports E677: Fsync failed as I tried to quit and exit the program.

Can someone please help? Very much appreciated

Cheers,

David

  • Hi David,

    Please let me know what "modinfo spidev" outputs.

    Also try adding the following line to the /etc/modprobe.d/local.conf file:

    options spidev bufsiz=65536

    Another suggestion is to write the desired buffer size to the following file:

    /sys/module/spidev/parameters/bufsiz

    My last suggestion is to modify the spidev.c file in the linux kernel sources and change the default buffer size:

    static unsigned bufsiz = 4096;

    Then recompile the module and try again.

    Best regards,
    Miroslav


    --------------------------------------------------------------------------------------------------------------------------------
    Note: If this post answers your question, please click the Verify Answer button below. Thank you!
    --------------------------------------------------------------------------------------------------------------------------------
  • In reply to Miroslav Kiradzhiyski XID:

    Hi Miroslav,

    Thanks a lot for your response.

    I got an Error message: "Module spidev not found." when I typed in modinfo spidev

    I did not have a local.conf file so I created one myself and added the line you suggested, still didn't work.

    I got a Fsync failed error when I tried to change bufsiz using vim

    I have attached an image for each of the scenario I described above.

    About recompiling the kernel - do I lose all the work I have done and saved on the BBB once I recompile it?

    Thanks

  • In reply to David King Li:

    David King Li
    I got an Error message: "Module spidev not found." when I typed in modinfo spidev

    Try to find the "spidev.ko" file somewhere inside /lib/modules/3.2.0 and do "modinfo spidev.ko" instead.

    David King Li
    About recompiling the kernel - do I lose all the work I have done and saved on the BBB once I recompile it?

    You don't need to recompile the whole kernel - just the modules. Anyway, you won't lose anything in your root file system if you just update the kernel or the modules.

    Best regards,
    Miroslav


    --------------------------------------------------------------------------------------------------------------------------------
    Note: If this post answers your question, please click the Verify Answer button below. Thank you!
    --------------------------------------------------------------------------------------------------------------------------------
  • In reply to Miroslav Kiradzhiyski XID:

    Hi Miroslav,

    I went into "/lib/modules/3.8.13" and did "modinfo spidev.ko" it sill returned error not found

    I managed to change the SPI bufsiz temporarily through gedit but I need the changes to permanent.

    Is there an alternative to recompiling the kernel? I have trouble setting up the TFTP server

    Thanks,

    DKL

  • In reply to David King Li:

    I found an alternate solution to the problem - 

    I wrote a script that changes spi bufsiz value on boot

    Script content

    --snip

    #!/bin/bash
    # Spi Bufsiz Script

    cd /sys/module/spidev/parameters
    chmod 666 bufsiz
    echo 65534 > bufsiz

    --snip

    Guide to creating scripts on BBB startup-

    http://mybeagleboneblackfindings.blogspot.ca/2013/10/running-script-on-beaglebone-black-boot.html

    Hope this helps those who have the same problem

    Cheers,

    DKL

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.