|
|
@@ -5,34 +5,17 @@
|
|
|
*/
|
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
+#include <inttypes.h>
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
#include "freertos/task.h"
|
|
|
#include "freertos/event_groups.h"
|
|
|
-#include "unity.h"
|
|
|
-#include "test_utils.h"
|
|
|
-#include "esp_event.h"
|
|
|
-#include "esp_netif.h"
|
|
|
-#include "esp_eth.h"
|
|
|
#include "esp_log.h"
|
|
|
#include "esp_http_client.h"
|
|
|
#include "esp_rom_md5.h"
|
|
|
-#include "soc/soc_caps.h"
|
|
|
-
|
|
|
-#if SOC_EMAC_SUPPORTED
|
|
|
+#include "esp_eth_test_common.h"
|
|
|
|
|
|
static const char *TAG = "esp32_eth_test";
|
|
|
|
|
|
-#define ETH_START_BIT BIT(0)
|
|
|
-#define ETH_STOP_BIT BIT(1)
|
|
|
-#define ETH_CONNECT_BIT BIT(2)
|
|
|
-#define ETH_GOT_IP_BIT BIT(3)
|
|
|
-
|
|
|
-#define ETH_START_TIMEOUT_MS (10000)
|
|
|
-#define ETH_CONNECT_TIMEOUT_MS (40000)
|
|
|
-#define ETH_STOP_TIMEOUT_MS (10000)
|
|
|
-#define ETH_GET_IP_TIMEOUT_MS (60000)
|
|
|
-#define ETH_DOWNLOAD_END_TIMEOUT_MS (240000)
|
|
|
-
|
|
|
extern const char dl_espressif_com_root_cert_pem_start[] asm("_binary_dl_espressif_com_root_cert_pem_start");
|
|
|
extern const char dl_espressif_com_root_cert_pem_end[] asm("_binary_dl_espressif_com_root_cert_pem_end");
|
|
|
|
|
|
@@ -40,48 +23,6 @@ extern const char dl_espressif_com_root_cert_pem_end[] asm("_binary_dl_espress
|
|
|
static md5_context_t md5_context;
|
|
|
static uint8_t digest[16];
|
|
|
|
|
|
-/** Event handler for Ethernet events */
|
|
|
-static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
|
|
- int32_t event_id, void *event_data)
|
|
|
-{
|
|
|
- EventGroupHandle_t eth_event_group = (EventGroupHandle_t)arg;
|
|
|
- switch (event_id) {
|
|
|
- case ETHERNET_EVENT_CONNECTED:
|
|
|
- xEventGroupSetBits(eth_event_group, ETH_CONNECT_BIT);
|
|
|
- ESP_LOGI(TAG, "Ethernet Link Up");
|
|
|
- break;
|
|
|
- case ETHERNET_EVENT_DISCONNECTED:
|
|
|
- ESP_LOGI(TAG, "Ethernet Link Down");
|
|
|
- break;
|
|
|
- case ETHERNET_EVENT_START:
|
|
|
- xEventGroupSetBits(eth_event_group, ETH_START_BIT);
|
|
|
- ESP_LOGI(TAG, "Ethernet Started");
|
|
|
- break;
|
|
|
- case ETHERNET_EVENT_STOP:
|
|
|
- xEventGroupSetBits(eth_event_group, ETH_STOP_BIT);
|
|
|
- ESP_LOGI(TAG, "Ethernet Stopped");
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/** Event handler for IP_EVENT_ETH_GOT_IP */
|
|
|
-static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
|
|
- int32_t event_id, void *event_data)
|
|
|
-{
|
|
|
- EventGroupHandle_t eth_event_group = (EventGroupHandle_t)arg;
|
|
|
- ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
|
|
- const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
|
|
- ESP_LOGI(TAG, "Ethernet Got IP Address");
|
|
|
- ESP_LOGI(TAG, "~~~~~~~~~~~");
|
|
|
- ESP_LOGI(TAG, "ETHIP:" IPSTR, IP2STR(&ip_info->ip));
|
|
|
- ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
|
|
|
- ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
|
|
|
- ESP_LOGI(TAG, "~~~~~~~~~~~");
|
|
|
- xEventGroupSetBits(eth_event_group, ETH_GOT_IP_BIT);
|
|
|
-}
|
|
|
-
|
|
|
static esp_err_t test_uninstall_driver(esp_eth_handle_t eth_hdl, uint32_t ms_to_wait)
|
|
|
{
|
|
|
int i = 0;
|
|
|
@@ -99,37 +40,59 @@ static esp_err_t test_uninstall_driver(esp_eth_handle_t eth_hdl, uint32_t ms_to_
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet io test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
+TEST_CASE("ethernet io test", "[ethernet]")
|
|
|
{
|
|
|
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
mac_config.flags = ETH_MAC_FLAG_PIN_TO_CORE; // pin to core
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- // auto detect PHY address
|
|
|
- phy_config.phy_addr = ESP_ETH_PHY_ADDR_AUTO;
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, &mac_config);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
- /* get MAC address */
|
|
|
- uint8_t mac_addr[6];
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
+
|
|
|
+ /* get default MAC address */
|
|
|
+ uint8_t mac_addr[ETH_ADDR_LEN];
|
|
|
memset(mac_addr, 0, sizeof(mac_addr));
|
|
|
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr));
|
|
|
ESP_LOGI(TAG, "Ethernet MAC Address: %02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
|
|
|
TEST_ASSERT(mac_addr[0] != 0);
|
|
|
+// *** SPI Ethernet modules deviation ***
|
|
|
+// Rationale: The SPI Ethernet modules don't have a burned default factory MAC address hence local MAC is used
|
|
|
+#if !CONFIG_TARGET_USE_SPI_ETHERNET
|
|
|
+ TEST_ASSERT_BITS(0b00000011, 0b00, mac_addr[0]); // Check UL&IG, should be UI
|
|
|
+#endif
|
|
|
+
|
|
|
+ /* set different MAC address */
|
|
|
+ mac_addr[5] ^= mac_addr[4];
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_MAC_ADDR, mac_addr));
|
|
|
+ /* get new MAC address */
|
|
|
+ uint8_t mac_addr_new[ETH_ADDR_LEN] = { 0 };
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr_new));
|
|
|
+ ESP_LOGI(TAG, "Ethernet MAC Address: %02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
+ mac_addr_new[0], mac_addr_new[1], mac_addr_new[2], mac_addr_new[3], mac_addr_new[4], mac_addr_new[5]);
|
|
|
+ TEST_ASSERT_EQUAL_UINT8_ARRAY(mac_addr_new, mac_addr, ETH_ADDR_LEN);
|
|
|
+
|
|
|
+// *** SPI Ethernet modules deviation ***
|
|
|
+// Rationale: SPI Ethernet modules PHYs and MACs are statically configured at one die, hence there is no need for PHY address
|
|
|
+// from user's point of view
|
|
|
+#if !CONFIG_TARGET_USE_SPI_ETHERNET
|
|
|
/* get PHY address */
|
|
|
int phy_addr = -1;
|
|
|
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_PHY_ADDR, &phy_addr));
|
|
|
ESP_LOGI(TAG, "Ethernet PHY Address: %d", phy_addr);
|
|
|
TEST_ASSERT(phy_addr >= 0 && phy_addr <= 31);
|
|
|
+#endif
|
|
|
TEST_ESP_OK(esp_eth_driver_uninstall(eth_handle));
|
|
|
TEST_ESP_OK(phy->del(phy));
|
|
|
TEST_ESP_OK(mac->del(mac));
|
|
|
+ extra_cleanup();
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
+TEST_CASE("ethernet io speed/duplex/autonegotiation", "[ethernet]")
|
|
|
{
|
|
|
EventBits_t bits = 0;
|
|
|
EventGroupHandle_t eth_event_group = xEventGroupCreate();
|
|
|
@@ -138,19 +101,19 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
TEST_ESP_OK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, eth_event_group));
|
|
|
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
mac_config.flags = ETH_MAC_FLAG_PIN_TO_CORE; // pin to core
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- // auto detect PHY address
|
|
|
- phy_config.phy_addr = ESP_ETH_PHY_ADDR_AUTO;
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, &mac_config);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
|
|
|
// Set PHY to loopback mode so we do not have to take care about link configuration of the other node.
|
|
|
// The reason behind is improbable, however, if the other node was configured to e.g. 100 Mbps and we
|
|
|
// tried to change the speed at ESP node to 10 Mbps, we could get into trouble to establish a link.
|
|
|
+ // TODO: this test in this configuration may not work for all the chips (JIRA IDF-6186)
|
|
|
bool loopback_en = true;
|
|
|
esp_eth_ioctl(eth_handle, ETH_CMD_S_PHY_LOOPBACK, &loopback_en);
|
|
|
|
|
|
@@ -173,13 +136,13 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_100M, exp_speed);
|
|
|
|
|
|
bool exp_autoneg_en;
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
TEST_ASSERT_EQUAL(true, exp_autoneg_en);
|
|
|
|
|
|
ESP_LOGI(TAG, "try to change autonegotiation when driver is started...");
|
|
|
bool auto_nego_en = false;
|
|
|
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_STATE, esp_eth_ioctl(eth_handle, ETH_CMD_S_AUTONEGO, &auto_nego_en));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
TEST_ASSERT_EQUAL(true, exp_autoneg_en);
|
|
|
|
|
|
ESP_LOGI(TAG, "stop the Ethernet driver and...");
|
|
|
@@ -195,22 +158,22 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
// Disable autonegotiation and change speed to 10 Mbps and duplex to half
|
|
|
ESP_LOGI(TAG, "disable the autonegotiation and change the speed/duplex...");
|
|
|
auto_nego_en = false;
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_AUTONEGO, &auto_nego_en));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_AUTONEGO, &auto_nego_en));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
TEST_ASSERT_EQUAL(false, exp_autoneg_en);
|
|
|
|
|
|
// set new duplex mode
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
|
|
|
// set new speed
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
|
|
|
// start the driver and wait for connection establish
|
|
|
esp_eth_start(eth_handle);
|
|
|
bits = xEventGroupWaitBits(eth_event_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(ETH_CONNECT_TIMEOUT_MS));
|
|
|
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_HALF, exp_duplex);
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_10M, exp_speed);
|
|
|
@@ -219,14 +182,14 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
esp_eth_stop(eth_handle);
|
|
|
ESP_LOGI(TAG, "change speed again...");
|
|
|
speed = ETH_SPEED_100M;
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
|
|
|
// start the driver and wait for connection establish
|
|
|
esp_eth_start(eth_handle);
|
|
|
bits = xEventGroupWaitBits(eth_event_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(ETH_CONNECT_TIMEOUT_MS));
|
|
|
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_HALF, exp_duplex);
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_100M, exp_speed);
|
|
|
|
|
|
@@ -234,14 +197,14 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
esp_eth_stop(eth_handle);
|
|
|
ESP_LOGI(TAG, "change duplex again...");
|
|
|
duplex = ETH_DUPLEX_FULL;
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
|
|
|
// start the driver and wait for connection establish
|
|
|
esp_eth_start(eth_handle);
|
|
|
bits = xEventGroupWaitBits(eth_event_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(ETH_CONNECT_TIMEOUT_MS));
|
|
|
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_FULL, exp_duplex);
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_100M, exp_speed);
|
|
|
@@ -253,8 +216,8 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_STATE, esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_STATE, esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_FULL, exp_duplex);
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_100M, exp_speed);
|
|
|
@@ -265,17 +228,17 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
duplex = ETH_DUPLEX_HALF;
|
|
|
|
|
|
// set new duplex mode
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_DUPLEX_MODE, &duplex));
|
|
|
|
|
|
// set new speed
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_SPEED, &speed));
|
|
|
|
|
|
// start the driver and wait for connection establish
|
|
|
esp_eth_start(eth_handle);
|
|
|
bits = xEventGroupWaitBits(eth_event_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(ETH_CONNECT_TIMEOUT_MS));
|
|
|
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_HALF, exp_duplex);
|
|
|
TEST_ASSERT_EQUAL(ETH_SPEED_10M, exp_speed);
|
|
|
@@ -287,11 +250,11 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
bits = xEventGroupWaitBits(eth_event_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(ETH_CONNECT_TIMEOUT_MS));
|
|
|
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
|
|
|
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_AUTONEGO, &exp_autoneg_en));
|
|
|
TEST_ASSERT_EQUAL(true, exp_autoneg_en);
|
|
|
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
- TEST_ASSERT_EQUAL(ESP_OK, esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &exp_duplex));
|
|
|
+ TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &exp_speed));
|
|
|
|
|
|
// verify autonegotiation result (expecting the best link configuration)
|
|
|
TEST_ASSERT_EQUAL(ETH_DUPLEX_FULL, exp_duplex);
|
|
|
@@ -307,24 +270,25 @@ TEST_CASE("esp32 ethernet speed/duplex/autonegotiation", "[ethernet][test_env=UT
|
|
|
TEST_ESP_OK(mac->del(mac));
|
|
|
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
|
|
TEST_ESP_OK(esp_event_loop_delete_default());
|
|
|
+ extra_cleanup();
|
|
|
vEventGroupDelete(eth_event_group);
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet event test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
+TEST_CASE("ethernet event test", "[ethernet]")
|
|
|
{
|
|
|
EventBits_t bits = 0;
|
|
|
EventGroupHandle_t eth_event_group = xEventGroupCreate();
|
|
|
TEST_ASSERT(eth_event_group != NULL);
|
|
|
TEST_ESP_OK(esp_event_loop_create_default());
|
|
|
TEST_ESP_OK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, eth_event_group));
|
|
|
- eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
// this test only test layer2 event, so don't need to register input callback (i.e. esp_eth_update_input_path)
|
|
|
TEST_ESP_OK(esp_eth_start(eth_handle));
|
|
|
/* wait for connection start */
|
|
|
@@ -344,10 +308,11 @@ TEST_CASE("esp32 ethernet event test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
TEST_ESP_OK(mac->del(mac));
|
|
|
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
|
|
TEST_ESP_OK(esp_event_loop_delete_default());
|
|
|
+ extra_cleanup();
|
|
|
vEventGroupDelete(eth_event_group);
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet dhcp test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
+TEST_CASE("ethernet dhcp test", "[ethernet]")
|
|
|
{
|
|
|
EventBits_t bits = 0;
|
|
|
EventGroupHandle_t eth_event_group = xEventGroupCreate();
|
|
|
@@ -357,16 +322,15 @@ TEST_CASE("esp32 ethernet dhcp test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
// create TCP/IP netif
|
|
|
esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH();
|
|
|
esp_netif_t *eth_netif = esp_netif_new(&netif_cfg);
|
|
|
-
|
|
|
- eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
// install Ethernet driver
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
// combine driver with netif
|
|
|
esp_eth_netif_glue_handle_t glue = esp_eth_new_netif_glue(eth_handle);
|
|
|
TEST_ESP_OK(esp_netif_attach(eth_netif, glue));
|
|
|
@@ -392,10 +356,11 @@ TEST_CASE("esp32 ethernet dhcp test", "[ethernet][test_env=UT_T2_Ethernet]")
|
|
|
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
|
|
esp_netif_destroy(eth_netif);
|
|
|
TEST_ESP_OK(esp_event_loop_delete_default());
|
|
|
+ extra_cleanup();
|
|
|
vEventGroupDelete(eth_event_group);
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet start/stop stress test", "[ethernet][test_env=UT_T2_Ethernet][timeout=240]")
|
|
|
+TEST_CASE("ethernet start/stop stress test with IP stack", "[ethernet]")
|
|
|
{
|
|
|
EventBits_t bits = 0;
|
|
|
EventGroupHandle_t eth_event_group = xEventGroupCreate();
|
|
|
@@ -405,16 +370,15 @@ TEST_CASE("esp32 ethernet start/stop stress test", "[ethernet][test_env=UT_T2_Et
|
|
|
// create TCP/IP netif
|
|
|
esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH();
|
|
|
esp_netif_t *eth_netif = esp_netif_new(&netif_cfg);
|
|
|
-
|
|
|
- eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
// install Ethernet driver
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
// combine driver with netif
|
|
|
esp_eth_netif_glue_handle_t glue = esp_eth_new_netif_glue(eth_handle);
|
|
|
TEST_ESP_OK(esp_netif_attach(eth_netif, glue));
|
|
|
@@ -444,6 +408,7 @@ TEST_CASE("esp32 ethernet start/stop stress test", "[ethernet][test_env=UT_T2_Et
|
|
|
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
|
|
esp_netif_destroy(eth_netif);
|
|
|
TEST_ESP_OK(esp_event_loop_delete_default());
|
|
|
+ extra_cleanup();
|
|
|
vEventGroupDelete(eth_event_group);
|
|
|
}
|
|
|
|
|
|
@@ -494,7 +459,7 @@ static void eth_start_download(void)
|
|
|
esp_rom_md5_final(digest, &md5_context);
|
|
|
}
|
|
|
|
|
|
-TEST_CASE("esp32 ethernet download test", "[ethernet][test_env=UT_T2_Ethernet][timeout=240]")
|
|
|
+TEST_CASE("ethernet download test", "[ethernet]")
|
|
|
{
|
|
|
EventBits_t bits = 0;
|
|
|
EventGroupHandle_t eth_event_group = xEventGroupCreate();
|
|
|
@@ -504,16 +469,15 @@ TEST_CASE("esp32 ethernet download test", "[ethernet][test_env=UT_T2_Ethernet][t
|
|
|
// create TCP/IP netif
|
|
|
esp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH();
|
|
|
esp_netif_t *eth_netif = esp_netif_new(&netif_cfg);
|
|
|
-
|
|
|
- eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
|
|
- eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
|
|
|
- esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config);
|
|
|
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
|
|
- esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
|
|
+ esp_eth_mac_t *mac = mac_init(NULL, NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(mac);
|
|
|
+ esp_eth_phy_t *phy = phy_init(NULL);
|
|
|
+ TEST_ASSERT_NOT_NULL(phy);
|
|
|
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(mac, phy);
|
|
|
esp_eth_handle_t eth_handle = NULL;
|
|
|
// install Ethernet driver
|
|
|
TEST_ESP_OK(esp_eth_driver_install(ð_config, ð_handle));
|
|
|
+ extra_eth_config(eth_handle);
|
|
|
// combine driver with netif
|
|
|
esp_eth_netif_glue_handle_t glue = esp_eth_new_netif_glue(eth_handle);
|
|
|
TEST_ESP_OK(esp_netif_attach(eth_netif, glue));
|
|
|
@@ -535,7 +499,7 @@ TEST_CASE("esp32 ethernet download test", "[ethernet][test_env=UT_T2_Ethernet][t
|
|
|
printf("%d ", digest[i]);
|
|
|
}
|
|
|
printf("\r\n");
|
|
|
- TEST_ASSERT(memcmp(expect_digest, digest, sizeof(digest)) == 0);
|
|
|
+ TEST_ASSERT_EQUAL_UINT8_ARRAY(expect_digest, digest, sizeof(digest));
|
|
|
|
|
|
// stop Ethernet driver
|
|
|
TEST_ESP_OK(esp_eth_stop(eth_handle));
|
|
|
@@ -551,7 +515,6 @@ TEST_CASE("esp32 ethernet download test", "[ethernet][test_env=UT_T2_Ethernet][t
|
|
|
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
|
|
esp_netif_destroy(eth_netif);
|
|
|
TEST_ESP_OK(esp_event_loop_delete_default());
|
|
|
+ extra_cleanup();
|
|
|
vEventGroupDelete(eth_event_group);
|
|
|
}
|
|
|
-
|
|
|
-#endif // SOC_EMAC_SUPPORTED
|