From bb2f346e55f484edc50f68cb26d164d8a79bcf39 Mon Sep 17 00:00:00 2001 From: Reinis Muiznieks Date: Mon, 16 Jan 2023 19:29:16 +0200 Subject: [PATCH 1/2] Verify w5500 chip properly --- components/esp_eth/src/esp_eth_mac_w5500.c | 4 ++-- components/esp_eth/src/w5500.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_eth/src/esp_eth_mac_w5500.c b/components/esp_eth/src/esp_eth_mac_w5500.c index 2a40332eec8..7e4bf846f72 100644 --- a/components/esp_eth/src/esp_eth_mac_w5500.c +++ b/components/esp_eth/src/esp_eth_mac_w5500.c @@ -230,8 +230,8 @@ 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 just print the version number instead - ESP_LOGI(TAG, "version=%x", version); + // 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; diff --git a/components/esp_eth/src/w5500.h b/components/esp_eth/src/w5500.h index 4460f7a8de5..c704ca8e077 100644 --- a/components/esp_eth/src/w5500.h +++ b/components/esp_eth/src/w5500.h @@ -16,6 +16,8 @@ #define W5500_BSB_OFFSET (3) // Block Select Bits offset #define W5500_RWB_OFFSET (2) // Read Write Bits offset +#define W5500_CHIP_VERSION (0x4) // Chip version that VERSIONR returns + #define W5500_BSB_COM_REG (0x00) // Common Register #define W5500_BSB_SOCK_REG(s) ((s)*4+1) // Socket Register #define W5500_BSB_SOCK_TX_BUF(s) ((s)*4+2) // Socket TX Buffer From 5fdb49698af5b179b558caa13f006790dd9c36d2 Mon Sep 17 00:00:00 2001 From: Ondrej Date: Thu, 19 Jan 2023 07:54:32 +0000 Subject: [PATCH 2/2] esp_eth: fixed copyright for W5500 --- components/esp_eth/src/esp_eth_mac_w5500.c | 2 +- components/esp_eth/src/w5500.h | 18 +++++------------- tools/ci/check_copyright_ignore.txt | 1 - 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/components/esp_eth/src/esp_eth_mac_w5500.c b/components/esp_eth/src/esp_eth_mac_w5500.c index 7e4bf846f72..e590d7df50b 100644 --- a/components/esp_eth/src/esp_eth_mac_w5500.c +++ b/components/esp_eth/src/esp_eth_mac_w5500.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/components/esp_eth/src/w5500.h b/components/esp_eth/src/w5500.h index c704ca8e077..ba0a1156df1 100644 --- a/components/esp_eth/src/w5500.h +++ b/components/esp_eth/src/w5500.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #define W5500_ADDR_OFFSET (16) // Address length #define W5500_BSB_OFFSET (3) // Block Select Bits offset diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index fc5c2b16ba9..d1ee61f7f49 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -400,7 +400,6 @@ components/console/linenoise/linenoise.c components/console/linenoise/linenoise.h components/esp_eth/src/dm9051.h components/esp_eth/src/ksz8851.h -components/esp_eth/src/w5500.h components/esp_eth/test_apps/component_ut_test.py components/esp_eth/test_apps/main/esp_eth_test.c components/esp_event/esp_event_private.c