int hw_net_mac (uint8_t mac[MAC_ADDR_LEN]) { CC3000_START; int ret = nvmem_get_mac_address(mac); CC3000_END; return ret; }
/** * @brief Reads the MAC address from the CC3000 * * @param[out] mac_addr six char buffer containing the MAC address * @return True if MAC address could be read from the CC3000. False otherwise. */ bool SFE_CC3000::getMacAddress(unsigned char *mac_addr) { /* If CC3000 is not initialized, return false. */ if (!getInitStatus()) { return false; } /* Read MAC address from the CC3000 */ if (nvmem_get_mac_address(mac_addr) != CC3000_SUCCESS) { return false; } return true; }
void patch_prog_start() { unsigned short index; unsigned char *pRMParams; printf("Initializing module...\n"); // Init module and request to load with no patches. // This is in order to overwrite restrictions to // write to specific places in EEPROM. initDriver(1); // Read MAC address. mac_status = nvmem_get_mac_address(cMacFromEeprom); return_status = 1; printf("Reading RM parameters...\n"); while ((return_status) && (counter < 3)) { // Read RM parameters. // Read in 16 parts to work with tiny driver. return_status = 0; pRMParams = cRMParamsFromEeprom; for (index = 0; index < 16; index++) { return_status |= nvmem_read(NVMEM_RM_FILEID, 8, 8*index, pRMParams); pRMParams += 8; } counter++; } // If RM file is not valid, load the default one. if (counter == 3) { printf("RM is not valid, loading default one...\n"); pRMParams = (unsigned char *)cRMdefaultParams; } else { printf("RM is valid.\n"); pRMParams = cRMParamsFromEeprom; } return_status = 1; printf("Writing new FAT\n"); while (return_status) { // Write new FAT. return_status = fat_write_content(aFATEntries[0], aFATEntries[1]); } return_status = 1; printf("Writing RM parameters...\n"); while (return_status) { // Write RM parameters. // Write in 4 parts to work with tiny driver. return_status = 0; for (index = 0; index < 4; index++) { return_status |= nvmem_write(NVMEM_RM_FILEID, 32, 32*index, (pRMParams + 32*index)); } } return_status = 1; // Write back the MAC address, only if exists. if (mac_status == 0) { // Zero out MCAST bit if set. cMacFromEeprom[0] &= 0xfe; printf("Writing back MAC address..\n"); while (return_status) { return_status = nvmem_set_mac_address(cMacFromEeprom); } } // Update driver ucStatus_Dr = 1; printf("Updating driver patch...\n"); while (ucStatus_Dr) { // Writing driver patch to EEPRROM - PROTABLE CODE // Note that the array itself is changing between the // different Service Packs. ucStatus_Dr = nvmem_write_patch(NVMEM_WLAN_DRIVER_SP_FILEID, drv_length, wlan_drv_patch); } // Update firmware ucStatus_FW = 1; printf("Updating firmware patch...\n"); while (ucStatus_FW) { // Writing FW patch to EEPRROM - PROTABLE CODE // Note that the array itself is changing between the // different Service Packs. ucStatus_FW = nvmem_write_patch(NVMEM_WLAN_FW_SP_FILEID, fw_length, fw_patch); } printf("Update complete, resetting module\n"\ "If this doesn't work, reset manually...\n"); wlan_stop(); systick_sleep(500); // Re-Init module and request to load with patches. initDriver(0); // If MAC does not exist, it is recommended // that the user will write a valid mac address. if (mac_status != 0) { printf("MAC address is not valid, please write a new one\n"); } // Patch update done printf("All done, call wlan.patch_version()\n"); }
void Initialize(void) { #ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK mmstart = mallinfo(); memcpy(&mmprevious, &mmstart, sizeof(struct mallinfo)); show_memory_usage(&mmstart,&mmprevious); #endif uint8_t fancyBuffer[MAC_ADDR_LEN]; if (isInitialized) { printf("CC3000 already initialized. Shutting down and restarting...\n"); wlan_stop(); usleep(1000000); /* Delay 1s */ } printf("Initializing CC3000...\n"); CC3000_Init(); #ifdef CONFIG_EXAMPLES_CC3000_STACK_CHECK stkmon_disp(); #endif printf(" CC3000 init complete.\n"); if (nvmem_read_sp_version(fancyBuffer) == 0) { printf(" Firmware version is: "); printf("%d", fancyBuffer[0]); printf("."); printf("%d\n", fancyBuffer[1]); } else { printf("Unable to get firmware version. Can't continue.\n"); return; } #if 0 if (nvmem_get_mac_address(fancyBuffer) == 0) { printf(" MAC address: "); for (i = 0; i < MAC_ADDR_LEN; i++) { if (i != 0) { printf(":"); } printf("%x", fancyBuffer[i]); } printf("\n"); isInitialized = true; } else { printf("Unable to get MAC address. Can't continue.\n"); } #else isInitialized = true; #endif #ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK mmprevious = mallinfo(); show_memory_usage(&mmstart,&mmprevious); #endif }