LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 07-26-2011, 10:22 PM   #1
Zova
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Rep: Reputation: Disabled
Unhappy ARM TCM access


Hi all,
I'm trying to use the TCM (Tightly Coupled Memroy, a kind of SRAM, can be congiured as part of RAM and is used to improve performance) provided by S3c6410 (ARM1176ZJF-S based), which contains 16K ITCM and 16K DTCM.
Yeah, after a lot of searches and readings, I secceeded to write a simple driver to setup I/D-TCMs, and by issuing insmod to enable TCM at some physical memory address (not assigned according to system memory map in UM) when startup.
I wrote a very simple example to test. I got results show that the L1 cache + TCM way is even slower than just using L1 cache. Here's the code of the example:
Code:
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
#include <string.h>
 
#define MAP_SIZE 8192 
#define MAP_MASK (MAP_SIZE-1)

off_t dphybase = 0x0c002000;
off_t dphybase2 = 0x0c004000;
 
 
int main(){
        struct timeval startTime;
        struct timeval endTime;
        char ram_buff[MAP_SIZE], ram_buff2[MAP_SIZE], ch;
        char* tcm_buff;
        char* tcm_buff2;
        int i, mdesc, span, mag=10*MAP_SIZE, k;
 
        if((mdesc = open("/dev/mem",O_RDWR)) == 0) {
                perror("Error openning file /dev/mem");
                return;
        }
 
        tcm_buff = (char *)mmap(0, MAP_SIZE,PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, mdesc, dphybase&~MAP_MASK);
        tcm_buff2 = (char *)mmap(0, MAP_SIZE,PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, mdesc, dphybase2&~MAP_MASK);
 
        if((tcm_buff == (void*)-1)) {
                perror("Error mapping");
                return;
        }
 
        for(i=0;i<MAP_SIZE;i++){
                ram_buff[i] = i%128;
                ram_buff2[i] = i%128;
                tcm_buff[i] = i%128;
                tcm_buff2[i] = i%128;
        }
 
        /*
        * time ram_buff access
        */
        memset(&startTime, 0, sizeof(struct timeval));
        memset(&endTime, 0, sizeof(struct timeval));
        gettimeofday(&startTime, (struct timezone *) NULL);
        //read every one byte
        for(k=0;k<mag;k++)
        for(i=0;i<MAP_SIZE;i++) {
                ch = ram_buff[i];
                //ch += ram_buff2[i];
                //ram_buff[i] = ch;
        }
                //printf("%d ", ram_buff[i]);   
 
        //printf("\n");
 
        gettimeofday(&endTime, (struct timezone *) NULL);
 
 
        span = (endTime.tv_sec - startTime.tv_sec) * 1000000LL;
        span += (endTime.tv_usec - startTime.tv_usec);
        printf("Total time of ram_buffer access: %ld\n", span);
 
 
        /*
        * time tcm_buff access
        */
        memset(&startTime, 0, sizeof(struct timeval));
        memset(&endTime, 0, sizeof(struct timeval));
        gettimeofday(&startTime, (struct timezone *) NULL);
        //read every one byte
        for(k=0;k<mag;k++)
        for(i=0;i<MAP_SIZE;i++){
                ch = tcm_buff[i];
                //ch += tcm_buff2[i];
                //tcm_buff[i] = ch;
                //printf("%d ", tcm_buff[i]);
        }
        //printf("\n");
 
        gettimeofday(&endTime, (struct timezone *) NULL);
 
 
        span = (endTime.tv_sec - startTime.tv_sec) * 1000000LL;
        span += (endTime.tv_usec - startTime.tv_usec);
        printf("Total time of tcm_buffer access: %ld\n", span);
        munmap(tcm_buff, MAP_SIZE);
        return 0;
}

output:
Total time of ram_buffer access: 16888375
Total time of tcm_buffer access: 21927893
As shown in the code, I choose /dev/mem + mmap to operate on TCM.

Q1. Something wrong with my example or is it properate to test efficiecy of TCM vs. Cache and to conclude that TCM's slower?

I doubted about the physical address assigned to TCM(the User Manual does not show where they are assigned, however!), so I tried 0x0C002000(mentioned in the UM) and 0x80004000(found in smdk6410 test suites), but results make no difference. Maybe both of them are wrong location as arm info center says TCM's base address(physical address of course) can be anywhere. However, ANYWHERE maybe somewhere aleady given to other devices.So, if anyone has tried using TCM and configed it, please help me..

Q2. If my example and config are right, then what may be the cause of the lose of TCM to cache?

Q3. What's secure/non-secure access to TCM? I may config TCM as secure or non-secure according to here, but how do I know the access to TCM is secure or not?

Thanks,
Zova

Last edited by Zova; 07-26-2011 at 11:07 PM.
 
Old 08-01-2011, 02:23 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
A base address register assigns TCM physical address
 
Old 08-03-2011, 08:39 PM   #3
Zova
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by nini09 View Post
A base address register assigns TCM physical address
Hi nini09, yes, base physical address is assigned using a register called tcm region register. That part is done in a simple driver, not given above.
Have you ever try to make TCM work on arm1176 cores?

Thanks,
Zova
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling debian arm for NSLU2 - arm-linux-gnueabi-objdump not found ergosteur Linux - Kernel 3 10-30-2010 11:24 AM
Remote access via GSM using EDGE/3G to standalone ARM AchimRS Linux - Embedded & Single-board computer 1 09-18-2010 04:04 PM
Compile the linux2.6.14.1 for arm must ues the arm-linux-gcc-3.4.4? frankyue Linux - Embedded & Single-board computer 2 12-20-2008 07:28 AM
TCM (USB) mp3 player d00bid00b Linux - Hardware 1 11-01-2005 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration