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

cpu/stm32: add unused backup RAM as extra heap #18921

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 16, 2022

Contribution description

Testing procedure

Run tests/malloc on a supported CPU

2022-11-16 13:25:06,756 # Allocated 128 Bytes at 0x0x20001c58, total 128
2022-11-16 13:25:06,757 # Allocated 128 Bytes at 0x0x20001cf0, total 264
2022-11-16 13:25:06,757 # Allocated 128 Bytes at 0x0x20001d88, total 400
2022-11-16 13:25:06,758 # Allocated 128 Bytes at 0x0x20001e20, total 536
2022-11-16 13:25:06,759 # Allocated 128 Bytes at 0x0x20001eb8, total 672
…
2022-11-16 13:25:07,614 # Allocated 128 Bytes at 0x0x2002fef8, total 169312
2022-11-16 13:25:07,615 # Allocated 128 Bytes at 0x0x40024008, total 169448
2022-11-16 13:25:07,615 # Allocated 128 Bytes at 0x0x40024090, total 169584
2022-11-16 13:25:07,616 # Allocated 128 Bytes at 0x0x40024118, total 169720
2022-11-16 13:25:07,616 # Allocated 128 Bytes at 0x0x400241a0, total 169856
…
2022-11-16 13:25:07,630 # Allocated 128 Bytes at 0x0x40024dd8, total 172712
2022-11-16 13:25:07,631 # Allocated 128 Bytes at 0x0x40024e70, total 172848
2022-11-16 13:25:07,632 # Allocated 128 Bytes at 0x0x40024f08, total 172984
2022-11-16 13:25:07,632 # Allocations count: 1272

Issues/PRs references

No longer crashes thanks to #18919

@fabian18
Copy link
Contributor

fabian18 commented Nov 16, 2022

Should be similar as in cfd0ef4 I guess.

So if NUM_HEAPS is 2, it is going to set up _sheap1 to _eheap1 in syscalls.c as an extra heap. In cortexm_base.ld, _sheap1 to _eheap1 are the ranges of bkup_ram. So I guess this is already right.

If someone uses backup RAM, he or she would have to #define NUM_HEAPS 1, to keep the backup RAM content?

@benpicco
Copy link
Contributor Author

If someone uses backup RAM, he or she would have to #define NUM_HEAPS 1, to keep the backup RAM content?

No need for that, this comes after the .backup.data and .backup.bss sections, so it will use whatever RAM is left after that.

@fabian18
Copy link
Contributor

it will use whatever RAM is left after that

ah true I see ... great!
I am going to run the malloc test real quick.

Copy link
Contributor

@fabian18 fabian18 left a comment

Choose a reason for hiding this comment

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

It allocates heap memory in the backup RAM region:

022-11-16 14:34:33,134 # Free 128 Bytes at 0x0x40024008, total 3544
2022-11-16 14:34:33,137 # Free 128 Bytes at 0x0x40024090, total 3408
2022-11-16 14:34:33,142 # Free 128 Bytes at 0x0x40024128, total 3272
2022-11-16 14:34:33,145 # Free 128 Bytes at 0x0x400241c0, total 3136
2022-11-16 14:34:33,149 # Free 128 Bytes at 0x0x40024258, total 3000
2022-11-16 14:34:33,154 # Free 128 Bytes at 0x0x400242f0, total 2864
2022-11-16 14:34:33,156 # Free 128 Bytes at 0x0x40024388, total 2728
2022-11-16 14:34:33,159 # Free 128 Bytes at 0x0x40024420, total 2592
2022-11-16 14:34:33,164 # Free 128 Bytes at 0x0x400244b8, total 2456
2022-11-16 14:34:33,167 # Free 128 Bytes at 0x0x40024550, total 2320
2022-11-16 14:34:33,171 # Free 128 Bytes at 0x0x400245e8, total 2184
2022-11-16 14:34:33,174 # Free 128 Bytes at 0x0x40024680, total 2048
2022-11-16 14:34:33,179 # Free 128 Bytes at 0x0x40024718, total 1912
2022-11-16 14:34:33,182 # Free 128 Bytes at 0x0x400247b0, total 1776
2022-11-16 14:34:33,186 # Free 128 Bytes at 0x0x40024848, total 1640
2022-11-16 14:34:33,190 # Free 128 Bytes at 0x0x400248e0, total 1504
2022-11-16 14:34:33,193 # Free 128 Bytes at 0x0x40024978, total 1368
2022-11-16 14:34:33,198 # Free 128 Bytes at 0x0x40024a10, total 1232
2022-11-16 14:34:33,203 # Free 128 Bytes at 0x0x40024aa8, total 1096
2022-11-16 14:34:33,206 # Free 128 Bytes at 0x0x40024b40, total 960
2022-11-16 14:34:33,208 # Free 128 Bytes at 0x0x40024bd8, total 824
2022-11-16 14:34:33,212 # Free 128 Bytes at 0x0x40024c70, total 688
2022-11-16 14:34:33,218 # Free 128 Bytes at 0x0x40024d08, total 552
2022-11-16 14:34:33,222 # Free 128 Bytes at 0x0x40024da0, total 416
2022-11-16 14:34:33,223 # Free 128 Bytes at 0x0x40024e38, total 280
2022-11-16 14:34:33,226 # Free 128 Bytes at 0x0x40024ed0, total 144
2022-11-16 14:34:33,230 # Free 128 Bytes at 0x0x40024f68, total 8

while the counter in tests/periph_backup_ram is still retained.

2022-11-16 14:39:33,427 # WARNING: non-backup memory retained - did we really enter deep sleep?
2022-11-16 14:39:33,429 # counter: 4131
2022-11-16 14:39:37,184 # WARNING: non-backup memory retained - did we really enter deep sleep?
2022-11-16 14:39:37,186 # counter: 4132
2022-11-16 14:39:41,128 # WARNING: non-backup memory retained - did we really enter deep sleep?
2022-11-16 14:39:41,130 # counter: 4133

ACK

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 16, 2022
@riot-ci
Copy link

riot-ci commented Nov 16, 2022

Murdock results

✔️ PASSED

6f05dac cpu/stm32: add unused backup RAM as extra heap

Success Failures Total Runtime
117848 0 117848 02h:29m:29s

Artifacts

@benpicco benpicco added Area: BLE Area: Bluetooth Low Energy support and removed Area: BLE Area: Bluetooth Low Energy support labels Nov 18, 2022
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Nov 18, 2022
@benpicco benpicco merged commit 2f12276 into RIOT-OS:master Nov 18, 2022
@benpicco benpicco deleted the cpu/stm32-bkup_heap branch November 18, 2022 14:48
@kaspar030 kaspar030 added this to the Release 2023.01 milestone Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants