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 .ramfunc attribute to flash_with_bootloader.ld to enable keeping functions in RAM #339

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

yosinski
Copy link

For some use cases, e.g. re-flashing the Arduino during runtime via OTA updates, it is useful to enable certain functions to be kept in RAM so that the underlying flash memory may be replaced with new firmware while the program is running. An approach to accomplishing this is to prefix function definitions with the .ramfunc attribute:

__attribute__ ((long_call, section (".ramfunc")))

However, to get this to work, we needed to add a section specifying how to handle .ramfunc to the relevant flash_with_bootloader.ld for our hardware.

Is this the correct entry point? If so, is this few line addition appropriate for inclusion in this repository? In this PR, I've only added the line to the feather_m4 variant, though it could also be added for architectures.

@drewfish
Copy link

Another possible use for this is interrupt handlers, which could also benefit from being in ram. (Also would be nice to be able to store the interrupt table itself in ram.)

Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your PR, we have no problems with adding/updaing linker file. However, have you tried and verified that this PR work as expected, e.g using binutil nm or view the symbol declared with ramfunc and verified that its address is within the SRAM section. If that works, then we are happy to merge this.

@rlcamp
Copy link

rlcamp commented Jul 12, 2024

Worth pointing out there are some places in neopixel code that need to be in RAM in order to meet their timing requirements if they are the first thing that happens upon wake from sleep. I've worked around it by adding __attribute__((section(".datafunc"))) which gets picked up by the .data* rule in the existing linker script, but this is more of a hack than a proper fix.

Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good enough

@hathach hathach merged commit ce20340 into adafruit:master Jul 18, 2024
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.

4 participants