Skip to content

Commit

Permalink
Merge pull request #759 from jimparis/aducrf101-fix-stack
Browse files Browse the repository at this point in the history
ADuCRF101: Fix stack/heap overflow
  • Loading branch information
malvira committed Jul 30, 2014
2 parents 62b8aaf + 9b76c2f commit 17f54ad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
7 changes: 5 additions & 2 deletions cpu/arm/aducrf101/Common/GCC/ADuCRF101.ld
Expand Up @@ -91,15 +91,18 @@ SECTIONS
} > ram AT > flash

.bss : {
/* Stack is in BSS */
. = ALIGN(8);
__bss_start = .;
*(.bss.stack)
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
__bss_end = .;
end = .;
} > ram

/* Heap grows up from "end" (after bss), and stack grows down from
the end of RAM. */
. = ORIGIN(ram) + LENGTH(ram);
stack_end = .;
}
11 changes: 0 additions & 11 deletions cpu/arm/aducrf101/Common/GCC/crt0.S
Expand Up @@ -32,19 +32,8 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __STACK_SIZE
#define __STACK_SIZE 1024
#endif

.equ SCB_VTOR, 0xE000ED08

/* Stack */
.section .bss.stack
stack_start:
.space __STACK_SIZE, 0
stack_end:
.global stack_end

/* Vector table */
.macro handler name
.long \name\()
Expand Down
16 changes: 16 additions & 0 deletions cpu/arm/aducrf101/clock.c
Expand Up @@ -43,9 +43,25 @@ static volatile clock_time_t current_clock = 0;
static volatile unsigned long current_seconds = 0;
static unsigned int second_countdown = CLOCK_SECOND;

#define SAMPLE_STACK_POINTER
#ifdef SAMPLE_STACK_POINTER
volatile uint32_t *__min_sampled_sp = (uint32_t *)0xFFFFFFFF;
#endif

void
SysTick_Handler(void)
{
#ifdef SAMPLE_STACK_POINTER
/* Take note of the lowest stack pointer we ever saw.
When compiling against newlib, the total free bytes of
RAM not ever used by heap or stack can be found via GDB:
(gdb) p (char *)__min_sampled_sp - (char *)_sbrk(0)
*/
uint32_t *sp = (uint32_t *)&sp;
if (sp < __min_sampled_sp)
__min_sampled_sp = sp;
#endif

current_clock++;
if(etimer_pending()) {
etimer_request_poll();
Expand Down
12 changes: 6 additions & 6 deletions platform/ev-aducrf101mkxz/contiki-conf.h
Expand Up @@ -89,11 +89,11 @@
#define XMAC_CONF_COMPOWER 0
#define CXMAC_CONF_COMPOWER 0

#define COLLECT_NBR_TABLE_CONF_MAX_NEIGHBORS 32
#define COLLECT_NBR_TABLE_CONF_MAX_NEIGHBORS 16

#endif /* WITH_UIP6 */

#define QUEUEBUF_CONF_NUM 16
#define QUEUEBUF_CONF_NUM 4

#define PACKETBUF_CONF_ATTRS_INLINE 1

Expand All @@ -109,7 +109,7 @@
#define ENERGEST_CONF_ON 0

#define AODV_COMPLIANCE
#define AODV_NUM_RT_ENTRIES 32
#define AODV_NUM_RT_ENTRIES 16

#define WITH_ASCII 1

Expand All @@ -131,8 +131,8 @@
#define UIP_CONF_IPV6_RPL 1
#endif

#define NBR_TABLE_CONF_MAX_NEIGHBORS 30
#define UIP_CONF_MAX_ROUTES 30
#define NBR_TABLE_CONF_MAX_NEIGHBORS 16
#define UIP_CONF_MAX_ROUTES 16

#define UIP_CONF_ND6_SEND_RA 0
#define UIP_CONF_ND6_REACHABLE_TIME 600000
Expand All @@ -146,7 +146,7 @@
#define UIP_CONF_ND6_MAX_PREFIXES 3
#define UIP_CONF_ND6_MAX_DEFROUTERS 2
#define UIP_CONF_IP_FORWARD 0
#define UIP_CONF_BUFFER_SIZE 140
#define UIP_CONF_BUFFER_SIZE 240
#define SICSLOWPAN_CONF_FRAG 1
#define SICSLOWPAN_CONF_MAXAGE 8

Expand Down

0 comments on commit 17f54ad

Please sign in to comment.