cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
loutronique
Visitor
Visitor
4,443 Views
Registered: ‎06-01-2010

can't read or write in a mapped memory

Hi All,

I want to write a driver to make a DMA transfert between a ddr2 and a bram with XPS_central_dma.

So i need to write or read the registers of XPS_CENTRAL_DMA.

 

I have two questions.

XPS_CENTRAL_DMA is mapped like below but i don't know where i can find the interesting registers (i only need 8 registers of 1 byte )


C_BASEADDR
Base Address
0x80200000
C_HIGHADDR
High Address
0x8020FFFF

 

Second question is why have I a kernel crash when i try to read or write at 0x80200000 or another adress?:

if (request_mem_region(REG_BASE,LENGTH_MEM,"centraldma")==NULL)
        {printk(KERN_DEBUG "request region echec!!!!!!!!!!!!!!!!!\n");
        kfree(buff_temp);
        return 0;
        }
    


    reg_virtu = (u32) ioremap(REG_BASE, LENGTH_MEM);
        if (!reg_virtu) {
                printk("error mapping registers\n");
                return -ENOMEM;
        }
     result = ( u32 )XIo_In32(reg_virtu);

 

 

 

 

I obtain this kind of error:

Data Read PLB Error
Oops: Machine check, sig: 7 [#1]
PREEMPT Xilinx Virtex440
Modules linked in: module(+)
**bleep**: d103c0ec LR: d103c0ec CTR: c01f5ec0
REGS: cfff7f10 TRAP: 0214   Not tainted  (2.6.33)
MSR: 00029000 <EE,ME,CE>  CR: 35000039  XER: 80000029
TASK = cf86d540[864] 'exe' THREAD: cf0ce000
GPR00: d1052003 cf0cfee0 cf86d540 a5a5a5a5 d1052000 cf804290 80201000 00000000
GPR08: 8020151b d1040000 00000000 c01f5ec0 80201003 ff7aefff e3ddfef5 d5fff97f
GPR16: ffdd9fd3 eff8dddf fffbff5f dffcdf57 00000002 ffffffef 100a8030 100a800e
GPR24: 00000000 c0380000 c0380000 c035fb3c c035fb10 d103c000 d1039704 cfae53a0
**bleep** [d103c0ec] mon_module_init+0xec/0x278 [module]
LR [d103c0ec] mon_module_init+0xec/0x278 [module]
Call Trace:
[cf0cfee0] [d103c0cc] mon_module_init+0xcc/0x278 [module] (unreliable)
[cf0cfef0] [c000119c] do_one_initcall+0x40/0x1cc
[cf0cff20] [c0064d30] sys_init_module+0xf4/0x218
[cf0cff40] [c000e230] ret_from_syscall+0x0/0x3c
Instruction dump:
38600000 60841003 38a00040 48000161 3d20d104 3bc99704 907e0010 801e0010
2f800000 419e0104 807e0010 48000161 <907e0014> 807e0010 48000175 3c60d104
---[ end trace fbd6550cae9d1350 ]---

 

I am

Thank you for the help.

regards

lounes

0 Kudos
Reply
4 Replies
linnj
Xilinx Employee
Xilinx Employee
4,435 Views
Registered: ‎09-10-2008

Hi,

 

Have you tried to read from the DMA register addresses in XMD without the MMU on (before running the kernel)?

 

I would do that to make sure you really know that the h/w is working.

 

You can also sometimes run a standalone app (no os), but I'm not sure if XPS has one for central DMA as I've not used it myself.

 

Thanks.

0 Kudos
Reply
mamisadegh2
Observer
Observer
4,434 Views
Registered: ‎06-15-2010

Dear Sir,

 

Question 1: What do you mean by interesting registers?

If you mean the set of registers by which you control the operation of XPS Central DMA, you can find the offset value and description for each one in XPS Central DMA data sheet.

 

DMA Control Register : BASE_ADDRESS + 4

Source Address Register : BASE_ADDRESS + 8

Destination Address Register : BASE_ADDRESS + C

Length Register : BASE_ADDRESS + 0x10

DMA Status Register : BASE_ADDRESS + 0x14

 

if you mean the memory erea from which you want to transfer data, I suggest you to allocate a piece of memory in your driver code and then use the allocated area address as the source or destination address in DRAM side.

 

Second Question: 

Your code seems to be correct, or at least i can not understand where is the problem, but my suggestion is : replace XIo with Kernel's ioread32 and iowrite32 functions and see what happens.

I personally never used XIo in my driver code.

By the way, what is the value of LENGTH_MEM in your driver code? 

 

Regards,

Mohammad Sadegh Sadri.

 

P.S. I am strongly agree with John, test your hardware in stand alone more before developing your kernel mode driver. It took us some thing near 1 month for our group to test and understand the operation of XPS Central DMA completely before beginning the actual driver code.

 

0 Kudos
Reply
loutronique
Visitor
Visitor
4,397 Views
Registered: ‎06-01-2010

thank you Mr John Linn and Mr Mohammad Sadegh Sadri for your answer .

I didn't find a standalone application note to test the xps_central_dma John but i will try to use or to change the xapp1121.

 

I tried to acces to read DMA registers and it is working fine(I don't have errors or kernel oops) but my driver didn't change the value of the registers .

I tried to do the same thing with a BRAM (read and write work fine ).

So as you said Mr Mohammad Sadegh Sadri my code seems correct but why can't write in th registers (know i can read the registers xps_central_dma but i always got  0 ) ??

 

 

ps1 :LENGTH_MEM =0x10000  and forget my first question it was just to be sure.

i joined all my files. can someone try it with his system you just need to change the BASE_REGISTER( i just want to know if it is a hardware problem or software)??.

 

ps2: I can acces to registers when i use xmd Mr Jhon Linn.

 

 

 

 

 

 

 

 

0 Kudos
Reply
mamisadegh2
Observer
Observer
4,359 Views
Registered: ‎06-15-2010

Dear Sir,

 

I had a brief look at your code,

1- where is the call to alloc_chrdev_region routine in your code? i was expecting to see it at the initial lines of your init routine ( after registering chrdev )

2- you have a call to request_region and then again request_mem_region , I think the second one is enough

3- since total number of register that we are going to work with is limitted to 4 or 6 registers at all, would you please decrease the value of LENGTH_MEM for your first tests? decrease it to 128 , or 32 or some thing like this.

 

Now, As I see in your driver code, you perform a read operation from BASE_ADDRESS and then your write 0xffffffff to this address and then again you read it and you see that it has not changed and so you conclude that it is not working. Am I correct?

 

Please note that, as described in the XPS Central DMA documentation , this register is the Reset register of the device, by writing to this register the device will be resetted. then again you read it and obviously you will read zero.

 

Change the offset to the location of , for example, DMA transfer Length register and repeat the test.

 

Regards

Mohammad Sadegh Sadri.

 

0 Kudos
Reply