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!
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
Hi @Samhitha_Kashyap ,
resmem: reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; ocram: ocram@900000 { no-map; reg = <0 0x900000 0 0x70000>; };
.....
.....
}
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);
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
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
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
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