Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler definition to get board RAM size #55

Open
wants to merge 1 commit into
base: release-1.1-dev
Choose a base branch
from

Conversation

eigendude
Copy link

Description

This PR adds the compiler definition ARDUINO_BOARD_RAM_SIZE, and sets it to the memory size of board being flashed. As a result, firmware code can refer to the expected total memory size when reporting memory usage percentages.

How has this been tested?

At the top of my memory utils header, I have:

#if !defined(ARDUINO_BOARD_RAM_SIZE)
#error "ARDUINO_BOARD_RAM_SIZE should have been defined by the build system"
#endif

When compiled with this patch, the build succeeds.

I also have the following function:

size_t GetTotalRAM()
{
  return ARDUINO_BOARD_RAM_SIZE;
}

I've tested on the following boards:

  • Arduino Uno - correctly returns 2048 bytes
  • Arduino Leonardo - correctly returns 2560 bytes

@eigendude eigendude changed the title Add compiler definition for RAM size Add compiler definition for board RAM size Mar 4, 2022
@eigendude eigendude changed the title Add compiler definition for board RAM size Add compiler definition to get board RAM size Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant