cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
az23
Contributor
Contributor
1,057 Views
Registered: ‎05-31-2018

Accessing BRAM in Linux Kernel hang

Hi everyone,

I was trying to get the example working here with petalinux: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842412/Accessing+BRAM+In+Linux

I'm using petalinux 2019.1 for this. Basically, when I add the device tree modifications to my system-user.dtsi file: 

/include/ "system-conf.dtsi"
/ {
   #address-cells = <2>;
   #size-cells = <2>;
   memory {
       device_type = "memory";
       reg = <0x0 0x0 0x0 0x80000000>, <0x0 0xA0000000 0x0 0x8000>, <0x00000008 0x00000000 0x0 0x80000000>;
   };
   reserved-memory {
       ranges;
       reserved {
           reg = <0x0 0xa0000000 0x0 0x8000>;
       };
   };
};
&&axi_bram_ctrl_0 {
    status = "disabled";
};

I get a petalinux-build error. When I take out the &&axi_bram_ctrl_0 portion, I do not get a build error, but my kernel hangs upon starting the boot out of u-boot. Is anyone able to try this example and get it working with the simple bram controller in the wiki?

5 Replies
az23
Contributor
Contributor
902 Views
Registered: ‎05-31-2018

I have also tried using a single ampersand, as in:

&axi_bram_ctrl_0 {
status = "disabled";
};

Anyone have a chance to look at this?
 

inve7
Visitor
Visitor
801 Views
Registered: ‎02-21-2020

I'm having the same issue enabling BRAM with petalinux 2019.2. Has anyone found a solution or have any suggestions?

0 Kudos
inve7
Visitor
Visitor
798 Views
Registered: ‎02-21-2020

To add, I've also included the following line in platform-top.h and have verified that u-boot recognizes all three DRAM banks with 'bd'

#define CONFIG_NR_DRAM_BANKS 3
0 Kudos
inve7
Visitor
Visitor
773 Views
Registered: ‎02-21-2020

I was able to make some progress, but it's still not wokring properly as described in the wiki page. I had a theory that there was problem with the device tree, so I tried compiling it manually with dtc and received the following errors:

Warning (reg_format): /reserved-memory/reserved:reg: property has invalid length (16 bytes) (#address-cells == 2, #size-cells == 1)
Warning (ranges_format): /reserved-memory:ranges: empty "ranges" property but its #size-cells (1) differs from / (2)

It seems as though #address-cells and #size-cells are required within the reserved-memory node and aren't inherited properly from the root node (see here). So, I modified my system-user.dtsi to be the following:

/include/ "system-conf.dtsi"

/ {
	#address-cells = <2>;
	#size-cells = <2>;

	memory {
		device_type = "memory";
		reg = <0x0        0x0        0x0 0x7ff00000>,
		      <0x00000004 0xC0000000 0x0 0x8000>,
		      <0x00000008 0x00000000 0x0 0x80000000>;
	};

	reserved-memory {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;
		reserved {
			reg = <0x00000004 0xC0000000 0x0 0x8000>;
		};
	};
};

 

This now allows the kernel to successfully boot...however, when I try to access the BRAM with devmem or mmap I receive an "Operation not permitted" error. Does anyone know why this is? Another thing to note...when I try to access the BRAM without any modifications to the device tree it works fine (but I'm assuming the point of following the steps in the wiki is for increased performance?).

 

0 Kudos
inve7
Visitor
Visitor
741 Views
Registered: ‎02-21-2020

I was able to mmap after unsetting CONFIG_STRICT_DEVMEM in the kernel config

https://forums.xilinx.com/t5/Embedded-Linux/Linux-mmap-DMA-changes-between-2018-3-and-2019-2/td-p/1070089

0 Kudos