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/K2GICE: PRU Memory access using Linux

Part Number: K2GICE

Tool/software: Linux

Hello

I am trying to access PRU shared Memory from Linux Application using uio_module_driver. I have modified the device tree to list the pru using uio. 

I am using the modified device tree - keystone-k2g-ice-pru-excl-uio.dtb.

I am able to access the registers of PRU and have wriitten program in pru iram to write data to shared memory and ocmc ram. 

I am using Icek2gv2 board along with sdk 04_03_00_05. 

My linux application is reading back value '0' instead of values written by the PRU. I have checked the running state of PRU.  

Kindly let me know what could be wrong.

Thanks.

  • Hi,

    I've notified the PRU team. They will post their feedback directly here.

    Best Regards,
    Yordan
  • Hello Manishkumar,

    Could you clarify which of these is the case?
    1) Are you using the unmodified device tree keystone-k2g-ice-pru-excl-uio.dtb?
    2) Are you modifying keystone-k2g-ice-pru-excl-uio.dts and using that device tree?
    3) Are you using a different device tree, but made changes to it based on what you saw in keystone-k2g-ice-pru-excl-uio.dts?
    4) Are you doing something else?

    Regards,
    Nick
  • Hello Nick,

    I am modifying the keystone-ice-pru-excl-uio.dts and using that device tree. Since K2G ICE has 4 PRU ethernet Ports, I have modified the device tree so that one the icss is exposed to the uio-module driver and other icss loads the default driver of mdio eth.

    I am loading my firmware on the modified icss and trying to access shared memory of the icss.

    Regards,
    Manish
  • Hello Manish,

    I'm not going to have time to investigate UIO this week, but I will take a look and see if I can be of any help to you next week.

    For context, we do not have any Linux UIO examples other than the ethernet code, and TI has not supported UIO outside of the context of that example for several years. I will do what I can, but usually we refer UIO questions to the beaglebone community.

    Regards,
    Nick
  • Hello Nick,

    My linux Application requires access to shared memory of PRU which written by PRU Firmware and OCMC Ram. I found one way of doing so by UIO module driver. I do understand that there is pruss driver but the support for same has been removed in the latest sdk.

    Could you  kindly suggest any other method to do the same task on K2G ICE by Linux RT Application.

    Thanks. 

    Regards,

    Manishkumar Jain

  • Hello Nick,

    I am awaiting for your reply. I have tried different configurations for the device tree but it doesn't seem to work.

    Could you kindly let me know how can access the shared memory of PRU using the linux user space application and uio-driver.

    Regards,
    Manish Jain
  • Hello Manish,

    When you say mdio eth, are you referring to processors.wiki.ti.com/.../PRU-ICSS_Ethernet , or a different ethernet on your PRUs? I am checking because that ethernet looks like it uses RemoteProc to boot the PRU cores. UIO and RemoteProc cannot be used on the same PRU - I am not sure if it is possible for one ICSS to use UIO while the other uses RemoteProc, but I can check.

    Regards,
    Nick
  • Hello Manish,

    Update: as long as the device tree nodes are configured properly, it should be possible for one PRU-ICSS to use UIO while the other uses RemoteProc. Could you post your PRU dts code?

    Regards,
    Nick
  • Hello Nick,

    The below is the PRU dts code. This is the code which I am using to generate device tree for boptinglinux.

    I can see the icss as a uio device in the device list.

    $ ls /dev

    I am also able to access the PRU-ICSS which are mentioned for the uio device using the uio-driver module. I can write to pru device iram using the uio driver and also read them. The PRU runs the program but the values written by PRU in shared ram are being read as '0' by the uio-module driver.

    I cannot understand the underlying issue. I have attached the dtsi file which I used for booting the system.

    Kindly let me know if you find anything about it.

    Thanks

    Manish Jain

    keystone-k2g-pru-uio.zip

  • Hello Manish,

    Does Linux allow you to use devmem2 or another tool to check those memory locations to make sure they are actually getting values written to them?

    Regards,
    Nick
  • Hello Nick,

    I am accessing few registers in the devmem2 which return the default values as mentioned in the device datasheet.

    Before accessing the pru shared memory, I am also accessing few configuration registers. Upon reading them, I see that they return the default values.

    I do not know any other tool to access the memory locations and check if the values are actually written or read from it. If you have any suggestions then I can try it.

    Regards
    Manish Jain
  • Hello Manish,

    Here's example firmware I wrote using devmem2 to read PRU0 DRAM0 and shared RAM locations to see if my PRU firmware was actually writing to that memory:

    /* test reading PRU DRAM0 and shared RAM from command line */
    #define TESTA    (*((volatile unsigned int *)0x100))
    #define TESTB    (*((volatile unsigned int *)0x110))
    #define TESTC    (*((volatile unsigned int *)0x10120))
    #define TESTD    (*((volatile unsigned int *)0x10130))
    
    void main(void)
    {
    	TESTA = 0xA0A0A0A0;
    	TESTB = 0x0B0B0B0B;
    	TESTC = 0xCCCCCCCC;
    	TESTD = 0xD0D1D2D3;
    }

    this was my output: 

    Regards, 

    Nick

  • Hello Manish,

    I'm going to mark this resolved. Please let us know if you have further questions.

    Regards,
    Nick
  • Hello Nick,

    Thanks for your reply.

    I am using the below device tree for my system. 

    I am loading the pru program with uio driver module into PRUs. 

    When try to access the pru memory I am getting the issue with bus error.

    I am doing the following on my system:

    1. Load the device tree with the below mentioned dts file.

    2. Run a user application which loads PRU program and enable the PRU both using uio-module driver.

    3. Access the shared memory and data memory using uio-module driver - This results in segmentation fault. 

    Alternatively, when I try to access the access the PRU memory through the tool mentioned above, I get the Bus Error at that memory location.

    I would kindly request you to share with me the device tree which you used along with method to load code into PRU. 

    Thanks,

    Regards,

    Manish Jain

     

    7651.keystone-k2g-pru-uio.zip

  • Hello Manish,

    I am sorry this response took so long - future responses will be faster. Let me know if you are still working on this issue.

    Glancing through, your code does not look too different from the template.

    I typically load PRU firmware using RemoteProc (since TI does not support UIO for a general purpose use case). You would need to make sure that your device tree was not disabling the pruss_soc_bus[0,1] and all the subnodes which are created in keystone-k2g.dtsi. keystone-k2g-evm.dts would be a good example of how to set up the device tree appropriately.

    Information on RemoteProc can be found here.

    and an example of using it to load firmware is here. (the example is am335x, but k2g should work similarly)

    Regards, 

    Nick

  • Hello Manish,

    I am going to mark this resolved. Please respond if I can offer further support.

    Regards,
    Nick
  • Hello Nick,

    Thanks for the response.

    I am not getting any bus error from the methods you suggested.

    I seem to into segmentation fault when I access the memory that might be due a bad pointer or clean-up issues which I am yet to resolve.

    I would open a new thread for the issue as I think that would resolve it.

    Regards,
    Manish