From 43db4fd10e8cb516aeff8922aef21f5da94574d4 Mon Sep 17 00:00:00 2001 From: "Enric M. Calvo" Date: Fri, 25 Feb 2011 14:34:52 +0100 Subject: [PATCH] Added MAC overwriting/burning capability to the Z1 Added compilation parameter "nodemac=1234" that can be used to overwrite the MAC at compilation time, and that combined with the burn-nodeid app can record a prestablished MAC on ext. mem. --- platform/z1/Makefile.z1 | 4 ++++ platform/z1/apps/burn-nodeid.c | 1 + platform/z1/contiki-z1-main.c | 33 +++++++++++++++------------------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/platform/z1/Makefile.z1 b/platform/z1/Makefile.z1 index a470e2516..36f5de5b0 100644 --- a/platform/z1/Makefile.z1 +++ b/platform/z1/Makefile.z1 @@ -18,6 +18,10 @@ ifdef UIP_CONF_IPV6 CFLAGS += -DWITH_UIP6=1 endif +ifdef nodemac +CFLAGS += -DMACID=$(nodemac) +endif + CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN) MCU=msp430x2617 diff --git a/platform/z1/apps/burn-nodeid.c b/platform/z1/apps/burn-nodeid.c index 67b4db805..6f8d9345c 100644 --- a/platform/z1/apps/burn-nodeid.c +++ b/platform/z1/apps/burn-nodeid.c @@ -61,6 +61,7 @@ PROCESS_THREAD(burn_process, ev, data) watchdog_stop(); leds_on(LEDS_RED); #if NODEID + #warning "***** BURNING NODE ID" printf("Burning node id %d\n", NODEID); node_id_burn(NODEID); leds_on(LEDS_BLUE); diff --git a/platform/z1/contiki-z1-main.c b/platform/z1/contiki-z1-main.c index 2ddfa4985..a1a1d88b4 100644 --- a/platform/z1/contiki-z1-main.c +++ b/platform/z1/contiki-z1-main.c @@ -208,20 +208,7 @@ main(int argc, char **argv) slip_arch_init(BAUD2UBR(115200)); #endif /* WITH_UIP */ - /* XXX hack: Fix it so that the 802.15.4 MAC address is compatible - with an Ethernet MAC address - byte 0 (byte 2 in the DS ID) - cannot be odd. */ - //Enric node_mac[2] &= 0xfe; - node_mac[0] = 0x00; - node_mac[1] = 0x12; - node_mac[2] = 0x76; - node_mac[3] = 0x01; - node_mac[4] = 0x02; - node_mac[5] = 0x03; - node_mac[2] = 0x04; - node_mac[7] = 0x05; - - + xmem_init(); rtimer_init(); @@ -229,10 +216,23 @@ main(int argc, char **argv) * Hardware initialization done! */ - /* Restore node id if such has been stored in external mem */ node_id_restore(); + /* Overwrite node MAC if desired at compile time */ +#ifdef MACID + #warning "***** CHANGING DEFAULT MAC *****" + node_mac[0] = 0xC1; // Hardcoded for Z1 + node_mac[1] = 0x0C; // Hardcoded for Revision C + node_mac[2] = 0x00; // Hardcoded to arbitrary even number so that the 802.15.4 MAC address + // is compatible with an Ethernet MAC address - byte 0 (byte 2 in the DS ID) + node_mac[3] = 0x00; // Hardcoded + node_mac[4] = 0x00; // Hardcoded + node_mac[5] = 0x00; // Hardcoded + node_mac[6] = MACID >> 8; + node_mac[7] = MACID & 0xff; +#endif + /* for setting "hardcoded" IEEE 802.15.4 MAC addresses */ #ifdef IEEE_802154_MAC_ADDRESS @@ -284,9 +284,6 @@ main(int argc, char **argv) PRINTF("Node id is not set.\n"); } - //Enric printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - //Enric node_mac[0], node_mac[1], node_mac[2], node_mac[3], - //Enric node_mac[4], node_mac[5], node_mac[6], node_mac[7]); #if WITH_UIP6 PRINTF("in WITH_UIP6\n"); //Enric