Skip to content

esp32/machine_rtc: Add prefix to rtc user mem macro. #5349

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

Closed

Conversation

nevercast
Copy link
Contributor

@nevercast nevercast commented Nov 20, 2019

When working with ESP32 C modules, you may want to put symbols/data/code in to RTC memory so that you can write a deepsleep stub, or use the ULP on the ESP32. When doing so, the RTC memory region can sometimes overflow at linker time due to the allocations made within the ESP32 RTC module.

This fix allows modifying the size of that memory region in your board config to decrease the size, by adding #define MICROPY_HW_RTC_USER_MEM_MAX 512 for example, the RTC module's user memory region would be decreased from 2K to 512 bytes, giving you space for other content outside of MicroPython.

This fix both renames the macro to something more suited for configuration use and allows it to be defined outside of the RTC module.

@nevercast
Copy link
Contributor Author

nevercast commented Nov 20, 2019

Currently on one of my builds I set the user memory size to be zero. RTC.memory() still works but doesn't accept any input and always returns empty, however 8 bytes are still used for the rtc_user_mem_magic and rtc_user_mem_len vars, as well as flash being used to hold the RTC.memory() code that cannot do anything.

Perhaps if MICROPY_HW_RTC_USER_MEM_MAX is 0, we should also not compile any of the code related to RTC user memory.

@dpgeorge
Copy link
Member

This change looks ok to me.

Perhaps if MICROPY_HW_RTC_USER_MEM_MAX is 0, we should also not compile any of the code related to RTC user memory.

Yeah, I guess if the user is setting this to 0 they really want the maximum amount of RTC memory for their own use, and so would never use RTC.memory(). So makes sense to just disable all that code in such a situation.

@nevercast
Copy link
Contributor Author

I've added optional compilation for when the user memory size is zero, and I have made a couple changes regarding choice of integer sizes and their usage to decrease code & memory footprint. I've tested the functionality with MICROPY_HW_RTC_USER_MEM_MAX unset, set to zero and set to a small value, and all these cases work as expected. If you're happy with this and have no considerations I'll happily squash and force push this for you so that it is ready to land in master.

@dpgeorge
Copy link
Member

I've added optional compilation for when the user memory size is zero, and I have made a couple changes regarding choice of integer sizes and their usage to decrease code & memory footprint.

Great, looks good (except for comment above).

I'll happily squash and force push this for you so that it is ready to land in master.

It's ok, no need, I do this anyway as part of the merge process.

@nevercast
Copy link
Contributor Author

Direct access to RTC memory is a smaller code footprint. If you're satisfied then I'm happy for this to merge 💯

@dpgeorge
Copy link
Member

Ok, thanks for confirming about the len.

Squashed and merged in ed2314f and 1530fda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants