EmbDev.net

Forum: ARM programming with GCC/GNU tools SDRAM Interfacing


von John A. (johnnie)


Rate this post
useful
not useful
Hi,

I'm using a crossworks 1.7.I have Interfaced a SDRAM K4s561632H with
LPC2478.
I tested it successfully I write some data to it and then read like

  wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
  char_wr_ptr = (UByte *)wr_ptr;
  // Clear content before 8 bit access test
  for ( i= 0; i < SDRAM_SIZE/4; i++ )
      *wr_ptr++ = 0;

  // 8 bit write
  for (i=0; i<SDRAM_SIZE; i++){
  *char_wr_ptr++ = 0xAA;
  *char_wr_ptr++ = 0x55;
  *char_wr_ptr++ = 0x5A;
  *char_wr_ptr++ = 0xA5;
  }

  // verifying
  wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
  for ( i= 0; i < SDRAM_SIZE/4; i++ ){
  if ( *wr_ptr != 0xA55A55AA )  // be aware of endianess
          return FALSE;

  wr_ptr++;
  }

It works perfectly.
My main problem is saving variables in External SDRAM.
cause I have a huge variable arrays.and at the time of building project
it gives error .bss is too large to fit in SRAM memory segment.
like this it gives error for non_init,heap,stack for irq,fiq,und,svc...

I tried to change the size of SRAM from Memorymap.xml and code is built
successfully,but because of that code is not running on hardware.

Please suggest the solution for the same.

Thanks.

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
John As wrote:
> Hi,
>
> I'm using a crossworks 1.7.I have Interfaced a SDRAM K4s561632H with
> LPC2478.
Did you ask Rowley? Crossworks is a commercial tool and I expect they
offer support for this.

> I tested it successfully I write some data to it and then read like
>
>   wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
>   char_wr_ptr = (UByte *)wr_ptr;
>   // Clear content before 8 bit access test
>   for ( i= 0; i < SDRAM_SIZE/4; i++ )
>       *wr_ptr++ = 0;
>
>   // 8 bit write
>   for (i=0; i<SDRAM_SIZE; i++){
>   *char_wr_ptr++ = 0xAA;
>   *char_wr_ptr++ = 0x55;
>   *char_wr_ptr++ = 0x5A;
>   *char_wr_ptr++ = 0xA5;
>   }
>
>   // verifying
>   wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
>   for ( i= 0; i < SDRAM_SIZE/4; i++ ){
>   if ( *wr_ptr != 0xA55A55AA )  // be aware of endianess
>           return FALSE;
>
>   wr_ptr++;
>   }
>
> It works perfectly.
> My main problem is saving variables in External SDRAM.
> cause I have a huge variable arrays.and at the time of building project
> it gives error .bss is too large to fit in SRAM memory segment.
> like this it gives error for non_init,heap,stack for irq,fiq,und,svc...

Most probably since you have filled up the bss with the huge arrays and
there is not more room.

> I tried to change the size of SRAM from Memorymap.xml and code is built
> successfully,but because of that code is not running on hardware.

I don't use Crossworks but I expect that "Memorymap.xml" is some kind of
control-file for a linker-script generator.

It's difficult to help without locking at least at the startup-code and
the linker-script.

Check the order in the startup-sequence and make sure that the
SDRAM-Controller get initialized before runtime-init of .data and .bss.

As an alternative you might locate you "huge arrays" in a special
section and do the initialization (zero-init) yourself.  See section
attribute in the gcc-manual/Crossworks documenation, check the
Crossworks manual how to configure "Memorymap.xml" to link extra
sections and configure additional memory-areas.

von Clifford S. (clifford)


Rate this post
useful
not useful
You will need to modify the linker script to place data in the external
SDRAM rather than the internal SRAM. The linker is presumably placing
the stack, static data and heap in internal SRAM.

You should configure the SDRAM controller in the C runtime start-up
before stack set-up, static initialisation, and jumping to main().


Note also that executing code from SDRAM is likely to be faster than
from Flash. Also if you are using a 16bit data bus to the SDRAM and
executing from SDRAM you will get better performance using Thumb mode
rather than ARM mode.

Clifford

von Amit C. (aseem)


Rate this post
useful
not useful
Clifford Slocombe wrote:
> You will need to modify the linker script to place data in the external
> SDRAM rather than the internal SRAM. The linker is presumably placing
> the stack, static data and heap in internal SRAM.
>
> You should configure the SDRAM controller in the C runtime start-up
> before stack set-up, static initialisation, and jumping to main().
>
>
> Note also that executing code from SDRAM is likely to be faster than
> from Flash. Also if you are using a 16bit data bus to the SDRAM and
> executing from SDRAM you will get better performance using Thumb mode
> rather than ARM mode.
>
> Clifford

Thanks for supporting everyone,

              I tried solutions and I found solution on existing
problem.

Now I am facing another problem,with memroy management. My current code
size is exceeds 512k including RODATA. I'm planning to Interface
external parallel flash with this controller.But confusion is How to
write code in internal memory and RODATA in external flash , is there
utility is available by using I can able to program internal as well as
external flash.
             So any idea about this please Its really serious problem
for me...

Thanks

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.