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 device connected to AM4377 need to transfer the data to Ethernet

Other Parts Discussed in Thread: AM4377

Hello,

Can anybody here suggest or explain how to transfer the data from SPI device connected to AM4377 sitara processor using ethernet then from ethernet transfer to a host PC. Is there a reference linux source code for this case? For example the data is an Analog input, this time I just simply need to know the status of the input through a host computer so I need to access the data from SPI down to ethernet then from ethernet to host PC and vice versa.

Thank you.

  • I would like to understand how sitara MPU process ethernet data and how that data will receive by the SPI and vice versa..

    Thank you.
  • Hi Leo,

    From what I understand, your use case is:

    1. Receive data from external SPI chip to the AM437x SPI module.
    2. Transfer this data from AM437x SPI module to AM437x Ethernet module
    3. Transfer this data from AM437x Ethernet module to host PC

    There is no direct connection between AM437x SPI and AM437x Ethernet. The data should go through the MPU/DMA.

    Regards,
    Pavel
  • Hello Pavel,

    Thank yo for your reply. Yes, it is correct. In fact, I have two separate boards one is an AIO board(slave) and the other is the base board(master) where AIO module is connected via SPI to the base module. I want to monitor the status of the AIO module and transfer data from AM437x Ethernet which is on the base board to the host PC. I have tested the spi communication between two modules using the spidev_test and it can be accessed but my problem is how to start communicating between spi and etnernet in AM437x which in this case SPI(master) and ethernet is in the base board. But you said there is no direct communication between two interfaces protocol. Do you have an idea how data is access in the MPU for SPI and ethernet. I am thinking of a firmware codes that act as SPI to Ethernet bridge but I dont have linux reference code for this case. Any suggestion or ideas is much appreciated. 

    Regards,

    Leo

  • Hi Leo,

    The connectivity between the modules inside AM437x is documented in the AM437x TRM, section 4.1.2.3 Interconnect Connections. The Ethernet (GEMAC) module is L3 initiator and has access to: EMIF/DDR, OCMC RAM, MPU L2 RAM, GPMC and QSPI. While McSPI belongs to the L4_PER domain, and Ethernet has no access to L4_PER domain.

    After receiving the data into the AM437x McSPI module, you should transfer this data (with MPU or DMA) to some memory that is accessible by the Ethernet/GEMAC module, memory like DDR, OCMC RAM, MPU L2 RAM. Then you should transfer that data from that memory to the Ethernet/GEMAC module.

    BR
    Pavel
  • Hello Pavel,

    I see.. I will check the TRM you mention. Thank you for this useful information. Now I understand more about SPI to ethernet data transfer concept with TI processor. I am just a beginner in embedded linux development and doing it alone so first I need to do step by step everything about TI am437x application. Anyway, Is there any open source code for Linux with this kind of data transfer as a reference? I tried to find some guides over the internet but I only found Linux SDK and Linux kernel user guide from TI with limited information about spi to ethernet interface.

    By the way, Currently I have QSPI interface with external 256MB NOR flash memory in the base board(master), I am thinking to use this as the access point for data transfer since as you mention Ethernet module has an access to it. Do you think it's possible? Actually, I have tried writing and loading linux kernel to QSPI to test the SPI peripheral using spidev_test but not for the ethernet. My base board has also an external 2G DDR3 RAM. One thing that I need to know is how a firmware linux code can control this transfer of data from SPI to memory then from memory to ethernet. As per my limited idea, I am thinking of SPI to Ethernet handler in my codes where it will call the SPI driver interface and the Ethernet Driver that link together to DMA where data is stored. Hope you could give a little bit more ideas with this matter.

    Thank you so much for your support.

    BR,
    Leo
  • Leo,

    I will recommend you to check AM437x datasheet and TRM, QSPI sections, to check if you can use QSPI for your usecase.

    From what I was able to find, you can access QSPI directly from the GEMAC, only when using flash memory attached to the QSPI. Thus you should access the region 0x30000000 to 0x33FFFFFF (64MB).

    If you use McSPI, you should first transfer the data from the external slave board through the AM437x McSPI module to some memory (EMIF/DDR, OCMC RAM, MPU L2 RAM).

    See the below wiki pages for hints about McSPI/QSPI software:

    processors.wiki.ti.com/.../Linux_Core_SPI_User's_Guide
    processors.wiki.ti.com/.../AM335x_McSPI_Driver's_Guide
    processors.wiki.ti.com/.../Linux_Core_QSPI_User's_Guide
    processors.wiki.ti.com/.../Processor_SDK_RTOS_QSPI-McSPI

    Regards,
    Pavel
  • Hello Pavel,

    Thank you for your quick reply.

    I can access QSPI. In fact, I can load uboot via UART to QSPI so that board will permanently program to it everytime the board is Power ON  then by sf probe command  I can check that there is an external flash memory.

    Also, the AIO board(SPI slave) composed of FPGA, DAC/ADC circuit connected to my base board(composed of the MPU/DMA and other peripherals) is interface with one of the McSPI SPI0 and act as a SPI master. With this I can read and write data and tried also to load the program to FPGA which is on the AIO board. However, sorry but I don't understand how to transfer data from the McSPI module(SPi0) to memory like DDR or the On chip memory or L2 MPU RAM. Did you mean there is a linux command to transfer it to memory or I need software/firmware code for this to happen? I also followed the link you provided to configure my SPI, QSPI and McSPI before building the linux kernel. By the way,  I use teraterm(serial) to transfer binary file to QSPI.

    Thank you.

    BR,

    Leo

  • P.S.
    How should I transfer the data from McSPI module of Am437x to memory like for example EMIF/DDR given that I already transfer the data from external slave board into it?
  • P.S.
    Is there API available for this data transfer? Or I need to build own API? The reason why I am asking is because once I transfer the data to ethernet then the next thing to do is to transfer it to a host PC maybe with software test app where I can send command to know the AO data and then the status of the AI.

    Thanks again for your great help.

    regards,
    Leo
  • Leo Abejuela said:
    However, sorry but I don't understand how to transfer data from the McSPI module(SPi0) to memory like DDR or the On chip memory or L2 MPU RAM. Did you mean there is a linux command to transfer it to memory or I need software/firmware code for this to happen?

    You can create driver (kernel module) for the AIO board and use the McSPI kernel driver (linux-kernel/drivers/spi/spi-omap2-mcspi.c). As an example, see the AM335x SPI flash  W25Q64 driver - linux-kernel/drivers/mtd/devices/m25p80.c

    SPI flash driver (m25p80.c) -> Linux SPI framework -> SPI driver -> SPI hardware -> SPI flash hardware

    See also the below e2e thread:

    You can also try with the user space spidev. In kernel you can add spix node in the dts, and enable spidev in kernel config, so that you can read/write through /dev/spidevX.Z

    For more info regarding spidev see:

    linux-kernel/Documentation/spi/spi-summary spidev spidev_fdx.c spidev_test.c

     http://processors.wiki.ti.com/index.php/Linux_Core_SPI_User's_Guide

    Regards,
    Pavel

  • Hello Pavel,

    Thank you.

    BR,

    Leo