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.

Linux/PRU-ICSS-INDUSTRIAL-SW: RPMsg timing limitations

Part Number: PRU-ICSS-INDUSTRIAL-SW

Tool/software: Linux

I currently have firmware running on the PRU which is sending out 32 bits of data via an rpmsg channel, once every millisecond. I read from the /dev/rpmsg_pru30 device using the poll method provided by the driver, however when verifying the data, I notice that a significant number of bits have been dropped. I would send out around 89,000 bytes and would only receive 50,000. The problem seems to get worse the faster I send data out so I was wondering if any testing has been done to show how fast the rpmsg communication between PRU and Linux can be achieved without any data loss? Thanks

  • Hello Jesse,

    I am not aware that TI has conducted any formal testing to see the fastest possible RPMsg communication without data loss. However, this thread indicates that 1ms has been verified by another user. Jason's suggestions on that thread might be helpful for you. One common issue is if the PRU writes RPMsgs to the kernel FIFO faster than the ARM reads from the FIFO, then data will be lost. One of several possible solutions is to only write data with the PRU when user space requests it.

    What version of Processor SDK are you using? 

    Regards, 

    Nick

  • I am using the most recent SDK available. The ARM seems to be able to service the PRU fast enough for a while , the problem seems to be that at times the cpu% for the remoteproc will shoot up to 100% corresponding to when the data is missed. It will hang like this for a couple seconds and then catch itself and record normally again.

    This thread does mention slow cpu performance when the pru is sending out messages that arent being serviced, which seems to be the case here. What is the reasoning behind why the cpu shoots up to 100% when pru is sending out messages and no one is reading? Something here seems to be messing up the communication.

    Thanks,

    Jesse

  • Also of note, I have been able to verify that the ARM can receive all the data from the PRU by having a read inside of a while loop and counting the number of bytes that I have read. By only sending a certain amount of bytes from the PRU i verify all bytes are received on the ARM, but the problem occurs when I try to write the data to a separate file descriptor and it starts missing chunks of data.

    Here is the code I am using to receive:

    while(1) {
    if(FD_ISSET(fd3,&input_set)){
    i = read(fd,&buf2[(bytecount/4)%500],4);
    bytecount += i;
    if(i >= 1){
    if((bytecount%(max_buffer*4))==0) {
    fwrite(buf2,max_buffer*4,1,stdout); //If I comment this line of code evrything works perfectly
    gettimeofday(&now,NULL);
    timersub(&detail_time,&now,&diff);
    time2 = (diff.tv_sec+(diff.tv_usec/1000000.0))*1.0;
    byte_write+=2000;
    fprintf(stderr,"-------%d-------%f\n",byte_write,(diff.tv_sec+(diff.tv_usec/1000000.0))*1.0);
    fprintf(stderr,"\nElapsed Time: %f\n\n",(time2-time)*-1.0);
    time = time2;
    }
    }
    if(bytecount==88000) break;
    }
    }


    Is this more a linux issue than it is PRU firmware? I would think the ARM which is running at a much faster speed should be able to handle a read and write command in millisecond intervals without taking up too many resources.
  • Hello Jesse,

    fwrite is a blocking function, as well as being expensive in terms of cycles to execute. It looks like this is a Linux related issue where the ARM code is taking so long to go through fwrite, fprintf, etc that it is missing reads. The application implementation is up to you, but I'd suggest

    1) decoupling the higher priority read from the lower priority write (ie put fwrite and all those fprintf statements in a separate thread)
    2) Look into reducing the number of times expensive functions are called

    Are you using RT Linux or regular Linux?

    Regards,
    Nick
  • Locking and closing thread, please create a new one with any additional questions.

    Regards,
    Nick