0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

0. はじめに

Espressif Systems 謹製のESP32-P4-Function-EV-Board は、RJ45 有線LANポートを有しており、PHYチップに IP101GRIを使用し、ESP32-P4 の次のGPIOに接続されています。

IP101 esp32-p4
MDC GPIO31
MDIO GPIO52
RESET_N
(PHY-POWER)
GPIO51
TX_EN GPIO49
TXD0 GPIO34
TXD1 GPIO35
RXD0 GPIO29
RXD1 GPIO30
RXDV / CRS_DV GPIO28
RXCLK / 50M_CLKO GPIO50

そこで、ESP-IDF の Ethernetサンプルを試してみます。

使用したボードのチップ情報

% esptool --chip esp32p4 --port /dev/cu.usbmodem1201 --baud 460800 flash-id
esptool v5.1.0
Connected to ESP32-P4 on /dev/cu.usbmodem1201:
Chip type:          ESP32-P4 (revision v1.3)
Features:           Dual Core + LP Core, 400MHz
Crystal frequency:  40MHz
USB mode:           USB-Serial/JTAG
MAC:                30:ed:a0:xx:yy:zz

Stub flasher running.
Changing baud rate to 460800...
Changed.

Flash Memory Information:
=========================
Manufacturer: c8
Device: 4018
Detected flash size: 16MB

Hard resetting via RTS pin...

1. esp-idf/examples/ethernet/basic

使用したバージョンは、ESP-IDF v5.4.2
以降は、「ESP-IDF はインストール済み」として進めます。

1.1 コピー

esp-idf/examples/ethernet/basic を適当なフォルダにコピーして使います。

$ cp -r esp-idf/examples/ethernet/basic/ esp/ethernet_basic

1.2 ターゲットの設定

ESP32-P4を指定します。

$ cd esp/ethernet_basic
esp/ethernet_basic$ idf.py set-target esp32p4

1.3 menuconfig

esp/ethernet_basic$ idf.py menuconfig

menuconfig にて、次の4項目を設定します。

1. Component config → Ethernet → Support ESP32 internal EMAC controller → PHY interface (Enable)
2. Component config → Ethernet → Support SPI to Ethernet Module (Disable)
3. Compiler options ---> Optimize for size (-Os with GCC, -Oz with Clang)
4. Partition Table ---> 0x9000

冒頭で説明した GPIOピンを指定するメニューは ありませんでした。

準備は以上です。追加のコンポーネントは必要ありません。

1.4 ビルド

ビルドします。

esp/ethernet_basic$ idf.py build

エラーがなければ、ファームウェア.binが生成されます。

1.5 ファームウェアの書き込み

esptoolで書き込みます。

esp/ethernet_basic$ esptool.py --chip esp32p4 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m \
0x2000 build/bootloader/bootloader.bin \
0x9000 build/partition_table/partition-table.bin \
0x20000 build/ethernet_basic.bin

2. 実行結果

シリアルモニターでログを確認しました。
(ログレベル:Verbose)

V (440) esp_image: segment data length 0x34984 data starts 0x40020
V (446) esp_image: MMU page size 0x10000
V (450) esp_image: segment 4 map_segment 1 segment_data_offs 0x40020 load_addr 0x40000020
I (457) esp_image: segment 4: paddr=00040020 vaddr=40000020 size=34984h (215428) map
D (465) esp_image: free data page_count 0x00000400
D (469) bootloader_flash: rodata starts from paddr=0x00040020, size=0x34984, will be mapped to vaddr=0x40000000
V (479) bootloader_flash: after mapping, starting from paddr=0x00040000 and vaddr=0x40000000, 0x40000 bytes are mapped
V (527) esp_image: loading segment header 5 at offset 0x749a4
D (527) bootloader_flash: mmu set block paddr=0x00070000 (was 0xffffffff)
V (528) esp_image: segment data length 0xdc4 data starts 0x749ac
V (533) esp_image: MMU page size 0x10000
V (537) esp_image: segment 5 map_segment 0 segment_data_offs 0x749ac load_addr 0x4ff0e208
I (545) esp_image: segment 5: paddr=000749ac vaddr=4ff0e208 size=00dc4h (  3524) load
D (552) esp_image: free data page_count 0x00000400
D (557) bootloader_flash: rodata starts from paddr=0x000749ac, size=0xdc4, will be mapped to vaddr=0x40000000
V (566) bootloader_flash: after mapping, starting from paddr=0x00070000 and vaddr=0x40000000, 0x10000 bytes are mapped
V (579) esp_image: image start 0x00020000 end of last section 0x00075770
D (583) bootloader_flash: mmu set block paddr=0x00070000 (was 0xffffffff)
D (590) boot: Calculated hash: ec8b94384331956f3d9ba9f4b02f5bd031a14db28b7795864ed070a19a8d48fc
I (600) boot: Loaded app from partition at offset 0x20000
I (603) boot: Disabling RNG early entropy source...
D (608) boot: calling set_cache_and_start_app
D (612) boot: configure drom and irom and start
V (617) boot: rodata starts from paddr=0x00020020, vaddr=0x40040020, size=0x11d8c
V (623) boot: after mapping rodata, starting from paddr=0x00020000 and vaddr=0x40040000, 0x20000 bytes are mapped
V (633) boot: mapped one page of the rodata, from paddr=0x00020000 and vaddr=0x43ff0000, 0x10000 bytes are mapped
V (643) boot: text starts from paddr=0x00040020, vaddr=0x40000020, size=0x34984
V (650) boot: after mapping text, starting from paddr=0x00040000 and vaddr=0x40000000, 0x40000 bytes are mapped
D (660) boot: start: 0x4ff003f8
I (674) cpu_start: Multicore app
I (685) cpu_start: Pro cpu start user code
I (685) cpu_start: cpu freq: 360000000 Hz
I (685) app_init: Application information:
I (686) app_init: Project name:     ethernet_basic
I (690) app_init: App version:      1
I (693) app_init: Compile time:     Jan 18 2026 12:35:00
I (698) app_init: ELF file SHA256:  5381d3712...
I (702) app_init: ESP-IDF:          v5.4.2
I (706) efuse_init: Min chip rev:     v0.1
I (710) efuse_init: Max chip rev:     v1.99 
I (714) efuse_init: Chip rev:         v1.3
I (718) heap_init: Initializing. RAM available for dynamic allocation:
I (724) heap_init: At 4FF11120 len 00029EA0 (167 KiB): RAM
I (729) heap_init: At 4FF3AFC0 len 00004BF0 (18 KiB): RAM
I (734) heap_init: At 4FF40000 len 00060000 (384 KiB): RAM
I (740) heap_init: At 50108080 len 00007F80 (31 KiB): RTCRAM
I (745) heap_init: At 30100088 len 00001F78 (7 KiB): TCM
I (751) spi_flash: detected chip: generic
I (754) spi_flash: flash io: dio
I (769) main_task: Started on CPU0
I (779) main_task: Calling app_main()
I (819) esp_eth.netif.netif_glue: 30:ed:a0:xx:yy:zz
I (819) esp_eth.netif.netif_glue: ethernet attached to netif
I (4819) eth_example: Ethernet Started
I (4819) main_task: Returned from app_main()

I (4819) eth_example: Ethernet Started
LANケーブルで HUBに接続すると、Link Upします。

I (14819) eth_example: Ethernet Link Up
I (14819) eth_example: Ethernet HW Addr 30:ed:a0:xx:yy:zz
I (16329) esp_netif_handlers: eth ip: 192.168.0.11, mask: 255.255.255.0, gw: 192.168.0.1
I (16329) eth_example: Ethernet Got IP Address
I (16329) eth_example: ~~~~~~~~~~~
I (16329) eth_example: ETHIP:192.168.0.11
I (16329) eth_example: ETHMASK:255.255.255.0
I (16339) eth_example: ETHGW:192.168.0.1
I (16339) eth_example: ~~~~~~~~~~~

PCからpingしてみます。問題ありません。

ping.png

LANケーブルを抜くと、Link Downします。

I (44819) eth_example: Ethernet Link Down



備忘録としてまとめました。
以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?