EmbDev.net

Forum: ARM programming with GCC/GNU tools SDRAM Interfacing


Author: John As (johnnie)
Posted on:

Rate this post
0 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.

Author: Martin Thomas (mthomas) (Moderator)
Posted on:

Rate this post
0 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.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 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

Author: Amit Chatre (aseem)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.