IMX8MP On chip RAM memory access

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX8MP On chip RAM memory access

2,098 Views
Samhitha_Kashyap
Contributor III

Hello,

I want to learn how I can access the OCRAM  to read and data to the memory.

Can anyone advice how I could achieve that on Linux cortex A-53?

On-Chip RAM - OCRAM (576 KB)

start address: 0x00900000 => reserved for ROM

start address: 0x00918000  =>OCRAM FREE AREA

end address: 0x0097FFFF

https://www.nxp.com/webapp/Download?colCode=IMX8MPRM 

 

Thank you!

IMX8MPLUS 

0 Kudos
Reply
7 Replies

2,011 Views
Samhitha_Kashyap
Contributor III

Hi Sanket,

Would it be possible to verify how much memory the Linux utilizes and the rest can be used for the user application.

If it is possible, how could I verify the same and allocate the rest of the memory for my application. 

Thanks & Regards,

Samhitha Kashyap

0 Kudos
Reply

1,998 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Samhitha_Kashyap ,

I hope you are doing well.
 
You can determine how much memory in the OCRAM, Linux kernel Reserved for itself by looking into the dtsi file (reserved memory node) of the soc
in the case of imx8mp, it is 448 KB.
 
resmem: reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		ocram: ocram@900000 {
			no-map;
			reg = <0 0x900000 0 0x70000>;
		};
 
      .....
      .....
 
}
 
So here 0x70000 ( 448K) bytes are reserved for Linux usage. and cannot be virtually mapped to the userspace as specified by the no-map property.
after 0x7000 bytes you can use it for other applications.
But you need to make sure that any  M7 core Application not using OCRAM. which can be determined by looking into the Linker script of a particular application.
 
Thanks & Regards
Sanket Parekh
 
0 Kudos
Reply

687 Views
Roman_Loz
Contributor I

Hi,
I am trying to use the OCRAM the way you suggested but I get kernel panic when I try to memcpy to/from it.
Could you please help me understand what am I doing wrong or missing?

dtsi:

resmem: reserved-memory {
    #address-cells = <2>;
    #size-cells = <2>;
    ranges;

    ocram: ocram@900000 {
        no-map;
        reg = <0 0x900000 0 0x70000>;
    };

    ocram_dma: ocram_dma@970000 {
        no-map;
        reg = <0 0x970000 0 0xC00>;  // 3KB
    };
...

module init:

    // Find the OCRAM DMA node by name
    np = of_find_node_by_name(NULL, "ocram_dma");
    if (!np) {
        pr_err("Failed to find OCRAM DMA node in device tree\n");
        return -ENODEV;
    }

    // Lookup the reserved memory region
    rmem = of_reserved_mem_lookup(np);
    if (!rmem) {
        pr_err("Failed to lookup reserved memory for OCRAM DMA\n");
        return -ENODEV;
    }

    // Map the reserved memory region
    ocram_dma_base = ioremap(rmem->base, rmem->size);
    if (!ocram_dma_base) {
        pr_err("Failed to map OCRAM DMA memory\n");
        return -ENOMEM;
    }


copy:

memcpy(current_address, mv->A, MATRIX_STRUCT_SIZE);


 

0 Kudos
Reply

654 Views
Samhitha_Kashyap
Contributor III

Hi @Roman_Loz , you could try including compatible = "shared-dma-pool"; and it should work.

ocram_dma: ocram_dma@970000 {
        no-map;
        compatible = "shared-dma-pool";
        reg = <0 0x970000 0 0xC00>;  // 3KB
    };

 

Regards,

Samhitha Kashyap

0 Kudos
Reply

1,973 Views
Samhitha_Kashyap
Contributor III

Hi @Sanket_Parekh,

Thanks for the response, it was helpful! 

Would it be possible for me to modify the device tree to support DMA within the 448 KB OCRAM space, if I can't use it for the user application?

 

Thanks & Regards,
Samhitha Kashyap

0 Kudos
Reply

1,935 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Samhitha_Kashyap,

Please note that the NXP does not recommend the modification in the node for 448 KB OCRAM Space as it is used by other drivers.
One can use memory regions after 0x970000 to Support DMA using the compatible = "shared-dma-pool" property.

 

Thanks & Regards

Sanket Parekh

0 Kudos
Reply

2,068 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Samhitha_Kashyap 

I hope you are doing well.

To access OCRAM First you need to ensure that you don't try to access the region that is used by ATF.

in the case of u-boot, one can use md/mw command to access OCRAM directly.

It is not recommended to use OCRAM in userspace as Linux itself uses it.

Thanks & Regards

Sanket Parekh

0 Kudos
Reply