[riot-notifications] [RIOT-OS/RIOT] cpu/atmega_common: make remaining RAM available as heap (#10934)
notifications at github.com
Sun Feb 3 18:27:58 CET 2019
### Contribution description
This PR make the remaining RAM of AVR MCUs available as heap for `malloc/free` functions of `avr-libc`.
`__malloc_heap_end` is set to 0 by default. Therefore, `malloc` checks `__brkval` against the SP instead of `__malloc_heap_end`.
cp = __malloc_heap_end;
if (cp == 0)
cp = STACK_POINTER() - __malloc_margin;
if (cp <= __brkval)
In thread mode, however, the SP is is always in `.data` section below `__bss_end` and thus below `__malloc_heap_start`. Since `__brkval` points at least to `__malloc_heap_start`, the check always fails.
This PR sets `__malloc_heap_end` to the current SP before switching to thread mode. Thus, `malloc` checks `__brkval` against `__malloc_heap_end`.
### Testing procedure
Use `tests/malloc` to check `malloc/free` functions of `avr-libc`, for example:
make -C tests/malloc BOARD=arduino-mega2560 PORT=/dev/ttyUSB0 flash
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* cpu/atmega_common: make RAM available as heap
-- File Changes --
M cpu/atmega_common/thread_arch.c (17)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications