LPC4370 Flash usage issue: maxed out at 20%

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC4370 Flash usage issue: maxed out at 20%

Jump to solution
1,258 Views
a_bet
Contributor IV

Hi to you all,
I'm developing on a LPC4370 using LPC-Link2 as evaluation board.
I have a problem with the flash memory, as for my understanding it should be 1MB, but I can only use 19.80% of it.

Here's my memory configuration:

Selection_087.png

To specifically use the SPIFI section I allocate data this way:

__DATA(SPIFI) int32_t buffer1[BUFF_SIZE] = {0};
__DATA(SPIFI) int32_t buffer2[2*BUFF_SIZE] = {0};

The problem is that when the dimension exceeds roughly the 20% of the memory capacity, the linker start to put stuff in the much smaller RAM (RamLoc128), which easily overflows giving me the following error:

/usr/local/mcuxpressoide-11.1.1_3241/ide/plugins/com.nxp.mcuxpresso.tools.linux_11.1.0.202001081728/tools/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: s2d_single_core.axf section `.data' will not fit in region `RamLoc128'

/usr/local/mcuxpressoide-11.1.1_3241/ide/plugins/com.nxp.mcuxpresso.tools.linux_11.1.0.202001081728/tools/bin/../lib/gcc/arm-none-eabi/8.3.1/../../../../arm-none-eabi/bin/ld: region `RamLoc128' overflowed by 19212 bytes


Selection_088.png

Any guess why I am unable to fully use the memory?

Thanks,
Andrea

Labels (4)
1 Solution
1,198 Views
converse
Senior Contributor V

It's flash - you cannot 'just write' to flash, it needs to be programmed in blocks. Flash is treated at read-only memory.

Flash is normally used for persistent storage - things such as code, images, fixed data. Flash is normally changed very infrequently - for example when you make a new release of your code, or want to change an image. When you do want to change it, it first needs to be erased, and then the new data is written in blocks (typically several kilobytes at a time).

So, no, you cannot use it for variables and 'data holders' unless they are constant.

View solution in original post

4 Replies
1,198 Views
converse
Senior Contributor V

You have told the compiler to place the buffer into flash, but you have not told it that it is read-only and so it will still try to place it into RAM. You also cannot initialise it. You need to define your buffers as

_DATA(SPIFI) const int32_t buffer1[BUFF_SIZE] ;
__DATA(SPIFI) const int32_t buffer2[2*BUFF_SIZE] ;

1,198 Views
a_bet
Contributor IV

Hi converse‌ ,
thanks a lot for the reply.
So I tried your definition, but GCC now complains every time I try to write to it.

../src/S2D_main.c:250:25: error: assignment of read-only location 'buffS_unpacked[j]'

I mean, what it the correct way to use this memory for variables and data holders? 
I found this on how to write to const vars, but it is far from elegant I guess.

0 Kudos
1,199 Views
converse
Senior Contributor V

It's flash - you cannot 'just write' to flash, it needs to be programmed in blocks. Flash is treated at read-only memory.

Flash is normally used for persistent storage - things such as code, images, fixed data. Flash is normally changed very infrequently - for example when you make a new release of your code, or want to change an image. When you do want to change it, it first needs to be erased, and then the new data is written in blocks (typically several kilobytes at a time).

So, no, you cannot use it for variables and 'data holders' unless they are constant.

1,198 Views
a_bet
Contributor IV

First timer in using flash memory? Here I am!
Thanks a lot, I am running out of memory so I'm exploring. 

0 Kudos