DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Tracking Bugs Made Easy With React.js Bug Tracking Tools
  • The Essentials of Amazon S3 Glacier for Affordable and Compliant Long-Term Data Archiving
  • Seamless Feature Release Without Deployment Using IBM Cloud AppConfiguration: An Alternative to LaunchDarkly
  • Microservices With Apache Camel and Quarkus (Part 4)

Trending

  • How to Submit a Post to DZone
  • Spring Authentication With MetaMask
  • Automated Testing Lifecycle
  • Automated Testing: The Missing Piece of Your CI/CD Puzzle

Changing Heap and Stack Size for NXP Kinetis SDK v2.0 GCC Projects

With no Processor Expert available, configuring linking behavior for NXP Kinetis SDK 2.0 requires getting a little deeper into settings and command line options.

Erich Styger user avatar by
Erich Styger
·
Apr. 24, 16 · Tutorial
Like (2)
Save
Tweet
Share
4.14K Views

Join the DZone community and get the full member experience.

Join For Free

With Processor Expert projects it is very easy to change the heap and stack size: There is a setting for this in the CPU component settings, under the ‘Build options’ tab:

Heap and Stack Size with Processor Expert

Heap and Stack Size with Processor Expert

As there is no Processor Expert in the NXP Kinetis SDK V2.0 (see “First NXP Kinetis SDK Release: SDK V2.0 with Online On-Demand Package Builder“), how to do the same in a SDK V2.0 project?

GNU Linker File

The Kinetis SDK approach is to have some optional settings in the source files which are used in the linker (.ld) file. Open the linker file, and there should be something like this:

Linker File

Linker File

With:

HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x100;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;

So if in the project settings there is a symbol __heap_size__ or __stack_size__ defined, then it will use these values. If not, it uses the default value (0x100 or 0x400 in above example).

Linker Map File

If I want to check what is actually used, I can check the linker map file (.map, usually located in the output (debug) folder):

Heap and Stack Size used in Linker Map File

Heap and Stack Size used in Linker Map File

In the above example I can see that 0x100 for the heap and 0x400 for the stack is used.

Defining Linker Symbols

So how do we define the linker symbols?

I can use the following linker option (see “Overwriting Symbols in the GNU Linker File“) for example to specify the heap size:

-Xlinker -defsym=__heap_size__=0x600

So I can add the following to adjust the stack and heap size:

-Xlinker -defsym=__heap_size__=0x1000 -Xlinker -defsym=__stack_size__=0x100
Custom Linker Settings

Custom Linker Settings

Checking now the .map shows that the value is taken into account:

Custom heap and stack size

Custom heap and stack size

And that the new size is indeed used:

Linker Heap and Stack Size

Linker Heap and Stack Size

Summary

With the linker files used in the NXP Kinetis SDK V2.0 project, I can use this linker command line option:

-defsym

This will overwrite symbols in the linker script, for example to configure the heap and stack size. That way I can keep the same linker file for multiple projects, and the command line to the linker is used for custom settings.

Happy stacking and heaping!

Software development kit GNU Compiler Collection

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Tracking Bugs Made Easy With React.js Bug Tracking Tools
  • The Essentials of Amazon S3 Glacier for Affordable and Compliant Long-Term Data Archiving
  • Seamless Feature Release Without Deployment Using IBM Cloud AppConfiguration: An Alternative to LaunchDarkly
  • Microservices With Apache Camel and Quarkus (Part 4)

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: