Hi David,
Thanks for the quick responce!
For starters I downloaded Atmel_ATECC508_Demos.zip and am debugging/building for the samd21 with Atmel Studio 7. My hardware setup is as follows:
SAMD21XPLAINED PRO
WINC1500 XPRO
CRYPTOAUTH XPRO
I defined DEBUG_WOLFSSL in user_settings.h and called wolfSSL_Debugging_ON() at the very beginning of both tls_start_server and tls_start_client. Unfortunately the resulting log outputs were identical. You mentioned the importance of placing this function before wolfSSL_init() and i'm starting to think that might be related to the hardfault.
I spent some time debugging the project and found that breakpoints set in wolfSSL_init() never triggered before the hardfault. The hardfault address evaluated to atGetExecTime() at the evaluation of cacmd->execution_times[cmd]. I set breakpoint and found that the first call to this function is evaluating a NULL ATCACommand, resulting in the hardfault. This is the (formated) call stack at that moment:
> client.elf! atGetExecTime() atca_command.c:630
client.elf! atcab_read_zone() atca_basic.c:1100
client.elf! atcacert_read_cert() atcacert_client.c:87
client.elf! tls_build_signer_ca_cert() tls_common.c:578
client.elf! tls_start_client() tls_client.c:411
client.elf! main() Line: 193
It seems that the function is passed _gCommandObj which has yet to be initialized to a valid pointer. This seems to occurs in atcab_init() or atcab_init_device(). As far as I can tell neither of these functions are called until later in tls_start_*, within tls_load_wolfssl_objects(), which calls wolfSSL_Init().
Hopefully this debug info is helpful. It seems like I'm missing something, but after debugging for a while I still can't figure out what. If you have any other suggestions let me know.