Merge pull request #759 from jimparis/aducrf101-fix-stack

ADuCRF101: Fix stack/heap overflow
This commit is contained in:
Mariano Alvira 2014-07-30 12:18:08 -05:00
commit 17f54ad562
4 changed files with 27 additions and 19 deletions

View file

@ -91,10 +91,8 @@ SECTIONS
} > ram AT > flash } > ram AT > flash
.bss : { .bss : {
/* Stack is in BSS */
. = ALIGN(8); . = ALIGN(8);
__bss_start = .; __bss_start = .;
*(.bss.stack)
*(.bss) *(.bss)
*(.bss.*) *(.bss.*)
*(COMMON) *(COMMON)
@ -102,4 +100,9 @@ SECTIONS
__bss_end = .; __bss_end = .;
end = .; end = .;
} > ram } > ram
/* Heap grows up from "end" (after bss), and stack grows down from
the end of RAM. */
. = ORIGIN(ram) + LENGTH(ram);
stack_end = .;
} }

View file

@ -32,19 +32,8 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __STACK_SIZE
#define __STACK_SIZE 1024
#endif
.equ SCB_VTOR, 0xE000ED08 .equ SCB_VTOR, 0xE000ED08
/* Stack */
.section .bss.stack
stack_start:
.space __STACK_SIZE, 0
stack_end:
.global stack_end
/* Vector table */ /* Vector table */
.macro handler name .macro handler name
.long \name\() .long \name\()

View file

@ -43,9 +43,25 @@ static volatile clock_time_t current_clock = 0;
static volatile unsigned long current_seconds = 0; static volatile unsigned long current_seconds = 0;
static unsigned int second_countdown = CLOCK_SECOND; 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 void
SysTick_Handler(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++; current_clock++;
if(etimer_pending()) { if(etimer_pending()) {
etimer_request_poll(); etimer_request_poll();

View file

@ -89,11 +89,11 @@
#define XMAC_CONF_COMPOWER 0 #define XMAC_CONF_COMPOWER 0
#define CXMAC_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 */ #endif /* WITH_UIP6 */
#define QUEUEBUF_CONF_NUM 16 #define QUEUEBUF_CONF_NUM 4
#define PACKETBUF_CONF_ATTRS_INLINE 1 #define PACKETBUF_CONF_ATTRS_INLINE 1
@ -109,7 +109,7 @@
#define ENERGEST_CONF_ON 0 #define ENERGEST_CONF_ON 0
#define AODV_COMPLIANCE #define AODV_COMPLIANCE
#define AODV_NUM_RT_ENTRIES 32 #define AODV_NUM_RT_ENTRIES 16
#define WITH_ASCII 1 #define WITH_ASCII 1
@ -131,8 +131,8 @@
#define UIP_CONF_IPV6_RPL 1 #define UIP_CONF_IPV6_RPL 1
#endif #endif
#define NBR_TABLE_CONF_MAX_NEIGHBORS 30 #define NBR_TABLE_CONF_MAX_NEIGHBORS 16
#define UIP_CONF_MAX_ROUTES 30 #define UIP_CONF_MAX_ROUTES 16
#define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_SEND_RA 0
#define UIP_CONF_ND6_REACHABLE_TIME 600000 #define UIP_CONF_ND6_REACHABLE_TIME 600000
@ -146,7 +146,7 @@
#define UIP_CONF_ND6_MAX_PREFIXES 3 #define UIP_CONF_ND6_MAX_PREFIXES 3
#define UIP_CONF_ND6_MAX_DEFROUTERS 2 #define UIP_CONF_ND6_MAX_DEFROUTERS 2
#define UIP_CONF_IP_FORWARD 0 #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_FRAG 1
#define SICSLOWPAN_CONF_MAXAGE 8 #define SICSLOWPAN_CONF_MAXAGE 8