This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using eb40a external SRAM HOWTO


Hello,

I have successfully expanded the ram on my eb40a to 1MB. 
I will try to give you a small HOWTO. 

First of all I would suggest to create your own hal subdirectory in order not to mess up the original code. So copy the original /packages/hal/arm/at91/eb40a to somethong like /packages/hal/arm/at91/my_eb40a. In /packages/ecos.ecc you should create your own target that uses the new hal directory. Have a look at the file and do some copy and paste there.
After that you should have a look at my_eb40a/.../include/hal_platform_setup.h. 
There you find the following section:

...
_InitMemory:
long   0x01002535  // 0x01000000, 16MB   This is the Flash ROM
long   0x02002121  // 0x02000000, 16MB   This is the external RAM
...

These values get directly loaded to the EBI Chip Select Registers in the AT91R40008. If you want to know what these values mean, have a look at the datasheet, You only have to change them if you install slow memory chips that need more than 1 wait state or some wait cycles after transfer. I had to do this in may configuration, I also had to change the page size, so here a little example:

...
long   0x02002225  // 0x02000000, 1MB,  1 cycle after transfer, 16-bit, 2 wait states
...

After that have a look at the files in the my_eb40a/.../include/pkgconf/ directory. They define the memory layout of the board. They are all similar, so I give only an example for the RAM version.
Let's start with mlt_arm_at91_eb40a_ram.h.

// original configuration, using the internal RAM
#define CYGMEM_REGION_ram (0x00000000)
#define CYGMEM_REGION_ram_SIZE (0x00040000)
#define CYGMEM_SECTION_heap1_SIZE (0x00040000 - (size_t) CYG_LABEL_NAME (__heap1))

// modified version, using 1MB of external RAM
#define CYGMEM_REGION_ram (0x02000000)
#define CYGMEM_REGION_ram_SIZE (0x00100000)
#define CYGMEM_SECTION_heap1_SIZE (0x02100000 - (size_t) CYG_LABEL_NAME (__heap1))

Next you have to modify mlt_arm_at91_eb40a_ram.ldi.

// original configuration, using the internal RAM
MEMORY
{
    ram : ORIGIN = 0x00000000, LENGTH = 0x40000
}

SECTIONS
{
    SECTIONS_BEGIN
    SECTION_fixed_vectors (ram, 0x20, LMA_EQ_VMA)
    SECTION_rom_vectors (ram, 0xc000, LMA_EQ_VMA)
    SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_rodata1 (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
    SECTIONS_END
}

// modified version, using 1MB of external RAM
MEMORY
{
    ram : ORIGIN = 0x02000000, LENGTH = 0x100000
}

SECTIONS
{
    SECTIONS_BEGIN
    SECTION_fixed_vectors (ram, 0x02000020, LMA_EQ_VMA)
    SECTION_rom_vectors (ram, 0x0200c000, LMA_EQ_VMA)
    SECTION_text (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_fini (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_rodata (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_rodata1 (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_fixup (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_gcc_except_table (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_data (ram, ALIGN (0x4), LMA_EQ_VMA)
    SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
    CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
    SECTIONS_END
}

Do these changes also to the ROM and the ROMRAM configurations.

Now you have to build a new redboot, that uses your modified my_eb40a package.
After flashing redboot, your prompt should look like that:

RedBoot(tm) bootstrap and debug environment [ROM]
Non-certified release, version UNKNOWN - built 16:04:24, Oct 10 2003

Platform: Atmel AT91/EB40A (ARM7TDMI)
Copyright (C) 2000, 2001, 2002, Red Hat, Inc.

RAM: 0x02000000-0x02100000, 0x0200a7a8-0x020ff000 available
FLASH: 0x01010000 - 0x01200000, 31 blocks of 0x00010000 bytes each.
RedBoot>

Now you have to build ecos with the new package an link it to your application. That's all.

I hope this is helpful. Any suggestions for improvement are appreciated.

Best regards to all the ecos freaks out there,
Dirk


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]