4 Replies Latest reply on May 9, 2019 2:12 AM by DheerajK_81

    Limit App Size via PSOC creator


      I want to set an upper limit size for my application.

      In case application takes more space than my set value, PSOC will not allow compilation of the code.


      Where can I set this limit?

        • 1. Re: Limit App Size via PSOC creator

          You have an interesting question.  I could not find a menu/command that could be used with Creator to limit app memory size.  But, maybe there is a way to work around this.


          Let's say FLASH memory is 32k and you want to limit app size to 2k.  You could #include a dummy data file that contains 30k bytes of data.  When the project is built, maybe Creator will complain when app size + dummy data exceeds 32k.  This would be the indication the app has exceeded its 2k size limit.


          I'm guessing, the dummy data file would be placed in the same folder as main.c.  I've never tried this.


          Not a great answer to your question, but maybe this would result in the same outcome.



          • 2. Re: Limit App Size via PSOC creator

            Hi Bill,


            I work with Dima.

            Thank you for your kind response.

            It is an interesting solution but it does not answer our requirement.

            We need to have an empty section in the flash. So by filling it with a dummy data file, it does not meet our needs.




            • 3. Re: Limit App Size via PSOC creator

              BTW, the dummy file could be all FF's, which leaves the FLASH available for programming from an app.

              Instead of a dummy file, an array of constants ($ff) would also work.


              Creator outputs a line of text to indicate memory usage for both code and data spaces after it builds a load.  Maybe you can build a script to detect/interpret this text.  This text is stored in a log file.


              I've still not come up with a good answer for using Creator to do the work of limiting project memory space.  If you want to dig deeper, you can control the compile/build process from command scripts.

              See Building a PSoC® Creator™ Project from the Command Prompt – KBA88169

              There's also a thread about this:

              External build command, PSoC Creator 3



              I forgot to mention, the dummy data file is only used to get a warning from Creator when project exceeds available FLASH size.  For the final Build, delete the #include and FLASH space is restored for whatever future programming is needed.




              • 4. Re: Limit App Size via PSOC creator

                You can edit the memory regions in the linker script. For the GNU linker, it is the MEMORY command in the .ld file. Once you have defined a region of memory named mem, you can direct specific output sections there by using a command ending in `>mem' within the SECTIONS command. If the memory overflows the linker will throw an error. There is no setting to stop allowing compilation of code though.