I wrote a driver to enabe TCM on ARM1176jzf-s based board. It shows success when I insmod. I set the base address of ITCM to 0x100000. Then, I tried to write something to that space from user space. I found one way to do that by open /dev/mem, and mmap to get a virtual address.
Here's the code
off_t iphybase = 0x100000;
....
if((mdesc=open("/dev/mem",O_RDWR))==0) {
perror("Error openning file /dev/mem");
return false;
}
ibase = (char *)mmap(0, MAP_SIZE,PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, mdesc, iphybase&~MAP_MASK);
Then, I put some code (JIT'ed code, acctually) into it, and run with gdb and shell command. Both get segment faults. I checked the mapped address in gdb, but it is not accessiable like this
(gdb) x/i 0x50b11158 0x50b11158: Cannot access memory at address 0x50b11158
segment faults at the address above, and strangly, it is not the base address returned by mmap, which means instructions starting from ibase got executed, right? Then, why segment faults?
So, where the problem? Did I use the TCM in a right way? Please help me out. ANY ADVICE WILL BE APPRECIATED. Thanks very very much.
This post has been edited by Zova: 27 June 2011 - 06:47 AM















