Hi All, I am using Samsung S3C2440 board to which linux kernel is ported and now i have an application board i need to make the system bus interface for my application board and S3C2440 board(i.e., memory mapping of Address and Data bus of S3C2440 to Address and Data bus of application board). How to do this.. any suggestions please.
Your question is somewhat short of essential detail. The term "application board" is rather vague. Either way you probably need to familiarise your self with Chapter 5 - Memory Controller of the S3C2440 User Manual. There are 8 banks each of which select a 128Mb address space, all banks support conventional ROM, SRAM type address/data bus, and two additionally support SDRAM. All banks support 8/16/23 bit data bus, except Bank 0 which has only 16/32 bit bus support. One of these banks will already be used by your board for SDRAM, and another for Flash memory. Possibly there are additional memory mapped devices on your board, which may use additional bank slect lines. Your board's user guide or schematic will tell you which ones are available. Basically you need to hook up your board to the necessary data and address lines, and the bank select to the data bus tri-state latch (chip select), and hook up the R/W select line. You will also need to enable the selected memory region in the MMU configuration.
Hi, Thanks for your reply i have attached the application board schematic here i mapped the address bus (A1-A3) and Data bus (D0-D7)to IDE connector of address bus (LADDR1-LADDR3) and data bus (LDATA0-LDATA7). Also i have made a code the if i select the particular memory location say 0x08000000 then the chip select(nGCS1) has to enable and if i continuously read the content of the memory location then the chip select(nGCS1) has to enable continuously till i kill the execution of the program. If i check the nGCS1 pin of the IDE connector in the CRO chip select will happens only once but not continuously. Please find the attachment and below code.
1 | /******************test.c****************/
|
2 | |
3 | #include <stdio.h> |
4 | #include <stdlib.h> |
5 | #include <unistd.h> |
6 | #include <stdio.h> |
7 | #include <stdlib.h> |
8 | #include <fcntl.h> |
9 | #include <sys/mman.h> |
10 | #include <sys/ioctl.h> |
11 | |
12 | #define MAP_SIZE 4096UL
|
13 | #define MAP_MASK (MAP_SIZE - 1)
|
14 | |
15 | #define DATA 0x08000000
|
16 | |
17 | int main(int argc, char *argv[]) { |
18 | int fd; |
19 | void *map_base, *virt_addr; |
20 | unsigned long read_result, writeval; |
21 | |
22 | if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) |
23 | return -1; |
24 | while(1){ |
25 | map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, DATA & ~MAP_MASK); |
26 | if(map_base == (void *) -1) |
27 | return -1; |
28 | |
29 | virt_addr = map_base + (DATA & MAP_MASK); |
30 | read_result = *((unsigned long *) virt_addr); |
31 | |
32 | // Write into the memory location 0x08000000
|
33 | writeval = read_result; |
34 | writeval = 0x0AA; //WRITE THE DATA TO MEMORY |
35 | *((unsigned long *) virt_addr) = writeval; |
36 | printf("writeval = 0x%X\n", writeval); |
37 | |
38 | //Read the content of the memory location 0x08000000
|
39 | read_result = *((unsigned long *) virt_addr); |
40 | printf("read_result = 0x%X\n",read_result); |
41 | }
|
42 | |
43 | if(munmap(map_base, MAP_SIZE) == -1) |
44 | return -1; |
45 | |
46 | close(fd); |
47 | return 0; |
48 | |
49 | }
|
I am no expert on Linux, but you will at least need to disable the cache for the application board's memory mapped region, otherwise you will simply read what is in the cache rather than what is on the board - which might explain the apparent single access. Similarly you should declare pointers that map to the region as volatile; otherwise the optimiser may potentially remove a read and use the value previously read into a register.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.