Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12610 Discussions

How to get Physical Address in uClinux with MMU

Altera_Forum
Honored Contributor II
1,453 Views

Hi~ 

 

I am using uClinux with mmu right now. 

and I want to write a driver for SGDMA(Stream to Memory). 

I need physical address to set up SGDMA. 

Is there anyone know about it? 

 

Right Now, my design is I use mmap to alloc a space which kernel and user can share this memory. 

My plan is pass this memory address to sgdma, than sgdma can direct write to it. 

My program in user mode can direct get from there. 

Is my idea possible? 

However I need this physical address, and I try to use virt_to_phys to get physical address, 

but it return a wrong address. 

Cound anyone tell me how to get the address? 

Or, is there anyone have this kind of design before. 

Could you share with me how you design. 

 

My virtual address is 0x2adfb0000, and I use (virt_to_phys) to transfer to physical address, 0x6adfb0000. I don't think this is real physical address. 

 

Thanks for your help
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
373 Views

I don't think it's a good idea to do DMA from a user land program. 

 

If you have a device driver that allows the user program to do mmap, why not enhance same to do the DMA stuff ?  

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

Hi Michael 

 

Right now, I am trying to write a driver for my SGDMA. 

I just test I can create a memory space. 

I want to tell my DMA he can write to this memory space. 

I need to pass this start address to DMA. 

But I don't know how to get physical address. 

 

Thanks Michael for your reply.
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

For the same physical memory, the address trhe user space program sees is different from the one the device driver sees. To access user space memory (e.g. for pointers provided by the user space program when calling the driver, I understand that (usually) a standard function is called, that _copies_ the appropriate memory block. I don't know how to make the driver determine the physical address or the Kernel virtual address of a pointer it gets from a user memory block from/to the Kernel space. Maybe in fact this is not provided as it asks for nasty side effects. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

Hi, 

 

 

--- Quote Start ---  

 

Right Now, my design is I use mmap to alloc a space which kernel and user can share this memory. 

My plan is pass this memory address to sgdma, than sgdma can direct write to it. 

My program in user mode can direct get from there. 

Is my idea possible? 

However I need this physical address, and I try to use virt_to_phys to get physical address, 

but it return a wrong address. 

... 

My virtual address is 0x2adfb0000, and I use (virt_to_phys) to transfer to physical address, 0x6adfb0000. I don't think this is real physical address. 

 

--- Quote End ---  

 

 

Maybe, the next site will be helpful for you. 

 

http://www.scs.ch/~frey/linux/memorymap.html (http://www.scs.ch/%7efrey/linux/memorymap.html

 

The macro 'virt_to_phys' can be used only for 'kernel virtual address', not for user space virtual address. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

Thanks Kazu 

Right now I know how to design it.
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

Hi htmin,  

 

How did you boot your board with uClinux? 

 

My board is NEEK and I tried the steps in Wiki http://www.nioswiki.com/linux/linux_quick_start 

with cycloneIII_embedded_evaluation_kit_standard.sof (neek_web_server_mmu.zip) and cycloneIII_3c25_niosII_standard (example/standard) 

$ nios2-configure-sof /home/user/Altera/kits/cycloneIII_3c25_niosII/examples/standard_cd/cycloneIII_embedded_evaluation_kit_standard.sof /opt/altera10.0sp1/quartus/adm/qenv.sh: line 109: warning: setlocale: LC_CTYPE: cannot change locale (en_US): No such file or directory Info: ******************************************************************* Info: Running Quartus II Programmer Info: Command: quartus_pgm --no_banner --mode=jtag -o p;/home/rgnurrahmat/Altera/kits/cycloneIII_3c25_niosII/examples/standard_cd/cycloneIII_embedded_evaluation_kit_standard.sof Info: Using programming cable "USB-Blaster " Info: Using programming file /home/rgnurrahmat/Altera/kits/cycloneIII_3c25_niosII/examples/standard_cd/cycloneIII_embedded_evaluation_kit_standard.sof with checksum 0x00D122FE for device EP3C25F324@1 Info: Started Programmer operation at Thu Sep 16 03:31:39 2010 Info: Configuring device index 1 Info: Device 1 contains JTAG ID code 0x020F30DD Info: Configuration succeeded -- 1 device(s) configured Info: Successfully performed operation(s) Info: Ended Programmer operation at Thu Sep 16 03:31:41 2010 Info: Quartus II Programmer was successful. 0 errors, 0 warnings Info: Peak virtual memory: 77 megabytes Info: Processing ended: Thu Sep 16 03:31:41 2010 Info: Elapsed time: 00:00:05 Info: Total CPU time (on all processors): 00:00:01 ~/nios2-linux/uClinux-dist $ nios2-download -g images/linux.initramfs.gz /opt/altera10.0sp1/quartus/adm/qenv.sh: line 109: warning: setlocale: LC_CTYPE: cannot change locale (en_US): No such file or directory Using cable "USB-Blaster ", device 1, instance 0x00 Processor is already paused Initializing CPU cache (if present) OK Downloaded 5283KB in 47.3s (111.6KB/s) Verified OK Starting processor at address 0xD0000000 ~/nios2-linux/uClinux-dist $ nios2-terminal nios2-terminal: Unable to connect to JTAG UART because another application nios2-terminal: is using it (or is using something else which clashes). Please close nios2-terminal: the other application and try again. ~/nios2-linux/uClinux-dist $ nios2-terminal nios2-terminal: connected to hardware target using JTAG UART on cable nios2-terminal: "USB-Blaster ", device 1, instance 0 nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) + Stopped nios2-terminal ~/nios2-linux/uClinux-dist $ ^C ~/nios2-linux/uClinux-dist $
0 Kudos
Altera_Forum
Honored Contributor II
373 Views

nios2-terminal: Unable to connect to JTAG UART because another application 

nios2-terminal: is using it (or is using something else which clashes). Please close 

nios2-terminal: the other application and try again. 

 

Did you open nios2 ide connect to your development board? 

It shows you have another thing connect to your board.. 

 

The second time you can't open it, is because first time you trigger it and it show everything already. 

Check do you have other thing connect to it or not. 

Nioswiki demo file is ok to use
0 Kudos
Reply