From 5910cadb58c89b57f4d871239c9af787ed0a200e Mon Sep 17 00:00:00 2001 From: Lucas Jenss Date: Fri, 27 Mar 2015 18:34:10 +0100 Subject: [PATCH] sys/net: Fix unaligned access on Samr21/Cortex-M0 *((uint16_t)*dest) results in a ldrh (load halfword) instruction on an address that seems to not be halfword-aligned (?), causing a hard-fault on the samr21-xpro board (cortex-m0 architecture). The issue seems to be very similar to the one described in http://stackoverflow.com/a/21661366/124257 --- sys/net/network_layer/sixlowpan/lowpan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/net/network_layer/sixlowpan/lowpan.c b/sys/net/network_layer/sixlowpan/lowpan.c index 7c58866872..8ef6d943e8 100644 --- a/sys/net/network_layer/sixlowpan/lowpan.c +++ b/sys/net/network_layer/sixlowpan/lowpan.c @@ -1107,7 +1107,8 @@ uint8_t lowpan_iphc_encoding(int if_id, const uint8_t *dest, int dest_len, else if (ipv6_buf->destaddr.uint32[2] == HTONL(0x000000ff) && ipv6_buf->destaddr.uint16[6] == HTONS(0xfe00)) { if (dest_len == 2 && - ipv6_buf->destaddr.uint16[7] == *((uint16_t *) dest)) { + ipv6_buf->destaddr.uint8[14] == dest[0] && + ipv6_buf->destaddr.uint8[15] == dest[1]) { /* 0 bits. The address is derived using context information * and possibly the link-layer addresses.*/ lowpan_iphc[1] |= 0x03;