PSoC4100S How to set code in SRAM with GCC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ReMa_3807036
Level 2
Level 2
First like received

Hi,

I'm trying to put code to SRAM with PSOC4100S and GCC compiler.

I have followed some code example,

first to specify the section:

CY_SECTION(".sramCode") __attribute__((used))

void example(void)

{

...

}

Then, I have specified  the direttive in linker file  cm0plusgcc.ld as follow:

...

MEMORY

{

    rom (rx) : ORIGIN = 0x0, LENGTH = 32768

/*was    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4096*/

    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 3072

   

    sramCode(rwx): ORIGIN =0x20000C00 LENGTH = 1024

   

}

...

Now, after the "build" I can see in the map file the new segment "sramCode" in the specified position, but when I debug the SW, in particular when I halt into the example routine, I can see that the PC register is not over 0x20000C00 but its value is 0x4xxx (in flash area!).

Some other things are missing?

Thanks for help.

Renato

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi Len,

I have seen your tentative ... thanks for the efforts but I believe (maybe I'm wrong) that the moving from flash to ram has to be done "automatically" by "startup routine", giving the right attribute to the routine to move.

Here you can find an updated to the project,  there I used "ram"  as attribute instead of "sramCode", in this way it is not necessary to modify the linker file (.ld), now the routine NonBlockWriteRow()  is located in SRAM.

Also the "SpcIntHandler" is in SRAM, but at the moment this interrupt never happen, and it is the actual issue (in vector table the address is relocated, and it is ok, address 0x20000070).

Yes I know the Em_EEPROM component..., using them the Write operation stops the cpu for some ms (about 20ms), in the project I will use a multiplexed LED display, to wait 20ms to update it  produces a "flicker" effect.

Br

Renato

View solution in original post

0 Likes
9 Replies