[riot-notifications] [RIOT-OS/RIOT] cpu/msp430_common: set top of heap for sbrk (#10943)
notifications at github.com
Tue Feb 5 10:45:43 CET 2019
### Contribution description
MSP430 uses the module 'oneway_malloc' to provide the `malloc` function. The implemented `sbrk` function always checks whether the current break value ` cur_break` is less than the SP. However, since `cur_break` starts above the` .bss` section while SP in thread mode is always in thread stacks in `.bss` section, this check always fails and `malloc` does not work.
This PR fixes this problem by setting a variable `__heap_end` in the `startup` function to the current position of SP immediately before entering the thread mode. `sbrk` then checks `cur_break` value against this `__heap_end` variable.
The changes of this PR require 10 additional bytes of ROM and 2 additional bytes of RAM.
### Testing procedure
Use `tests/malloc` with the current master and the changes in this PR to verify the differences, for example:
make -C tests/malloc BOARD=wsn430-v1_3b flash test
With current master, `tests/malloc` doesn't work at all and gives no output. With the changes in this PR, `malloc` function works. `free` always fails since it is not implemented in `oneway_malloc`.
### Issues/PRs references
This PR is prerequisite for PR.
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* cpu/msp430_common: set top of heap for sbrk
-- File Changes --
M cpu/msp430_common/msp430-main.c (13)
M cpu/msp430_common/startup.c (7)
-- 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