itm / wsn-device-drivers

Drivers for Wireless Sensor Network Devices
Other
6 stars 4 forks source link

Flashing sometimes results in 0xFF...FF MAC adresses #116

Open danbim opened 12 years ago

danbim commented 12 years ago

Looking at the code there could be a more clever way to validate (and potentially repair) a flash operation:

  1. Read current MAC address and remember it
  2. Flash image
  3. Read MAC address and compare with the one remembered
  4. In case the current and remembered don't match restore the old by only writing the old MAC address

While this won't guarantee failure-freedom it would certainly result in less occasions on which the MAC address of the node is damaged.

danbim commented 12 years ago

Current code:

byte[] deviceFlashHeader = readDeviceFlashHeader(chipType.getHeaderStart(), chipType.getHeaderLength());
if (MacAddress.HIGHEST_MAC_ADDRESS.equals(new MacAddress(deviceFlashHeader))) {
    throw new FlashProgramFailedException("Device MAC address (0xFF...FF) seems broken!");
}
binaryImage.insertHeader(deviceFlashHeader);

It reads the current MAC address from the device and checks if its not equal to 0xFF...FF.