Skip to content

Commit 43acaa4

Browse files
committed
LPC2368 [GCC_ARM]: Fixed: Compilation and link errors in case "SD" example.
1 parent b9d52bd commit 43acaa4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libraries/mbed/common/retarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,20 @@ extern "C" int __end__;
439439
#undef errno
440440
extern "C" int errno;
441441

442+
// For ARM7 only
443+
register unsigned char * stack_ptr __asm ("sp");
444+
442445
// Dynamic memory allocation related syscall.
443446
extern "C" caddr_t _sbrk(int incr) {
444447
static unsigned char* heap = (unsigned char*)&__end__;
445448
unsigned char* prev_heap = heap;
446449
unsigned char* new_heap = heap + incr;
447450

451+
#ifdef __get_MSP
448452
if (new_heap >= (unsigned char*)__get_MSP()) {
453+
#else
454+
if (new_heap >= stack_ptr) {
455+
#endif
449456
errno = ENOMEM;
450457
return (caddr_t)-1;
451458
}

libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC23XX/TOOLCHAIN_GCC_ARM/LPC2368.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ SECTIONS
143143
. = ALIGN( 8 ) ;
144144
__heap_start__ = . ;
145145
end = . ;
146+
__end__ = . ;
146147

147148
.stab 0 (NOLOAD) : { *(.stab) }
148149
.stabstr 0 (NOLOAD) : { *(.stabstr) }

0 commit comments

Comments
 (0)