We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

SPI does not work since v0.1.9-b159



  • Hi guys,

    I have been trying to work with Omega2+ and SPI communications, until now unsuccessfully.
    After test some firmware versions of Omega, I realized that SPI is working great with versions older than "v0.1.9-b159" (included). For newer versions, the correct data does not reach the receiver.

    I am testing the SPI communication, using the Onion Spi-Tool: spi-tool. I tried to read some bytes, maintaining MISO and MOSI connected to each other. So, using the command,

    spi-tool -b 1 -d 32766 --sck 7 --mosi 8 --miso 9 --cs 6 read 0x07

    and varying the byte read, the result is always the same: 0x00. Using the version "v0.1.9-b159", the reading works as expected (read 0x07: 0x07).

    Library and Kernel Modules already updated:

    1. libonionspi
    2. kmod-spi-bitbang
    3. kmod-spi-dev
    4. kmod-spi-gpio-custom

    Using the command "dmesg | grep spi", the result is the following:

    • With versions newer than v0.1.9-b159:
      [ 0.354636] spi-mt7621 10000b00.spi: sys_freq: 193333333
      [ 0.364822] m25p80 spi32766.0: using chunked io (size=31)
      [ 0.370321] m25p80 spi32766.0: mx25l25635e (32768 Kbytes)
      [ 0.375863] 4 ofpart partitions found on MTD device spi32766.0
      [ 0.381776] Creating 4 MTD partitions on "spi32766.0":

    • With version v0.1.9-b159:
      [ 0.351457] spi-mt7621 10000b00.spi: sys_freq: 193333333
      [ 0.361491] m25p80 spi32766.0: using chunked io (size=31)
      [ 0.366988] m25p80 spi32766.0: mx25l25635e (32768 Kbytes)
      [ 0.372558] 4 ofpart partitions found on MTD device spi32766.0
      [ 0.378487] Creating 4 MTD partitions on "spi32766.0":
      [ 10.473111] spidev spi32766.1: buggy DT: spidev listed directly in DT
      [ 10.484434] WARNING: CPU: 0 PID: 473 at drivers/spi/spidev.c:720 0x8710c33c()
      [ 10.491675] Modules linked in: spidev(+) snd_usbmidi_lib slhc rfcomm nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack iptable_mangle iptable_filter ip_tables hidp hid_generic hci_uart crc_ccitt cdc_acm btusb btintel bnep bluetooth snd_soc_simple_card snd_soc_ralink_i2s snd_soc_wm8960 videobuf2_vmalloc videobuf2_memops videobuf2_core hid v4l2_common videodev evdev snd_soc_core ralink_gdma virt_dma mt76x8 ralink_eeprom_api ledtrig_oneshot ledtrig_morse ledtrig_heartbeat ledtrig_gpio ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables x_tables msdos snd_pcm_dmaengine snd_compress snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd_rawmidi snd_seq_device snd_hwdep snd input_core soundcore vfat fat ntfs configfs autofs4 nls_utf8 nls_iso8859_1 nls_cp437 regmap_i2c dma_shared_buffer ecb cmac mmc_block usb_storage sdhci_pltfm sdhci mtk_sd mmc_core leds_gpio ohci_platform ohci_hcd ledtrig_transient ehci_platform ehci_hcd sd_mod scsi_mod gpio_button_hotplug ext4 jbd2 mbcache exfat usbcore nls_base usb_common crc16 aead crypto_null cryptomgr crc32c_generic crypto_hash
      [ 10.718008] [<801dd064>] spi_drv_probe+0x3c/0x84
      [ 10.732313] [<801dcf64>] spi_match_device+0x38/0xa8
      [ 10.802172] [<877e3000>] init_module+0x0/0xdc [spidev]
      [ 10.825719] [<877e3098>] init_module+0x98/0xdc [spidev]
      [ 10.839729] [<877e3000>] init_module+0x0/0xdc [spidev]
      [ 10.854375] [<877e3000>] init_module+0x0/0xdc [spidev]

    Any ideas?

    Thanks for advance,



  • @Pedro-Moura
    Perhaps the details and the links to further information contained in here can be of assistance: FAQ: I heard there is some issue with hardware SPI?


  • administrators

    Yep, as @cas mentioned, please see the FAQ.
    SPI half-duplex transmissions work really well with the python-spidev module.

    I've also edited the FAQ to mention that the spi-tool utility and the pyOnionSpi module are deprecated and should not be used. We'll be updating our documentation to reflect that as well!



  • How do you change the cs pin using python-spidev? I don't find this in the documentation anywhere.



  • @Jeremy-Shubert Here's what I did but can't confirm it's working because I had another issue come up.

    gpio11 = onionGpio.OnionGpio(11)
    spi.no_cs = True
    status = gpio11.setValue(0) #take cs low
    rdVal = spi.readbytes(2) #read two bytes,
    status = gpio11.setValue(1) #cs high to end comm

    I'll check back in once I confirm, hopefully save someone else time


  • administrators

    @Jeremy-Shubert If you want to use the hardware SPI controller, you'll have to use SPI CS1 (GPIO6) as your CS pin.

    And then you don't need to worry about manually toggling the CS. If you just issue a rdVal = spi.readbytes(2), the hardware controller will take care of everything.

    Is there a specific reason why you want to change the CS pin?



  • Thanks for the answer @cas and @Lazar-Demin.

    In fact, half-duplex SPI transmissions will work really well in newer versions of Omega2+. I took some time to solve the communication problem between Omega and my Thermal Camera but, finally, I got it.


  • administrators

    @Pedro-Moura glad to hear it! make sure to post your project when it's done!


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.