From 8fd7719c073b8c6ec4c7fdd178b266bb8e327064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Thu, 23 Jun 2016 22:10:43 +0200 Subject: [PATCH 1/2] noncoresec: Fix build errors with DEBUG set to 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix these build errors, which are generated if DEBUG is set to 1: ../../core/net/llsec/noncoresec/noncoresec.c: In function 'parse': ../../core/net/llsec/noncoresec/noncoresec.c:198:54: error: expected ')' before 'PRIu32' PRINTF("noncoresec: received unauthentic frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ ../../core/net/llsec/noncoresec/noncoresec.c:198:12: warning: spurious trailing '%' in format [-Wformat=] PRINTF("noncoresec: received unauthentic frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ ../../core/net/llsec/noncoresec/noncoresec.c:198:12: warning: spurious trailing '%' in format [-Wformat=] PRINTF("noncoresec: received unauthentic frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ ../../core/net/llsec/noncoresec/noncoresec.c:231:54: error: expected ')' before 'PRIu32' PRINTF("noncoresec: received replayed frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ ../../core/net/llsec/noncoresec/noncoresec.c:231:15: warning: spurious trailing '%' in format [-Wformat=] PRINTF("noncoresec: received replayed frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ ../../core/net/llsec/noncoresec/noncoresec.c:231:15: warning: spurious trailing '%' in format [-Wformat=] PRINTF("noncoresec: received replayed frame %"PRIu32"\n", ^ ../../core/net/llsec/noncoresec/noncoresec.c:88:28: note: in definition of macro 'PRINTF' #define PRINTF(...) printf(__VA_ARGS__) ^ PRIu32 is not defined, so replace it with a standard format directive. Signed-off-by: Benoît Thébaudeau --- core/net/llsec/noncoresec/noncoresec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/net/llsec/noncoresec/noncoresec.c b/core/net/llsec/noncoresec/noncoresec.c index 71a1cb82a..f9d442651 100644 --- a/core/net/llsec/noncoresec/noncoresec.c +++ b/core/net/llsec/noncoresec/noncoresec.c @@ -195,7 +195,7 @@ parse(void) packetbuf_set_datalen(packetbuf_datalen() - MIC_LEN); if(!aead(result, 0)) { - PRINTF("noncoresec: received unauthentic frame %"PRIu32"\n", + PRINTF("noncoresec: received unauthentic frame %lu\n", anti_replay_get_counter()); return FRAMER_FAILED; } @@ -228,7 +228,7 @@ parse(void) anti_replay_init_info(info); } else { if(anti_replay_was_replayed(info)) { - PRINTF("noncoresec: received replayed frame %"PRIu32"\n", + PRINTF("noncoresec: received replayed frame %lu\n", anti_replay_get_counter()); return FRAMER_FAILED; } From 1da00a482fe91e4e4af2324202439a799cc02f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Thu, 23 Jun 2016 22:25:27 +0200 Subject: [PATCH 2/2] cc2538: aes: Fix possibly missing result available status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Depending on the use case and on the timings, aes_auth_crypt_check_status() sometimes never reported an available result, leading to a deadlock of any protothread waiting for this event, and to a WDT reset if a protothread was polling it. This was caused by aes_auth_crypt_start() clearing the result available interrupt after operations that may rightfully trigger it, leading to a missed interrupt. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/dev/aes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cpu/cc2538/dev/aes.c b/cpu/cc2538/dev/aes.c index 429def67b..2b9e11a17 100644 --- a/cpu/cc2538/dev/aes.c +++ b/cpu/cc2538/dev/aes.c @@ -226,12 +226,14 @@ aes_auth_crypt_start(uint32_t ctrl, uint8_t key_area, const void *iv, REG(AES_CTRL_ALG_SEL) = 0x00000000; return CRYPTO_DMA_BUS_ERROR; } + + /* Clear interrupt status */ + REG(AES_CTRL_INT_CLR) = AES_CTRL_INT_CLR_DMA_IN_DONE; } } - /* Clear interrupt status */ - REG(AES_CTRL_INT_CLR) = AES_CTRL_INT_CLR_DMA_IN_DONE | - AES_CTRL_INT_CLR_RESULT_AV; + /* Enable result available bit in interrupt enable */ + REG(AES_CTRL_INT_EN) = AES_CTRL_INT_EN_RESULT_AV; if(process != NULL) { crypto_register_process_notification(process); @@ -239,9 +241,6 @@ aes_auth_crypt_start(uint32_t ctrl, uint8_t key_area, const void *iv, nvic_interrupt_enable(NVIC_INT_AES); } - /* Enable result available bit in interrupt enable */ - REG(AES_CTRL_INT_EN) = AES_CTRL_INT_EN_RESULT_AV; - if(data_len != 0) { /* Configure DMAC * Enable DMA channel 0 */