added check_stack() to determine stack usage with Contiki

tinydtls uses some stack space for HMAC calculations etc. This may
cause trouble on platforms where the stack is very small. For example,
the platform mbxxx (using an STM32 CPU) has reserved 1280 bytes for
this. During tests, I found that this is too limited for a complete
handshake. check_stack() shows that around 2 KiB should work.
This commit is contained in:
Olaf Bergmann 2014-07-16 14:08:33 +02:00
parent 28e9d62da8
commit 014c0a4978
2 changed files with 21 additions and 1 deletions

21
debug.h
View File

@ -37,8 +37,27 @@
# define DEBUG DEBUG_PRINT
# endif /* DEBUG */
#include "net/ip/uip-debug.h"
#else
#ifdef CONTIKI_TARGET_MBXXX
extern char __Stack_Init, _estack;
static inline void check_stack() {
const char *p = &__Stack_Init;
while (p < &_estack && *p == 0x38) {
p++;
}
PRINTF("Stack: %d bytes used (%d free)\n", &_estack - p, p - &__Stack_Init);
}
#else /* CONTIKI_TARGET_MBXXX */
static inline void check_stack() {
}
#endif /* CONTIKI_TARGET_MBXXX */
#else /* WITH_CONTKI */
#define PRINTF(...)
static inline void check_stack() {
}
#endif
struct __session_t;

1
dtls.c
View File

@ -3135,6 +3135,7 @@ handle_handshake_msg(dtls_context_t *ctx, dtls_peer_t *peer, session_t *session,
dtls_handshake_free(peer->handshake_params);
peer->handshake_params = NULL;
dtls_debug("Handshake complete\n");
check_stack();
peer->state = DTLS_STATE_CONNECTED;
/* return here to not increase the message receive counter */