• 0
soha

AXI master custom IP write memory-mapped register

Question

Hi,

I have a Zedboard and I have loaded a Linux OS on it. I'm wondering how I can implement an AXI master custom IP to write to memory-mapped registers (e.g. for configuration purpose). I tried to implement an AXI master IP block to write the specific registers through the GPIO slave interface on the PS. I provided target address and value to be written in the Verilog code for the IP. The write event is initiated by pressing a button on the board. Currently, when I press the button, the OS goes into a deadlock state. My questions are as follows:

(1) Can I use the AXI master IP and GPIO connection to write to a memory-mapped register? Do I need to also implement an interrupt (I'm guessing missing an interrupt mechanism is my problem but not sure)?

(2) Do I actually have to use a DMA controller to fulfill the task instead of using the GPIO slave interface?

In any case, does anyone have a tutorial for how to implement an AXI master custom IP to write to memory-mapped registers? I've found a lot about AXI slave IP but can't find something about AXI master IP. Thanks in advance.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @soha,

You are in the right sub section to get answers for embedded linux questions. While you are waiting for a more experience forum member to respond. I do not have a lot of experience with embedded linux but the OS shouldn't stop when you press a button. So i would guess that you might be using the wrong memory addresses. I would check into that first and foremost. Then Here is a thread that talks about using scatter mode for the DMA that might be useful for you.

cheers,

Jon

Share this post


Link to post
Share on other sites
  • 0
On 3/14/2017 at 5:57 PM, jpeyron said:

Hi @soha,

You are in the right sub section to get answers for embedded linux questions. While you are waiting for a more experience forum member to respond. I do not have a lot of experience with embedded linux but the OS shouldn't stop when you press a button. So i would guess that you might be using the wrong memory addresses. I would check into that first and foremost. Then Here is a thread that talks about using scatter mode for the DMA that might be useful for you.

cheers,

Jon

 
 

Hi Jpeyron,

Thanks for your reply and I don't know why I didn't get email notification when you update so I kind of missed it. I guess your concern is valid and I just have a very quick question (and it might be stupid but I just want to make sure). The question is:

Whether my peripheral communicates with the memory through AXI bus or DMA, my peripheral can only write its own allocated address space. Is this correct? For example, if I create a CIP and it is mapped to a base address 0x10000000 with a 4K memory space, I can only read/write this space, right? There is no way to read/write to other memory address, e.g. 0x50000000, 0xA0000000, right? If I want to read/write other memory address, I can only do it through the OS? Thanks in advance.

Edited by soha

Share this post


Link to post
Share on other sites
  • 0

Hey soha,

 

Yes, if you create a Device Driver that is mapped to 0x10000000 with a 4K memory space, you can only read/write to that space. You can read/write to other memory addresses using /dev/mem but I would not recommend it, as a buggy application could overwrite memory spaces that the kernel is using and then your OS would freeze/hang or worst.

The correct way to do what you want is to create a Device Driver for each memory space you want to write to.

 

Hope this helps :)

Share this post


Link to post
Share on other sites
  • 0

Don't forget the memory management unit ... physical addresses to your problem may not have the same address as virtual addresses.

I've always used /dev/mem: first I would open /dev/mem via open, and then create a memory mapping via mmap.  The result is a virtual address pointer that can then be used to access the physical address of the peripheral you are dealing with.

While I've never tried this with MicroBlaze, it works quite well with Linux on an ARM.

Dan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now