From bc741c00cc1d12ba07bf66a0fc41b80f04684266 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 23 Nov 2017 05:19:00 -0800 Subject: [PATCH] cc2538 platforms: initialize linkaddr in phase 2 but set RF params only in phase 3 --- arch/platform/cc2538dk/platform.c | 8 ++++---- arch/platform/openmote-cc2538/platform.c | 8 ++++---- arch/platform/zoul/platform.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/platform/cc2538dk/platform.c b/arch/platform/cc2538dk/platform.c index 154651c98..3a504c315 100644 --- a/arch/platform/cc2538dk/platform.c +++ b/arch/platform/cc2538dk/platform.c @@ -103,9 +103,6 @@ set_rf_params(void) short_addr = ext_addr[7]; short_addr |= ext_addr[6] << 8; - /* Populate linkaddr_node_addr. Maintain endianness */ - memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE); - NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); @@ -159,7 +156,8 @@ platform_init_stage_two() crypto_disable(); #endif - set_rf_params(); + /* Populate linkaddr_node_addr */ + ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE); INTERRUPTS_ENABLE(); @@ -171,6 +169,8 @@ platform_init_stage_three() { LOG_INFO("%s\n", BOARD_STRING); + set_rf_params(); + soc_print_info(); adc_init(); diff --git a/arch/platform/openmote-cc2538/platform.c b/arch/platform/openmote-cc2538/platform.c index 7cb583a16..584f5a292 100644 --- a/arch/platform/openmote-cc2538/platform.c +++ b/arch/platform/openmote-cc2538/platform.c @@ -111,9 +111,6 @@ set_rf_params(void) short_addr = ext_addr[7]; short_addr |= ext_addr[6] << 8; - /* Populate linkaddr_node_addr. Maintain endianness */ - memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE); - NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); @@ -157,7 +154,8 @@ platform_init_stage_two() crypto_disable(); #endif - set_rf_params(); + /* Populate linkaddr_node_addr */ + ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE); INTERRUPTS_ENABLE(); @@ -169,6 +167,8 @@ platform_init_stage_three() { LOG_INFO("%s\n", BOARD_STRING); + set_rf_params(); + board_init(); soc_print_info(); diff --git a/arch/platform/zoul/platform.c b/arch/platform/zoul/platform.c index da106a697..d428decbb 100644 --- a/arch/platform/zoul/platform.c +++ b/arch/platform/zoul/platform.c @@ -166,9 +166,6 @@ set_rf_params(void) short_addr = ext_addr[7]; short_addr |= ext_addr[6] << 8; - /* Populate linkaddr_node_addr. Maintain endianness */ - memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE); - NETSTACK_RADIO.set_value(RADIO_PARAM_PAN_ID, IEEE802154_PANID); NETSTACK_RADIO.set_value(RADIO_PARAM_16BIT_ADDR, short_addr); NETSTACK_RADIO.set_value(RADIO_PARAM_CHANNEL, CC2538_RF_CHANNEL); @@ -220,7 +217,8 @@ platform_init_stage_two() crypto_disable(); #endif - set_rf_params(); + /* Populate linkaddr_node_addr */ + ieee_addr_cpy_to(linkaddr_node_addr.u8, LINKADDR_SIZE); INTERRUPTS_ENABLE(); @@ -232,6 +230,8 @@ platform_init_stage_three() { LOG_INFO("%s\n", BOARD_STRING); + set_rf_params(); + board_init(); rtc_init();