Out of CX3 memory

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

cross mob
ScGr_289066
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi All,

I have been working on this firmware (https://community.cypress.com/thread/16971?start=0&tstart=0) and have finally run out of memory?  When I compile my latest code, the linker spits out:

c:/program files (x86)/cypress/ez-usb fx3 sdk/1.3/arm gcc/bin/../lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld.exe: OV5647_dual_camera_NOUVC_e.elf section `i._tx_mutex_prioritize' will not fit in region `SYS_MEM'

c:/program files (x86)/cypress/ez-usb fx3 sdk/1.3/arm gcc/bin/../lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld.exe: section .data loaded at [40030000,4003188f] overlaps section i._tx_mutex_prioritize loaded at [4002ff00,400300ff]

c:/program files (x86)/cypress/ez-usb fx3 sdk/1.3/arm gcc/bin/../lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld.exe: section i._tx_queue_cleanup loaded at [40030100,400301b7] overlaps section .data loaded at [40030000,4003188f]

c:/program files (x86)/cypress/ez-usb fx3 sdk/1.3/arm gcc/bin/../lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld.exe: region `SYS_MEM' overflowed by 440 bytes

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\/arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':

writer.c:(.text+0x20): undefined reference to `_write'

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\/arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':

closer.c:(.text+0x18): undefined reference to `_close'

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\/arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':

lseekr.c:(.text+0x20): undefined reference to `_lseek'

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\/arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':

readr.c:(.text+0x20): undefined reference to `_read'

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\ARM GCC\/arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':

sbrkr.c:(.text+0x18): undefined reference to `_sbrk'

collect2.exe: error: ld returned 1 exit status

cs-make: *** [OV5647_dual_camera_NOUVC_e.elf] Error 1

13:08:43 Build Finished (took 13s.977ms)

The linker map files are pretty confusing to look at so I have written a little program to summarize lengths of the various modules.  When I look at the current version of my code, and a former version that does compile without error, I see the current version is *shorter* than the old version that compiles, which is perplexing.  This brings up numerous questions:

1) Can someone point me to a document that discusses the various memory sections used by the CX3 libraries?

2) The CX3 (CYUSB3064) part data sheet says the parts have 512 or 256 KB of SRAM but there is no mention as to which family member has how much memory.  Are we to guess that the 4-lane version has 512K and the 2-lane as 256K?

3) Neither program is anywhere near close to this limit, is SYS_MEM some special memory section that must be considered separately, or am I not understanding how data is loaded for CX3 execution?

4) I have seen the compiler spit out similar errors when I had a grave macro syntax problem.  I had imbalanced parenthesis in a macro and compensated for it by adding an extra parenthesis in the macro expansion.  The compiler didn't mention and memory overlaps, but did spit out many missing symbol errors (_sbrk, _write, _close, ...).

Thanks as always,

Scott

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

Scott,

You need to modify the .ld file to increase the SYS_MEM (180 KB).

This can be done in the .ld file and cyfxtx.c file.

Note that once you change the .ld, ensure that modifed .ld file is used in Linker Settings.

Just by changing the CY_U3P_SYS_MEM_TOP to 0x40080000 will not increase the code area.

This will increase only DMA area.

I did the required modification and provided the files with this response.

The modfied settings are as follows:

Memory Configuration

Name             Origin             Length             Attributes

I-TCM            0x00000100         0x00003f00

SYS_MEM          0x40003000         0x00035000

DATA             0x40038000         0x00008000

Application memory map for FX3 firmware is as follows:

   Descriptor area    Base: 0x40000000 Size: 12  KB

   Code area          Base: 0x40003000 Size: 212 KB

   Data area          Base: 0x40038000 Size: 32  KB

   Driver heap        Base: 0x40040000 Size: 32  KB

  Buffer area        Base: 0x40048000 Size: 224 KB // DMA is same.

  2-stage boot area  Base: 0x40080000 Size: 0  KB

Please use the attached .ld file and cyfxtx.c file in your project and build the firmware.

The path for .ld file to be replaced can be checked in Linker settings as shown in below diagram.

Please replace cyfxtx.c file in the project.

pastedImage_2.png

Regards,

Sridhar

View solution in original post

0 Likes
6 Replies
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Hello Scott,

CX3 CYUSB3064 and CYUSB3065 parts have 512 KB SRAM, There is no 256 KB SRAM part in CX3 like FX3.

-----------------------------------------------------------------------------------------------------

The memroy organisation of CX3 is as follows:

This is documented in cyfxtx.c file in the project.

The default application memory map for FX3/CX3 with 512 SRAM is as follows:

   Descriptor area    Base: 0x40000000 Size: 12  KB

   Code area          Base: 0x40003000 Size: 180 KB

   Data area          Base: 0x40030000 Size: 32  KB

   Driver heap        Base: 0x40038000 Size: 32  KB

   Buffer area        Base: 0x40040000 Size: 224 KB

   2-stage boot area  Base: 0x40078000 Size: 32  KB

   Note: The 2-stage boot area is optional (only required if the application makes use of a persistent

   in-memory boot-loader). If this is not being used, the 32 KB reserved for this segment can be merged

   into the buffer area by changing CY_U3P_SYS_MEM_TOP to 0x40080000.

*/

/*

   The following definitions specify the start address and length of the Driver heap

   area which is used by the application code as well as the drivers to allocate thread

   stacks and other internal data structures.

*/

#define CY_U3P_MEM_HEAP_BASE         (0x40038000)

#define CY_U3P_MEM_HEAP_SIZE         (0x8000)

/*

   The last 32 KB of RAM is reserved for 2-stage boot operation. This value can be

   changed to 0x40080000 if 2-stage boot is not used by the application.

*/

#define CY_U3P_SYS_MEM_TOP           (0x40078000)

-----------------------------------------------------------------------------------------------------------

As per the memory overlap error mentioned above, the code size is exceeding 180 KB.

Can you please try to build with Release mode libraries and see whether there are any errors.

Regards,

Sridhar

0 Likes

Hi Sridhar,

Thanks for the answer, that has help a bunch.

Alas, I am building in release mode, so no help there.

Best,

Scott

0 Likes

Hello Scott,

Please let me know what happened when you build the library using Release mode.

Are you still facing issues in building the firmware?

Regards,

Sridhar

0 Likes

Hi Sridhar,

I have always used release mode, so no help there.  I'll try using the 2-stage boot area as extra code space.

Unfortunately it didn't help my out of memory situation.  Any other thoughts?

Thanks,

Scott

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

Scott,

You need to modify the .ld file to increase the SYS_MEM (180 KB).

This can be done in the .ld file and cyfxtx.c file.

Note that once you change the .ld, ensure that modifed .ld file is used in Linker Settings.

Just by changing the CY_U3P_SYS_MEM_TOP to 0x40080000 will not increase the code area.

This will increase only DMA area.

I did the required modification and provided the files with this response.

The modfied settings are as follows:

Memory Configuration

Name             Origin             Length             Attributes

I-TCM            0x00000100         0x00003f00

SYS_MEM          0x40003000         0x00035000

DATA             0x40038000         0x00008000

Application memory map for FX3 firmware is as follows:

   Descriptor area    Base: 0x40000000 Size: 12  KB

   Code area          Base: 0x40003000 Size: 212 KB

   Data area          Base: 0x40038000 Size: 32  KB

   Driver heap        Base: 0x40040000 Size: 32  KB

  Buffer area        Base: 0x40048000 Size: 224 KB // DMA is same.

  2-stage boot area  Base: 0x40080000 Size: 0  KB

Please use the attached .ld file and cyfxtx.c file in your project and build the firmware.

The path for .ld file to be replaced can be checked in Linker settings as shown in below diagram.

Please replace cyfxtx.c file in the project.

pastedImage_2.png

Regards,

Sridhar

0 Likes

Hi Sridhar,

Thanks for much, my memory errors are gone!

Scott

0 Likes