Skip to content

Commit dfc3240

Browse files
committed
[NUC472/M453] Refine comment for two-region model
1 parent 107d633 commit dfc3240

File tree

3 files changed

+14
-7
lines changed
  • platform
  • targets
    • TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM
    • cmsis/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/TOOLCHAIN_GCC_ARM

3 files changed

+14
-7
lines changed

platform/retarget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,10 @@ register unsigned char * stack_ptr __asm ("sp");
574574

575575
// Dynamic memory allocation related syscall.
576576
#if defined(TARGET_NUMAKER_PFM_NUC472) || defined(TARGET_NUMAKER_PFM_M453)
577-
// Overwrite _sbrk() to support two region model.
577+
// Overwrite _sbrk() to support two region model (heap and stack are two distinct regions).
578+
// __wrap__sbrk() is implemented in:
579+
// TARGET_NUMAKER_PFM_NUC472 hal/targets/cmsis/TARGET_NUVOTON/TARGET_NUC472/TARGET_NUMAKER_PFM_NUC472/TOOLCHAIN_GCC_ARM/retarget.c
580+
// TARGET_NUMAKER_PFM_M453 hal/targets/cmsis/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/TOOLCHAIN_GCC_ARM/retarget.c
578581
extern "C" void *__wrap__sbrk(int incr);
579582
extern "C" caddr_t _sbrk(int incr) {
580583
return (caddr_t) __wrap__sbrk(incr);

targets/TARGET_NUVOTON/TARGET_NUC472/device/TOOLCHAIN_GCC_ARM/retarget.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
extern uint32_t __mbed_sbrk_start;
1616
extern uint32_t __mbed_krbs_start;
1717

18-
// NOTE: The implementation of _sbrk (in common/retarget.cpp) for GCC_ARM requires one-region model for heap and stack, which doesn't
19-
// meet the layout of e.g. Nu-mbed-NUC472 board where heap is located on external SRAM.
20-
// Because the symbol is not weak and cannot be overwritten, wrap calls to it by hooking command line linker with '-Wl,--wrap,_sbrk'.
18+
/**
19+
* The default implementation of _sbrk() (in common/retarget.cpp) for GCC_ARM requires one-region model (heap and stack share one region), which doesn't
20+
* fit two-region model (heap and stack are two distinct regions), for example, NUMAKER-PFM-NUC472 locates heap on external SRAM. Define __wrap__sbrk() to
21+
* override the default _sbrk(). It is expected to get called through gcc hooking mechanism ('-Wl,--wrap,_sbrk') or in _sbrk().
22+
*/
2123
void *__wrap__sbrk(int incr)
2224
{
2325
static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start;

targets/cmsis/TARGET_NUVOTON/TARGET_M451/TARGET_NUMAKER_PFM_M453/TOOLCHAIN_GCC_ARM/retarget.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
extern uint32_t __mbed_sbrk_start;
1616
extern uint32_t __mbed_krbs_start;
1717

18-
// NOTE: The implementation of _sbrk (in common/retarget.cpp) for GCC_ARM requires one-region model for heap and stack, which doesn't
19-
// meet the layout of e.g. Nu-mbed-NUC472 board where heap is located on external SRAM.
20-
// Because the symbol is not weak and cannot be overwritten, wrap calls to it by hooking command line linker with '-Wl,--wrap,_sbrk'.
18+
/**
19+
* The default implementation of _sbrk() (in common/retarget.cpp) for GCC_ARM requires one-region model (heap and stack share one region), which doesn't
20+
* fit two-region model (heap and stack are two distinct regions), for example, NUMAKER-PFM-NUC472 locates heap on external SRAM. Define __wrap__sbrk() to
21+
* override the default _sbrk(). It is expected to get called through gcc hooking mechanism ('-Wl,--wrap,_sbrk') or in _sbrk().
22+
*/
2123
void *__wrap__sbrk(int incr)
2224
{
2325
static uint32_t heap_ind = (uint32_t) &__mbed_sbrk_start;

0 commit comments

Comments
 (0)