EmbDev.net

Forum: ARM programming with GCC/GNU tools External Memory


von Jacopo C. (jacopo)


Rate this post
useful
not useful
Hi, I'm develloping on AT91SAM7SE-EK board and I want to use the
external memory interface (EBI) to comunicate with an external micro
(view as static memory).
The external memory address starts at 0x10000000 (as written in
AT91SAM7SE datasheet pag.22) and I made a pointer to that address:

#define AT91C_SMC_BASE   ((unsigned int *)0x10000000)

in the main loop I try to write in that location:

  for(i = 0; i < 100; i++)
    {
    *(AT91C_SMC_BASE + i) = i;
    }

When I try to debug in RAM mode, the debug (when accesses to
AT91C_SMC_BASE goes in error:
  "Could not read memory location 0x002021EC when trying to clear soft
RAM BP".
and the program generate a watchdog error.

I use Eclipse  and Yagarto toolchain (arm-elf cross compile) and use the
following part of makefile to link RAM objects:

sram: $(OBJS)
  $(LD) $(LDFLAGS) -Ttext 0x201000 -Tdata 0x200000 -n -o
$(OUTFILE_SRAM).elf $(OBJS)
  $(OBJCOPY) --strip-debug --strip-unneeded $(OUTFILE_SRAM).elf -O
binary $(OUTFILE_SRAM).bin

I think that it is some linker options that make crash the debug when it
tries to access to address out of it's map range

If I try to use the following one:

sdram: $(OBJS)
  $(LD) $(LDFLAGS) -Ttext 0x10000000 -Tdata 0x200000 -n -o
$(OUTFILE_SRAM).elf $(OBJS)
  $(OBJCOPY) --strip-debug --strip-unneeded $(OUTFILE_SRAM).elf -O
binary $(OUTFILE_SRAM).bin

but when I select the debug in RAM mode the result is:
"Execution is suspended because of error.
  continue
  Warning:
  Cannot insert breakpoint 3.
  Error accessing memory address 0x1000270: (undocumented errno -1)."

Does anyone have good idea to make it works on AT91SAM7SE-EK whit
external memory? Thanks

von Clifford S. (clifford)


Rate this post
useful
not useful
Not related but if the memory mapped device does not behave as a
single-ported memory device, you must declare it volatile:

#define AT91C_SMC_BASE   ((volatile unsigned int *)0x10000000)

I am not sure about the actual problem however, will have to check the
data sheet. I would be surprised if the linker script had any bearing on
this - all that is forgotten at run-time.

I am guessing that you must configure the EBI for static memory (your
script implies that it is SDRAM which has an entirely different
interface).

I'll take a look at the data sheet if I get a chance.

Clifford

von Jacopo C. (jacopo)


Rate this post
useful
not useful
Clifford Slocombe wrote:
> Not related but if the memory mapped device does not behave as a
> single-ported memory device, you must declare it volatile:
>
> #define AT91C_SMC_BASE   ((volatile unsigned int *)0x10000000)
>
> I am not sure about the actual problem however, will have to check the
> data sheet. I would be surprised if the linker script had any bearing on
> this - all that is forgotten at run-time.
>
> I am guessing that you must configure the EBI for static memory (your
> script implies that it is SDRAM which has an entirely different
> interface).
>
> I'll take a look at the data sheet if I get a chance.
>
> Clifford

thank you for the answer, but it doesn't change...
I configure the address (A0-A7) and data (D0-D7) pins to peripheral
function (and disable as pin) and use the code above but when I try to
access to SMC address (0x10000000) the debug generates a watchdog
error...

I restore the linker sram instruction in makefile:
sram: $(OBJS)
  $(LD) $(LDFLAGS) -Ttext 0x201000 -Tdata 0x200000 -n -o
$(OUTFILE_SRAM).elf $(OBJS)
  $(OBJCOPY) --strip-debug --strip-unneeded $(OUTFILE_SRAM).elf -O
binary $(OUTFILE_SRAM).bin


and it doesn't change...

Thanks in advance for your help.

von Clifford S. (clifford)


Rate this post
useful
not useful
Jacopo Charmet wrote:
> thank you for the answer, but it doesn't change...
I did not expect it to. You need to declare the pointer volatile, but as
I said ist is not related to your current problem (but it might have
caused you problems later).

You may have missed my point about sram and sdram, those are just labels
in the linker script. I was merely pointing out that the use of the
label "sdram" rang alarm bells because the external device will not
behave like SDRAM. If your code attempts to configure that adddress
range as SDRAM it will not work. My guess was that if you were using a
linker script that assumed referred to SDRAM, you may well be using
runtime start-ip code that configures the hardware for SDRAM. The linker
script itself does nothing to configure the hardware (except possibly
provide symbolic addresses later used by the hardware configuration
code), so I would not expect any changes there to solve the problem.

I would expect typically that the EBI should be configured to match your
ardware within the runtime initialisation (typically crt0.s).

As I said I have not looked at the data sheet and have only a passing
knowledge of this part, but that's where I'd start looking myself.

Clifford

von Clifford S. (clifford)


Rate this post
useful
not useful
I took a quick look at the AT91SAM7SE manual. Chapter 22 of the user
manual deals with the Static Memory Controller (SMC). You need to
correctly configure SMC_CSR0 for your hardware. The external micro must
also behave appropriately - i.e it may not drive the bus outside of the
bus access cycle for CSR0. You must also ensure that the EBI_CSA
register is configured to match your hardware.

You have not really provided sufficient information to determine what
(or where) your problem may be.

Clifford

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
No account? Register here.