As an aide to debugging, we should print out the expected value of the EEPROM checksum in addition to just saying that it is wrong.
Signed-off-by: Kyle Moffett <kyle.d.moff...@boeing.com> Cc: Ben Warren <biggerbadder...@gmail.com> --- No changes since v1 drivers/net/e1000.c | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index 38eed37..5d957ad 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -873,29 +873,43 @@ e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is * valid. *****************************************************************************/ -static int -e1000_validate_eeprom_checksum(struct eth_device *nic) +static int e1000_validate_eeprom_checksum(struct e1000_hw *hw) { - struct e1000_hw *hw = nic->priv; - uint16_t checksum = 0; - uint16_t i, eeprom_data; + uint16_t i, checksum, checksum_reg, *buf; DEBUGFUNC(); - for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { - if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { - DEBUGOUT("EEPROM Read Error\n"); - return -E1000_ERR_EEPROM; - } - checksum += eeprom_data; + /* Allocate a temporary buffer */ + buf = malloc(sizeof(buf[0]) * (EEPROM_CHECKSUM_REG + 1)); + if (!buf) { + printf("%s: ERROR: Unable to allocate EEPROM buffer!\n", + hw->nic->name); + return -E1000_ERR_EEPROM; } - if (checksum == (uint16_t) EEPROM_SUM) { - return 0; - } else { - DEBUGOUT("EEPROM Checksum Invalid\n"); + /* Read the EEPROM */ + if (e1000_read_eeprom(hw, 0, EEPROM_CHECKSUM_REG + 1, buf) < 0) { + printf("%s: ERROR: Unable to read EEPROM!\n", + hw->nic->name); return -E1000_ERR_EEPROM; } + + /* Compute the checksum */ + for (i = 0; i < EEPROM_CHECKSUM_REG; i++) + checksum += buf[i]; + checksum = ((uint16_t)EEPROM_SUM) - checksum; + checksum_reg = buf[i]; + + /* Verify it! */ + if (checksum == checksum_reg) + return 0; + + /* Hrm, verification failed, print an error */ + printf("%s: ERROR: EEPROM checksum is incorrect!\n", hw->nic->name); + printf("%s: ERROR: ...register was 0x%04hx, calculated 0x%04hx\n", + hw->nic->name, checksum_reg, checksum); + + return -E1000_ERR_EEPROM; } /***************************************************************************** @@ -5226,10 +5240,8 @@ e1000_initialize(bd_t * bis) printf("%s: ERROR: EEPROM is invalid!\n", nic->name); continue; } - if (e1000_validate_eeprom_checksum(nic) < 0) { - printf("%s: ERROR: EEPROM checksum is bad!\n", nic->name); + if (e1000_validate_eeprom_checksum(hw)) continue; - } #endif e1000_read_mac_addr(nic); e1000_get_bus_type(hw); -- 1.7.2.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot