0. はじめに
↑ 前回、ESP-IDF環境でした。今回は、Arduino環境で 有線LAN を試します。
Espressif Systems 謹製のESP32-P4-Function-EV-Board は、RJ45 有線LANポートを有しており、PHYチップに IP101GRIを使用しています。
今回は、Arduino環境で ESP32P4 Dev Module の Ethernetサンプルを試してみます。
1. Ethernet/examples/ETH_TLK110
使用した ESP32 ボードマネジャー Arduino Coreのバージョンは、現時点の最新 3.3.5 。
以降は、「Arduino-IDE 2.3 および Espressif ESP32 Core 3.3.5 は インストール済み」として進めます。
1.1 ターゲットボードの指定
ESP32-P4-Function-EV-Boardが見当たらないので、ESP32P4 Dev Moduleを選びます。
メニュー→ツール→esp32→ESP32P4 Dev Module
1.2 ボード定義のピン情報を確認
ESP32P4 Dev Moduleを確認しておきます。
variants/esp32p4/pins_arduino.hの52行目から、ESP32-P4-Function-EV-BoardのETH(PHY)のピン定義が次のように定義されています。
/* ESP32-P4 EV Function board specific definitions */
//ETH
#define ETH_PHY_TYPE ETH_PHY_TLK110
#define ETH_PHY_ADDR 1
#define ETH_PHY_MDC 31
#define ETH_PHY_MDIO 52
#define ETH_PHY_POWER 51
#define ETH_RMII_TX_EN 49
#define ETH_RMII_TX0 34
#define ETH_RMII_TX1 35
#define ETH_RMII_RX0 29
#define ETH_RMII_RX1_EN 30
#define ETH_RMII_CRS_DV 28
#define ETH_RMII_CLK 50
#define ETH_CLK_MODE EMAC_CLK_EXT_IN
これらのピンは、ESP32-P4-Function-EV-Boardの回路図で確認した内容と一致しています。
1.3 スケッチ例を選ぶ
メニュー→ファイル→スケッチ例→Ethernet→ETH_TLK110
Ethernetスケッチ例にIP101が見当たらないので、TLK110を選びます。
次のとおりETH_PHY_IP101はETH_PHY_TLK110と「同じ」と定義されており、問題ありません。
#define ETH_PHY_IP101 ETH_PHY_TLK110
開いたスケッチの変更は一切不要です。
先頭の#ifndef ETH_PHY_MDCにより、続く不要な#defineは すべてスキップされます。
#ifndef ETH_PHY_MDC
#define ETH_PHY_TYPE ETH_PHY_TLK110
#if CONFIG_IDF_TARGET_ESP32
#define ETH_PHY_ADDR 31
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#define ETH_PHY_POWER 17
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#elif CONFIG_IDF_TARGET_ESP32P4
#define ETH_PHY_ADDR 1
#define ETH_PHY_MDC 31
#define ETH_PHY_MDIO 52
#define ETH_PHY_POWER 51
#define ETH_CLK_MODE EMAC_CLK_EXT_IN
#endif
#endif
1.4 コンパイル&アップロード
Command+U(Ctrl+U)にて コンパイルして、ESP32P4ボードにアップロードします。
2. 実行結果
シリアルモニターでログを確認しました。
(ログレベル:Verbose)
ESP-ROM:esp32p4-eco2-20240710
Build:Jul 10 2024
rst:0x17 (CHIP_USB_UART_RESET),boot:0x7 (DOWNLOAD(USB/UART0/SPI))
Core0 Saved PC:0x4ff02ae0
Core1 Saved PC:0x4ff02ae0
waiting for download
ESP-ROM:esp32p4-eco2-20240710
Build:Jul 10 2024
rst:0x17 (CHIP_USB_UART_RESET),boot:0xf (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4ff10c0e
Core1 Saved PC:0x4fc058e0
SPI mode:DIO, clock div:1
load:0x4ff33ce0,len:0x11dc
load:0x4ff29ed0,len:0xccc
load:0x4ff2cbd0,len:0x3568
entry 0x4ff29ed0
E (138) esp_core_dump_flash: Incorrect size of core dump image: 1210016248
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
Model : ESP32-P4
Package : 0
Revision : 1.03
Cores : 2
CPU Frequency : 360 MHz
XTAL Frequency : 40 MHz
Features Bitfield : 0000000000
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : No
Classic BT : No
BT Low Energy : No
IEEE 802.15.4 : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
Total Size : 602584 B ( 588.5 KB)
Free Bytes : 565800 B ( 552.5 KB)
Allocated Bytes : 30976 B ( 30.2 KB)
Minimum Free Bytes: 560532 B ( 547.4 KB)
Largest Free Block: 385012 B ( 376.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 16777216 B (16 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Flash Frequency : 80 MHz (source: 80 MHz, divider: 1)
Bus Mode : QIO
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 1280.0 KB, type: APP, subtype: OTA_0
app1 : addr: 0x00150000, size: 1280.0 KB, type: APP, subtype: OTA_1
spiffs : addr: 0x00290000, size: 1408.0 KB, type: DATA, subtype: SPIFFS
coredump : addr: 0x003F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : Jan 19 2026 15:59:23
Compile Host OS : macosx
ESP-IDF Version : v5.5.2-249-gf56bea3d1f
Arduino Version : 3.3.6
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : ESP32P4_DEV
Arduino Variant : esp32p4
Arduino FQBN : esp32:esp32:esp32p4:UploadSpeed=921600,USBMode=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=default,DebugLevel=verbose,PSRAM=disabled,EraseFlash=none,JTAGAdapter=default,ChipVariant=prev3
============ Before Setup End ============
[ 338][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_RX (2) cleared
[ 347][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_TX (3) cleared
[ 357][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_CTS (4) cleared
[ 366][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_RTS (5) cleared
[ 376][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 38 successfully set to type UART_RX (2) with bus 0x4ff104ec
[ 387][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x40008e30
[ 398][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 37 successfully set to type UART_TX (3) with bus 0x4ff104ec
[ 409][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40008cf6
[ 420][V][esp32-hal-uart.c:641] uartBegin(): UART0 baud(115200) Mode(800001c) rxPin(38) txPin(37)
[ 429][V][esp32-hal-uart.c:739] uartBegin(): UART0 not installed. Starting installation
[ 437][V][esp32-hal-uart.c:749] uartBegin(): UART0 RX FIFO full threshold set to 120 (value requested: 120 || FIFO Max = 128)
[ 448][V][esp32-hal-uart.c:775] uartBegin(): Setting UART0 to use XTAL clock
[ 455][V][esp32-hal-uart.c:814] uartBegin(): UART0: RX and TX signals are set not inverted.
[ 463][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_RX (2) cleared
[ 473][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_TX (3) cleared
[ 482][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_CTS (4) cleared
[ 492][V][esp32-hal-periman.c:251] perimanClearBusDeinit(): Deinit function for type UART_RTS (5) cleared
[ 501][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x40008e30
[ 513][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_TX (3) successfully set to 0x40008cf6
[ 524][V][esp32-hal-uart.c:842] uartBegin(): UART0 initialization done.
[ 530][V][esp32-hal-uart.c:893] uartSetRxFIFOFull(): UART0 RX FIFO Full value set to 120 from a requested value of 120
[ 541][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_RMII (48) successfully set to 0x40000a2a
[ 553][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_CLK (49) successfully set to 0x40000a2a
[ 565][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_MCD (50) successfully set to 0x40000a2a
[ 577][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_MDIO (51) successfully set to 0x40000a2a
[ 588][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type ETHERNET_PWR (52) successfully set to 0x40000a2a
[ 4643][V][ETH.cpp:113] _onEthEvent(): eth0 Started
[ 4643][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 50 successfully set to type ETHERNET_CLK (49) with bus 0x4ff12790
[ 4659][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 1 - ETH_START
ETH Started
[ 4659][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 31 successfully set to type ETHERNET_MCD (50) with bus 0x4ff12790
[ 4679][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 52 successfully set to type ETHERNET_MDIO (51) with bus 0x4ff12790
[ 4690][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 49 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4701][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 34 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4712][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 35 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4724][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 29 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4735][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 30 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4746][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 28 successfully set to type ETHERNET_RMII (48) with bus 0x4ff12790
[ 4757][V][esp32-hal-periman.c:160] perimanSetPinBus(): Pin 51 successfully set to type ETHERNET_PWR (52) with bus 0x4ff12790
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 602584 B ( 588.5 KB)
Free Bytes : 523196 B ( 510.9 KB)
Allocated Bytes : 71644 B ( 70.0 KB)
Minimum Free Bytes: 523020 B ( 510.8 KB)
Largest Free Block: 385012 B ( 376.0 KB)
------------------------------------------
GPIO Info:
------------------------------------------
GPIO : BUS_TYPE[bus/unit][chan]
--------------------------------------
28 : ETHERNET_RMII
29 : ETHERNET_RMII
30 : ETHERNET_RMII
31 : ETHERNET_MCD
34 : ETHERNET_RMII
35 : ETHERNET_RMII
37 : UART_TX[0]
38 : UART_RX[0]
49 : ETHERNET_RMII
50 : ETHERNET_CLK
51 : ETHERNET_PWR
52 : ETHERNET_MDIO
============ After Setup End =============
[ 4643][V][ETH.cpp:113] _onEthEvent(): eth0 Started
LANケーブルで HUBに接続すると、Link Upします。
- IPアドレス取得(DHCP)
- アドレス解決(DNS)
[130644][V][ETH.cpp:103] _onEthEvent(): eth0 Connected
[130649][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 3 - ETH_CONNECTED
ETH Connected
[132156][V][NetworkInterface.cpp:79] _onIpEvent(): eth0 Got New IP: 192.168.0.11 MASK: 255.255.255.0 GW: 192.168.0.1
[132167][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 5 - ETH_GOT_IP
ETH Got IP
*eth0: <UP,100M,FULL_DUPLEX,AUTO,ADDR:0x1> (DHCPC,GARP,IP_MOD) PRIO: 50
ether 30:ED:A0:xx:yy:zz
inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255
gateway 192.168.0.1 dns 192.168.0.1
connecting to google.com
[134913][D][NetworkManager.cpp:83] hostByName(): Clearing DNS cache
[134927][D][NetworkManager.cpp:127] hostByName(): DNS found IPv4 142.250.196.142
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-E45eADk3gX2ovKAAWl5aAw' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
Date: Mon, 19 Jan 2026 08:02:49 GMT
Expires: Wed, 18 Feb 2026 08:02:49 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML></BODY></HTML>
closing connection
(ステータス301ですが、)google.comにアクセスできています。
LANケーブルを抜くと、Link Downします。
[200644][V][ETH.cpp:108] _onEthEvent(): eth0 Disconnected
[200649][V][NetworkEvents.cpp:120] _checkForEvent(): Network Event: 4 - ETH_DISCONNECTED
ETH Disconnected
備忘録としてまとめました。
以上

