There is a useful utility for ARM called devmem2. It lets you "peek &
poke", read and write to physical addresses from the command line.
You can easily find it with a web search, in source format.
Best regards
Massimo



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Hunter, Jon
Sent: 13 December 2006 17:44
To: [email protected]; Jerry Johns
Subject: RE: Reading memory - User Space

> So would I do it like this to read PLL2 Registers? (PLL2 
> regs start at 
> 0x01C40C00, see page 94 of TMS320DM6446 datasheet)
> 
> int memfd;
> memfd = open("/dev/mem", O_RDONLY | O_NONBLOCK, 0); if 
> (memfd == -1) {
>       ERR("Cannot open /dev/mem (%s)\n", strerror(errno));
>       return FAILURE;
> }
> 
> unsigned char *memread;
> memread = (unsigned char*)malloc(512); memread = (unsigned 
> char*)mmap(NULL, 16, PROT_READ, MAP_SHARED, memfd, 0x01C40C00); 
> printf("PLL Values %08x\n", *(unsigned int*)memread);
 
 
Sorry for the delay. Looks fine, however, the only item that 
you need to be wary of is the MMU page size. I was playing 
around with the /dev/mem driver and it appears that you need 
to map memory on a MMU page boundary otherwise the driver 
will issue a fault. For ARM devices, I believe that the page 
size used by Linux is 4KB. So what you need to do is create a 
4KB mapping at address 0x01C40000 instead of 0x01C40C00. For example:

memread = (unsigned char*)mmap(NULL, 4096, PROT_READ, MAP_SHARED, memfd,
0x01C40000); 

You can then access the particular register by using a 0xC00 
offset with the address that mmap provides. 

Cheers
Jon
 
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to