Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Problem accessing NV memory : (7 Items)
   
Problem accessing NV memory  
Hi,
I a new to QNX and I am trying to port from VxWorks. In the CPU board I have NV RAM located at: 0x00F00000
I have the following code but is not working: 
ThreadCtl(_NTO_TCTL_IO, 0);

int val =  munmap( 0x00F00000, 0x1F400 );

    volatile uint32_t * bat_pub_addr;
    bat_pub_addr = mmap_device_memory( 0,
					 0x1F400,
                     PROT_READ|PROT_WRITE|PROT_NOCACHE,
                     0,
                     0x00F00000);


    if (bat_pub_addr == MAP_FAILED )
      {
      	cout << "bat pub alloc error " << errno << endl;
      }
When I try to access the bat_pub_addr  by showing memory I get all 0xFFFFFFFF
This works OK in VxWorks, so is not a hardware issue.
Am I doing something wrong here. 

Please Help.

Ricardo
AW: Problem accessing NV memory  
with QNX you'll need IO privileges
add this ThreadCtl before mapping:

	int rc = ThreadCtl( _NTO_TCTL_IO, 0 );
	if(-1 == rc) {
		printf("can't get IO privileges\n");
		exit(-1);
	} 

>-----Ursprüngliche Nachricht-----
>Von: Ricardo Ahumada [mailto:community-noreply@qnx.com] 
>Gesendet: Mittwoch, 23. September 2009 00:26
>An: momentics-community
>Betreff: Problem accessing NV memory 
>
>Hi,
>I a new to QNX and I am trying to port from VxWorks. In the 
>CPU board I have NV RAM located at: 0x00F00000 I have the 
>following code but is not working: 
>ThreadCtl(_NTO_TCTL_IO, 0);
>
>int val =  munmap( 0x00F00000, 0x1F400 );
>
>    volatile uint32_t * bat_pub_addr;
>    bat_pub_addr = mmap_device_memory( 0,
>					 0x1F400,
>                     PROT_READ|PROT_WRITE|PROT_NOCACHE,
>                     0,
>                     0x00F00000);
>
>
>    if (bat_pub_addr == MAP_FAILED )
>      {
>      	cout << "bat pub alloc error " << errno << endl;
>      }
>When I try to access the bat_pub_addr  by showing memory I get 
>all 0xFFFFFFFF This works OK in VxWorks, so is not a hardware issue.
>Am I doing something wrong here. 
>
>Please Help.
>
>Ricardo
>
>
>
>
>_______________________________________________
>
>QNX Momentics Community Support
>http://community.qnx.com/sf/go/post38519
>
> 
 
*******************************************
Harman Becker Automotive Systems GmbH
Management Board: Dr. Klaus Blickle (Chairman), Dr. Udo Hüls, Michael Mauser
Chairman of the Supervisory Board: Ansgar Rempp | Domicile: Karlsbad | 
Local Court Mannheim: Register No. 361395

 
*******************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat 
sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und loeschen Sie diese Mail
. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have 
received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the contents in this e-mail is strictly forbidden.
*******************************************
Re: AW: Problem accessing NV memory  
I tried checking the value in
int rc = ThreadCtl( _NTO_TCTL_IO, 0 );
		if(-1 == rc) {
			printf("can't get IO privileges\n");
			exit(-1);
		}
and is 0 (no error) so privileges do not seem to be the problem. 

Ricardo
AW: AW: Problem accessing NV memory  
as you get the MAP_FAILED from mmap()
have you checked errno?

hp 

>-----Ursprüngliche Nachricht-----
>Von: Ricardo Ahumada [mailto:community-noreply@qnx.com] 
>Gesendet: Mittwoch, 23. September 2009 16:04
>An: momentics-community
>Betreff: Re: AW: Problem accessing NV memory 
>
>I tried checking the value in
>int rc = ThreadCtl( _NTO_TCTL_IO, 0 );
>		if(-1 == rc) {
>			printf("can't get IO privileges\n");
>			exit(-1);
>		}
>and is 0 (no error) so privileges do not seem to be the problem. 
>
>Ricardo
>
>
>
>_______________________________________________
>
>QNX Momentics Community Support
>http://community.qnx.com/sf/go/post38554
>
> 
 
*******************************************
Harman Becker Automotive Systems GmbH
Management Board: Dr. Klaus Blickle (Chairman), Dr. Udo Hüls, Michael Mauser
Chairman of the Supervisory Board: Ansgar Rempp | Domicile: Karlsbad | 
Local Court Mannheim: Register No. 361395

 
*******************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen. Wenn Sie nicht der richtige Adressat 
sind oder diese E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und loeschen Sie diese Mail
. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have 
received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the contents in this e-mail is strictly forbidden.
*******************************************
Re: AW: AW: Problem accessing NV memory  
I do not get a MAP_FAILED
Re: Problem accessing NV memory  
The munmap is not necessary - the first parameter to munmap is a virtual address, not a physical address!

I'm not sure that's the error though.  What platform is this running on?

Ricardo Ahumada wrote:
> Hi,
> I a new to QNX and I am trying to port from VxWorks. In the CPU board I have NV RAM located at: 0x00F00000
> I have the following code but is not working: 
> ThreadCtl(_NTO_TCTL_IO, 0);
> 
> int val =  munmap( 0x00F00000, 0x1F400 );
> 
>     volatile uint32_t * bat_pub_addr;
>     bat_pub_addr = mmap_device_memory( 0,
> 					 0x1F400,
>                      PROT_READ|PROT_WRITE|PROT_NOCACHE,
>                      0,
>                      0x00F00000);
> 
> 
>     if (bat_pub_addr == MAP_FAILED )
>       {
>       	cout << "bat pub alloc error " << errno << endl;
>       }
> When I try to access the bat_pub_addr  by showing memory I get all 0xFFFFFFFF
> This works OK in VxWorks, so is not a hardware issue.
> Am I doing something wrong here. 
> 
> Please Help.
> 
> Ricardo
> 
> 
> 
> 
> _______________________________________________
> 
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post38519
> 

-- 
cburgess@qnx.com
Re: Problem accessing NV memory  
This is running in a Centrino 1 GHz processor