Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w5500: mac: poll VERSIONR to ensure the chip is initialised (IDFGH-10061) #11337

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions components/esp_eth/src/esp_eth_mac_w5500.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,22 @@ static esp_err_t w5500_verify_id(emac_w5500_t *emac)
{
esp_err_t ret = ESP_OK;
uint8_t version = 0;
ESP_GOTO_ON_ERROR(w5500_read(emac, W5500_REG_VERSIONR, &version, sizeof(version)), err, TAG, "read VERSIONR failed");
// W5500 doesn't have chip ID, we check the version number instead
ESP_GOTO_ON_FALSE(version == W5500_CHIP_VERSION, ESP_ERR_INVALID_VERSION, err, TAG, "invalid chip version, expected 0x%x, actual 0x%x", W5500_CHIP_VERSION, version);

err:
return ret;
ESP_LOGD(TAG, "Waiting W5500 to start & verify version...");
uint32_t to = 0;
for (to = 0; to < emac->sw_reset_timeout_ms / 10; to++) {
ret = w5500_read(emac, W5500_REG_VERSIONR, &version, sizeof(version));
if (ret != ESP_OK) {
ESP_LOGD(TAG, "Poll VERSIONR failed, retrying...");
vTaskDelay(pdMS_TO_TICKS(10));
continue;
} else if (version == W5500_CHIP_VERSION) {
return ESP_OK;
}
}

huming2207 marked this conversation as resolved.
Show resolved Hide resolved
ESP_LOGE(TAG, "W5500 version mismatched, expected 0x%02x, got 0x%02x", W5500_CHIP_VERSION, version);
return ESP_ERR_INVALID_VERSION;
huming2207 marked this conversation as resolved.
Show resolved Hide resolved
}

static esp_err_t w5500_setup_default(emac_w5500_t *emac)
Expand Down