PSoC 62 Application flash size

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

cross mob
lock attach
Attachments are accessible only for community members.
DeWa_4681626
Level 1
Level 1

Hi
I am building my application in Mbed-OS 5.15.1 on PSoC 62. According to the datasheet, application flash has a capacity of 1MB. Before I added WiFi to my application, the text section of my application (contains other features such as BLE) was about 442KB, and it ran fine. However, after adding WiFi feature, compilation would fail with the following message

region `flash` overflowed by 26716 bytes.

However, as I reviewed the linker file, 1MB is allocated for `flash` section. I understand that application is shared between two cores. The code for CM0+ is about 6KB, and my application size seems to be below the limit as well. Thus, I am quite puzzled why compiler thinks there is an overflow. Really appreciate if anyone can help pin point the issue. Is there something missing? Or where I can look into to resolve the issue?

Thanks,

Dennis

0 Likes
1 Solution

According to the attached documentation:

Application Size is - 0x10000000 - 0x100FFFFF = FFFFF

Your application is size is:

MBED_RAM_SIZE = 0x00045800

+FLASH_CM0P_SIZE=0x2000

+MBED_APP_SIZE=0xFE000

                                                                             = 0x145800

Go back to it working -  save the map

Then add your wifi - save the map

It should give you some clues...

Are somehow send what you can so I can recreate your issue...

By suspision is that there is a zero to many in your make file, recheck your build files

View solution in original post

0 Likes
22 Replies
lock attach
Attachments are accessible only for community members.
WiWi_4702256
Level 5
Level 5
5 sign-ins Welcome! 5 solutions authored

Dennis,

I am working on a dual program. Maybe you could compare mine against yours and it will give you some insight.

I thought that you might try letting  the system decide stack size using the dummy variable... Just a guess on my part.

Untitled.gif

William

0 Likes

Hi William,
Thanks for the reply and the suggestion. I modified the stack section based on your linker script. Unfortunately, I still see the flash section overflow compilation error...

In your dual program, are you able to use more than 512KB of the application flash area?

0 Likes

Dennis,

I am used to looking at the map and it tells me start finish and used...

I dont see that...

The best I have is memory configuration and the code size and sram after a successful build. If you want me too I will send the map of the cm0 and cm4...

Williamsmemoryuse.gif

0 Likes

Hi William,
Really appreciate the help! The previous linker script didn't contain the memory map. If I may borrow your expertise, would you mind helping me diagnose what might go wrong in the linker script or memory map?

Below is the memory map configuration when the compiler thinks there is an overflow.
In PSoC 62, the actual application flash is from 0x10000000 to 0x10100000. cm0p_image + flash should fit into this region, but I am quite puzzled why flash section is allocated with 0xfe000.
cm0p_image contains small piece of code to boot CM4 from CM0+. It is about 6KB.
My WiFi portion is about 88KB (the number is obtained by removing other features and get the difference between compilation with WiFi feature and compilation without WiFi feature). So this 88KB increment should fit with my rest of the application + cm0p_image, which is about 442KB + 6KB, when I put the code together. My WiFi feature is independent to other features.
Thus, I am quite puzzled why flash section is allocated with 0xfe000.

memcfg.PNG

Thanks,
Dennis

0 Likes

Dennis,

I assume since you are using mbed, you are using modustoolbox correct? So if you running mbed, how did you and where did you get the wifi from? You said you added wifi and ran into problems correct?

Also, had you made all your mods to the linker file before or after or both once the addition of wifi.

So if you could describe you environment to me maybe I can recreate it.

Or you could bundle the software and send it unless you are in my situation and cannot send software since you dont own it and under a 5 year NDA agreement.

Thanks,

William

0 Likes

Hi William,
Thanks a lot for the help!

I assume since you are using mbed, you are using modustoolbox correct? So if you running mbed, how did you and where did you get the wifi from? You said you added wifi and ran into problems correct?

I am using mbed-os to develop my application, so the wifi is directly from mbed API. If I use wifi alone (and remove other features), compile can pass and wifi is working fine.

Also, had you made all your mods to the linker file before or after or both once the addition of wifi.

The mods you referred to were the stack size modifications in linker file, right? I did that and compiled it with the addition of wifi, and still ran into the overflow compilation error.


Nevertheless, reading from your other comments, I think you have nailed down the issue. "MBED_RAM_SIZE = 0x00045800" is quite a big area.
This linker file was taken directly from mbed (they provided support for PSoC 62).

I have limited knowledge on the linker script, so please correct me if I misunderstood, so MBED_RAM_SIZE is the size of the "ram" area which is used by .ramVectors, .data, .noinit, .bss, and .heap sections. Is it ok to change this size? What would be the recommended size for "ram"?
And by letting the system decide the stack size we can use smaller MBED_RAM_SIZE? 

Thanks,
Dennis

0 Likes

Which kit do you have Dennis?

PSoC 6 WiFi-BT Prototyping Kit

PSoC 6 WiFi-BT Pioneer Kit

or...

1. The reason I ask is you may be running into the same situation I ran into... AnyCloud_OTA_MQTT on PSOC 6 WIFI-BT Pioneer Kit

KitIssue.gif

Lets just eliminate that possibility ok...

2. Then could you tell me what you are trying to accomplish with your program development (IoT, etc)?

3. Then could you tell me what development platform you are using WICED, PSOC Creator, or Modustoolbox or a combination of one or more of those IDE's?

4. Why did you choose to use mbed os? The reason I asked that is because I tried mbed in the beginning and just did not seem to be the right choice. FreeRTOS seems to be the goto OS in AWS and Cypress it seems to me...

Well... I did some checking and found some interesting tidbits... I searched on "mbed_ram_start and mbed_ram_size psoc 62" and found this... Have you seen this? It may be what your dealing with...

maybeissue.gif

Plus there is this fellow named Alan Hawse with IOT Expert, I've seen him on some Cypress Training Videos... So I believe he is with Cypress... Anyway I found a page for PSoC mbed instructions that may be used to compare how he set up the files the about image speaks about...

Alan_H.gif

Also since you are using mbed, then you can use the mbed command you will see on the image to download his examples for comparison and possibly to use in your application...

Keep me posted...

William

0 Likes

So just to make sure, the one sentence in the image is "the CMSIS DFP Pack has no information about RAM split between CM4 & CM0+ applications"... I bet that is the issue... I hope it is at least...

0 Likes

Hi William,

Really appreciate for looking into these in great details. Regarding your questions

  1. I am using PSoC 6 WiFi-BT Pioneer Kit
  2. I am building a wearable device with sensors on top of it. It is getting the sensor data frequently, but it only accesses the WiFi when it needs to upload massive data to the server.
  3. I am using Mbed Studio IDE.
  4. We switch to PSoC 62 from previous development and RTOS is one of the requirements for the firmware. So far Mbed API's seem to be well supported, we haven't ran into serious issues.
    May I know what kind of issues you ran into with Mbed? Maybe we haven't encountered it yet...

    Thanks for sharing the commit about mbed_ram_start and mbed_ram_size. After reviewing their comments and my linker script, I noticed that although MBED_RAM_SIZE = 0x00045800, MBED_RAM_START is set to 0x08002000, so I think we can't add MBED_RAM_SIZE to FLASH_CM0P_SIZE + MBED_APP_SIZE....


Thanks,
Dennis

0 Likes

Dennis,

Cool, very cool, we have a branch that does wearable's too... I built a wear leveling algorithm for NOR for them. The device is worn by the crew-members as they go about their daily activities onboard the International Space Station. The device monitors and stores CO2 levels and stores the data in external flash, soon as they get within range of a laptop on board it connects and downloads the data via BLE to the laptop and then to the ground.

So your just going to add FLASH_CM0P_SIZE + MBED_APP_SIZE and give it a try? I think your right. Let me know if that works.

As far as the MBed OS issue(s), I actually can't recall the specific issue at this point however, I do recall my personal feelings about using CLI and IDE to develop with so its more personal preference with using CLI and IDE to develop than issues that made me go to FreeRTOS.

This will be my first application written that uses an OS on an "embedded" device. I've always used Interrupt Architecture to develop our applications. However, with these Cypress SoC MCU's, you really need an OS.

I've bumped into FreeRTOS several times at work, and even though we work with ARM MCU's (TI's RM48) I really have not heard of mbed OS until I started consulting and working on this side project... I am doing some remote consulting work...

I really have enjoyed learning this new Cypress environment and learning about IoT, its very cool! However, its been a painful sharp learning curve for me. Both with Cypress, IoT, AWS... AWS is like the rain forest, its overwhelming, yet with the AnyCloud community I've been able to control my devices from the cloud. Currently I am working on uploading and downloading files to from a S3 bucket... Feels like a firehouse of knowledge being shoved into my brain... LOL! Haven't figured out S3 buckets yet (specifically policies) but I will...

Keep me posted,

William

0 Likes

Hi William,
Thanks for sharing your project! It sounds very cool and must be an honor to make contribution to the international space station!

I have signed an NDA, so I can't disclose too much details on my work. Otherwise, I would be happy to share what I do as well.

This is my first time using Cypress MCU and mbed as well. Personally, I feel mbed has good support to run on PSoC; they have rich APIs in various features and the code is open source, so it also makes debug easier especially when I needed to look into how the APIs were implemented...

Regarding the memory map, I reviewed the linker script again, I think currently, it is only computing FLASH_CM0P_SIZE + MBED_APP_SIZE for the flash section, right?
Since MBED_RAM_START starts at 0x08002000, MBED_RAM_SIZE won't be added to the flash section, right? Or perhaps I misunderstood how the linker script works... Does the linker still add these (MBED_RAM_SIZE, FLASH_CM0P_SIZE, MBED_APP_SIZE) together and try to fit them in the flash section?

Thanks,

Dennis

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

Dennis,

"Regarding the memory map, I reviewed the linker script again, I think currently, it is only computing FLASH_CM0P_SIZE + MBED_APP_SIZE for the flash section, right? "

Your right.

Did you see this section in the doc I sent you?

CustomizingLinkerScripts.gif

I will reattach it. See it that sheds any light on you situation... In the mean time I am looking at a few things with your .ld

Just wondering, do you have both .ld's? Should be cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld that I can look at please.

William

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

Dennis,

Correct me if I wrong but you seem to be trying to add the CM0+ image in the CM4 .ld...

    /* The ram and flash regions control RAM and flash memory allocation for the CM4 core.

     * You can change the memory allocation by editing the 'ram' and 'flash' regions.

     * Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use.

     * Using this memory region for other purposes will lead to unexpected behavior.

     * Your changes must be aligned with the corresponding memory regions for CM0+ core in 'xx_cm0plus.ld',

     * where 'xx' is the device group; for example, 'cy8c6xx7_cm0plus.ld'.

     */

    ram                      (rwx)   : ORIGIN = MBED_RAM_START(0x08002000), LENGTH = MBED_RAM_SIZE(0x00045800)

    cm0p_image        (rx)     : ORIGIN = MBED_ROM_START(0x10000000), LENGTH = FLASH_CM0P_SIZE(0x2000)

    flash                    (rx)     : ORIGIN = MBED_APP_START(0x10002000), LENGTH = MBED_APP_SIZE(FE000)

William

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

Hi William,
I am so sorry that I missed that section of the document previously.
I've also studied your linker script attachment. From the attachment and the document, I think I just need to change MBED_RAM_SIZE from 0x10000 to 0x2000 for CM0+, but turned out that it didn't help resolved the overflow issue. I kept MBED_RAM_SIZE at 0x45800 for CM4 because SRAM size is 288 KB, so I didn't change it to 0xFD800. But I may be wrong, so please correct me if I misunderstood.

By the way, your understanding on my memory configuration in the previous email is correct.

Attached is my latest linker scripts for CM0+ (MBED_RAM_SIZE is at 0x10000) and CM4. If there is anything else I can look into, please do let me know as well.

Appreciate for all the help!

Dennis

0 Likes

The reason changing CM0+ to 0x2000 did not work is because it appears you have two overlaps.

CM0 ram: 0x08000000-0x08010000  flash: 0x10000000-0x10078000

CM4 ram: 0x08002000-0x08047800  flash: 0x10000000-0x100FE000

CM0 ram: 0x08000000-0x08010000  flash: 0x10000000-0x10078000

CM4 ram: 0x08010000-0x08047800  flash: 0x10078000-0x100FE000

0 Likes

dualmemconfig.gif

Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use.

0 Likes

Hi William,
The diagram really helps to visualize the map, thanks! And really appreciate for providing feedback over the break!

Initially, I thought the area is shared, so I didn't realize the overlap can be an issue... Nevertheless, now I think about it, those areas supposed to be dedicated for each core to store and run code, so overlap would not be ideal.

I tried the region you suggested, but linker complained that more bytes would overflow (before change was about 26 KB and now is about 512 KB)

Since we want to avoid overlap, the next thing I try is modifying the region to the following, but linker still thinks there is 26 KB over the flash region, so I am still quite surprised since my code size (for both cores) is not close to 1 MB at all.

CM0 ram: 0x08000000-0x08002000  flash: 0x10000000-0x10002000

CM4 ram: 0x08002000-0x08047800  flash: 0x10002000-0x100FE000


Thanks,
Dennis

0 Likes

Dennis,

Your welcome, I am more visual myself so I thought it might help.

This looks good. Yes, the CM4 and CM0 share ram and flash just to reiterate that.

CM0 ram: 0x08000000-0x08002000  flash: 0x10000000-0x10002000

CM4 ram: 0x08002000-0x08047800  flash: 0x10002000-0x100FE000

It just cant overlap!!!

You are saving the 2k reserve so thats good and we are only talking about 26 bytes.

So now at this point.

Make sure that you have no offending Makefiles, that they are matching your linkers and your math is correct.

Have you contacted mbed or looked on their forum or is this an mbed provided by Cypress?

If its provided by ARM MBed I would bring them into the fold.

Myself, I would start removing libraries until the issue went away but that is kinda drastic... Like divide and conquer...

BUT,

Since you are using the same setup I am, please send me the links to the mbed you are using.

The Cypress example you started your application with... NOT YOUR APPLICATION

I will put those two together and see what I can determine ok? Its what we do here at Cypress... Once you take an issue, you see it thru!!!

William

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

Hi William,

I really like your support from Cypress and thanks for sitting through this with me!

The overflow is about 26 KB extra. Unfortunately, this is after I attempted to to remove libraries in custom_targets.json. Since I need WiFi, BLE, SD card and QSPI memory access, I keep those features / components in there, and try to have bare minimum. I will attached it here as well in case I miss anything that can be removed.


Yeah, since my linker scripts (CM4 and CM0+) were based on mbed os repository, I have reported my issue in mbed forum few weeks ago as well, but I haven't heard back from them or anyone else reported similar issues...

My application is similar to this example​. But I am not sure if this can help determine the issue. Nevertheless, I will try to provide if you need anything else from me.

Thanks,
Dennis

0 Likes

MBED_ROM_START = 0x10000000

FLASH_CM0P_SIZE = 0x2000

MBED_APP_START = 10002000

MBED_ROM_SIZE = 0x00100000

MBED_APP_SIZE = MBED_ROM_SIZE  - FLASH_CM0P_SIZE

MBED_APP_SIZE = 0x00100000 - 0x2000 = FE000

0 Likes

According to the attached documentation:

Application Size is - 0x10000000 - 0x100FFFFF = FFFFF

Your application is size is:

MBED_RAM_SIZE = 0x00045800

+FLASH_CM0P_SIZE=0x2000

+MBED_APP_SIZE=0xFE000

                                                                             = 0x145800

Go back to it working -  save the map

Then add your wifi - save the map

It should give you some clues...

Are somehow send what you can so I can recreate your issue...

By suspision is that there is a zero to many in your make file, recheck your build files

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

oops... attached document...

0 Likes