0023 MP2.5GTPU(M.2 E) EN:修订间差异

来自Mcuzone Wiki
(创建页面,内容为“== '''关键词''' == 树莓派5、PCIe、Switch、RL8125、2.5Gbps、以太网、iperf3测速、TPU、DTPU、驱动安装、操作演示、AI、google、Coral、M.2 E key == '''一、简介''' == 树莓派5具备一个16Pin的PCIe接口,我们可以利用该接口进行多种外设的扩展。这次我们利用PCIe接口,一路为M.2 E key接口,可外接A+E Key接口的TPU模组,一路通过RTL8125芯片2.5Gbps以太网扩展。该扩展板的2.5G以…”)
 
 
(未显示同一用户的7个中间版本)
第1行: 第1行:
== '''关键词''' ==
[[0023 MP2.5GTPU(M.2 E)|切换语言为中文]]
树莓派5、PCIe、Switch、RL8125、2.5Gbps、以太网、iperf3测速、TPU、DTPU、驱动安装、操作演示、AI、google、Coral、M.2 E key


== '''一、简介''' ==
== '''Keywords''' ==
树莓派5具备一个16Pin的PCIe接口,我们可以利用该接口进行多种外设的扩展。这次我们利用PCIe接口,一路为M.2 E key接口,可外接A+E Key接口的TPU模组,一路通过RTL8125芯片2.5Gbps以太网扩展。该扩展板的2.5G以太网在树莓派系统下无需驱动上电后即可自动识别成eth1。如果使用Ubuntu系统则需要先安装RTL8125的驱动才可使用。而Coral M.2加速器是一款M.2尺寸的模组,可以通过PCIE接口为树莓派等平台扩展边缘TPU协处理器。
Raspberry Pi5, PCIe, Switch, RL8125, 2.5Gbps, Ethernet, iperf3 speed test, TPU, DTPU, Driver installation, Operation demonstration, AI, google, Coral, M.2 E key


== '''二、硬件资源''' ==
== '''I. Introduction''' ==
1. 采用0.5mm 16P PCIe线连接树莓派5的PCIE接口;
The Raspberry Pi 5 features a 16-pin PCIe interface, which we can use to expand a variety of peripheral devices.  Now we utilize the PCIe interface, with one is an M.2 E key interface, which can connect to a TPU module with A+E Key. Another expands the Ethernet capability through the RTL8125 chip to 2.5Gbps. The 2.5G Ethernet on this expansion board is automatically recognized as eth1 in the Raspberry Pi OS without requiring any drivers upon power-up. If using the Ubuntu system, you need to install the RTL8125 driver first before it can be used. The Coral M.2 Accelerator is an M.2 sized module that can expand edge TPU coprocessing capabilities via the PCIE interface for platforms such as the Raspberry Pi.


2. 一路PCIe扩展2.5Gbps以太网;
== '''II. Hardware Resources''' ==
1. Use a 0.5mm 16-pin PCIe cable to connect to the PCIE interface of the Raspberry Pi 5.


3. 一路PCIe扩展M.2 E-key接口,用于接Google coral Edge TPU,树莓派官方OS加载驱动;
2. One PCIe expansion for 2.5Gbps Ethernet.


4. 2.5Gbps以太网在树莓派官方OS和Openwrt系统免驱,Ubuntu系统下需安装驱动;
3. One PCIe expansion for M.2 E-key interface, it used to connect to Google Coral Edge TPU, with the Raspberry Pi official OS loading the driver.


5. 采用优质电子元器件和沉金工艺,无铅生产;PCB板通过UL和ROHS认证,防火等级94V-0;
4. The 2.5Gbps Ethernet is driver-free in the Raspberry Pi OS and OpenWrt system, but requires driver installation in Ubuntu system.


6. 四个M2.5固定孔,板子上方内凹设计,方便40Pin GPIO的操作使用;
5. Gold immersion PCB process, lead-free production, certified by UL, compliant with ROHS standards, and has a fire rating of 94V-0.
 
6. The board has four M2.5 mounting holes, with a recessed design on the top of the board to facilitate the use of the 40-Pin GPIO.


http://www.mcuzone.com/wiki/0023_MP2_5GTPU/0023_MP2_5GTPU_01.jpg
http://www.mcuzone.com/wiki/0023_MP2_5GTPU/0023_MP2_5GTPU_01.jpg


== '''三、系统烧写及设置''' ==
== '''III. System flashing and setting''' ==


=== 3.1 概述 ===
=== 3.1 Overview ===
本文档采用树莓派OS、Ubuntu OS和OpenWrt系统进行测试。
This document uses the Raspberry Pi OS, Ubuntu system and OpenWrt system for testing.


1) 树莓派OS的版本为2024-07-04-raspios-bookworm-arm64.img.xz,树莓派OS下载地址:
The version of the Raspberry Pi OS is: 2024-07-04-raspios-bookworm-arm64.img.xz
 
You can download the Raspberry Pi OS in:


https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit
https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit


2) Ubuntu OS的版本为ubuntu-24.04-preinstalled-desktop-arm64+raspi.img.xz,Ubuntu OS下载地址:
'''''Note: If you want to run the TPU module under Raspberry Pi OS, the TF card used for flashing the system should have a space of at least 16GB, otherwise, it will display space errors during the installation and configuration process!'''''
 
The version of the Ubuntu system is: ubuntu-24.04-preinstalled-desktop-arm64+raspi.img.xz
 
You can download the Ubuntu system in:


https://ubuntu.com/download/raspberry-pi
https://ubuntu.com/download/raspberry-pi


3) OpenWrt系统版本为:openwrt-bcm27xx-bcm2712-rpi-5-squashfs-sysupgrade-linux-6.1.100-20240805.img.gz
The version of the OpenWrt system is: openwrt-bcm27xx-bcm2712-rpi-5-squashfs-sysupgrade-linux-6.1.100-20240805.img.gz


=== 3.2 系统烧写在SD(TF)卡上 ===
=== 3.2 System flashed onto the SD (TF) card ===
[[0005 MPS2242 2280 2280P(单SSD扩展板)#3.2 从TF卡启动|点击直达烧写方法说明]]
[[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#3.2 Boot from TF card|Click here to read the instructions for System flashing]]


== '''四、树莓派系统下使用演示''' ==
== '''IV. Raspberry Pi OS operation demonstration''' ==


=== 4.1 Internet网络测试 ===
=== 4.1 Internet test ===
MP2.5GTPU扩展板上的2.5G网口在树莓派OS下免驱 即插即用,系统起来后,在树莓派终端中输入ifconfig -a命令,2.5G网口被识别为eth1:
The 2.5G Ethernet on the MP2.5GTPU expansion board is plug-and-play without requiring drivers in the Raspberry Pi OS. After the system starts, enter the command <code>ifconfig -a</code> in the terminal, and the 2.5G  Ethernet will be recognized as eth1:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_01.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_01.jpg


使用[https://test.ustc.edu.cn/ 中国科技大学测速网站],对2.5G网口连外网(200M宽带)测速,结果如下:
Using [https://test.ustc.edu.cn/ the speed test website of USTC], we conducted a speed test for the 2.5G Ethernet connected to the internet (with a 200M connection), and the results are as follows:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_02.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_02.jpg


'''''注意:网络测速受网络环境和测试方法影响,速度请以实际为准,本测试仅供参考。'''''
'''''Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.'''''


=== 4.2 2.5G内网测试 ===
=== 4.2 2.5G Ethernet test in local network ===
安装网络测速工具iperf3:
Install the network speed testing tool iperf3:


<code>sudo apt install iperf3</code>
<code>sudo apt install iperf3</code>
第58行: 第66行:
http://www.mcuzone.com/wiki/0008_MPS2_5G/0008_MPS2_5G_04.jpg
http://www.mcuzone.com/wiki/0008_MPS2_5G/0008_MPS2_5G_04.jpg


利用iperf3,通过2.5G路由器,在树莓派OS与PC之间进行测速。
Use iperf3 to perform a speed test between the Raspberry Pi OS and the PC via a 2.5G router.


'''eth1测速结果如下:'''
'''The speed test results for eth1 are as follows:'''


当树莓派OS作为client时,速度大约为2.35Gbps:
When the Raspberry Pi OS acts as the client, the speed is about 2.35 Gbps:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_03.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_03.jpg


当树莓派OS作为server时,速度大约为1.82Gbps:
When the Raspberry Pi OS acts as the server, the speed is about 1.82 Gbps:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_04.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_04.jpg


'''''注意:网络测速受网络环境和测试方法影响,速度请以实际为准,本测试仅供参考。'''''
'''''Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.'''''
 
=== 4.3 Fix the MAC address of the 2.5G Ethernet port ===
The 2.5G Ethernet port uses the RTL8125 network card, and during use, the MAC address is not fixed. Each time the device is powered on again, the MAC address changes randomly. The following explains how to set a fixed MAC address for the RTL8125 network card.
 
This explanation also applies to the Ubuntu system.


== '''五、Ubuntu系统下使用演示''' ==
First, check the identification information of the RTL8125 network card in terminal:


=== 5.1 安装Ubuntu系统下RTL8125驱动 ===
<code>ipconfig -a</code>
MP2.5GTPU扩展板上的2.5G网口在Ubuntu系统下不能即插即用,需要安装RTL8125驱动。


因为树莓派5的无线网卡模块在Ubuntu系统下是即插即用的,所以我们需要使用无线网卡连接无线网络:
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_28.jpg
 
Here, the RTL8125 network card is identified as eth1, but in practice, the name recognized by the system might be different.
 
Then input:
 
<code>sudo mousepad /etc/systemd/system/macspoof@eth1.service</code>
 
Or:
 
<code>sudo nano /etc/systemd/system/macspoof@eth1.service</code>
 
eth1 is the name recognized by the system for the network card shown above.
 
Executing the above command will create a new document, then enter the following text:
 
[<code>Unit]</code>
 
<code>Description=MAC Address Change %I</code>
 
<code>Wants=network-pre.target</code>
 
<code>Before=network-pre.target</code>
 
<code>BindsTo=sys-subsystem-net-devices-%i.device</code>
 
<code>After=sys-subsystem-net-devices-%i.device</code>
 
<code>[Service]</code>
 
<code>Type=oneshot</code>
 
<code>ExecStart=/usr/bin/ip link set dev %i address xx:xx:xx:xx:xx:xx</code>
 
<code>ExecStart=/usr/bin/ip link set dev %i up</code>
 
<code>[Install]</code>
 
<code>WantedBy=multi-user.target</code>
 
Here, "xx:xx:xx:xx:xx:xx" represents the MAC address you wish to assign. You can determine it according to the MAC address format (make sure it does not duplicate the MAC address of other network devices). After setting it, save and exit.
 
Then execute the following command to enable the service:
 
<code>sudo systemctl enable macspoof@eth1.service</code>
 
This completes the fixation of the MAC address for eth1.
 
After completing all operations, restart the system. Once the system has finished rebooting, execute <code>ipconfig -a</code> to see that the MAC address has been successfully changed.
 
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_29.jpg
 
== '''V. Ubuntu system operation demonstration''' ==
 
=== 5.1 Install the RTL8125 driver for Ubuntu system ===
The 2.5G Ethernet on the MP2.5GTPU expansion board is not plug-and-play in Ubuntu systems and requires the installation of the RTL8125 driver.
 
Since the wireless network module of the Raspberry Pi 5 is plug-and-play in Ubuntu systems, we need to use it to connect to a wireless network.


http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_11.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_11.jpg


也可以使用网线连接树莓派5上的原生网口。
We can also use an Ethernet cable to connect to the native Ethernet port on the Raspberry Pi 5.


Ubuntu系统默认不安装ifconfig工具,所以需要手动安装:
The ifconfig tool is not installed by default in Ubuntu systems, so it needs to be installed manually:


<code>sudo apt install net-tools</code>
<code>sudo apt install net-tools</code>
第89行: 第158行:
http://www.mcuzone.com/wiki/0008_MPS2_5G/0008_MPS2_5G_13.jpg
http://www.mcuzone.com/wiki/0008_MPS2_5G/0008_MPS2_5G_13.jpg


输入<code>ifconfig -a</code>,可见此时并没有显示2.5G网卡:
Enter <code>ifconfig -a</code>, and we can see that the 2.5G Ethernet is not displayed at this time:


http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_12.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_12.jpg


接下来我们开始安装RTL8125驱动。
Then we will begin installing the RTL8125 driver.


首先需要更新系统:
First, we need to update the system:


<code>sudo apt-get update</code>
<code>sudo apt-get update</code>
第101行: 第170行:
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_13.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_13.jpg


接着准备编译环境:
Then we need to prepare the compilation environment:


<code>sudo apt-get install --reinstall linux-headers-$(uname -r) linux-headers-generic build-essential dkms</code>
<code>sudo apt-get install --reinstall linux-headers-$(uname -r) linux-headers-generic build-essential dkms</code>
第107行: 第176行:
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_14.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_14.jpg


然后安装驱动:
And install drivers:


<code>sudo apt-get install r8125-dkms</code>
<code>sudo apt-get install r8125-dkms</code>
按提示安装即可:


http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_15.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_15.jpg


安装完成后输入:
After installation is complete, enter:


<code>sudo modprobe r8125</code>
<code>sudo modprobe r8125</code>
第121行: 第188行:
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_16.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_16.jpg


输入<code>ifconfig -a</code>就可以看到一个enxxx的网卡接口,这样就安装完毕2.5G网卡驱动:
Enter <code>ifconfig -a</code> to see a network interface named enxxx, which indicates that the 2.5G Ethernet driver has been successfully installed.


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_05.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_05.jpg


=== 5.2 Internet网络测试 ===
=== 5.2 Internet test ===
将2.5G网口连外网(200M宽带)测速,结果如下:
Using [https://test.ustc.edu.cn/ the speed test website of USTC], we conducted a speed test for the 2.5G Ethernet connected to the internet (with a 200M connection), and the results are as follows:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_06.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_06.jpg


'''''注意:网络测速受网络环境和测试方法影响,速度请以实际为准,本测试仅供参考。'''''
'''''Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.'''''


如果使用Ubuntu内置的Firefox浏览器时运行速度很慢或者经常无响应,建议安装轻量浏览器Falkon:
If the built-in Firefox browser in Ubuntu runs very slowly or frequently becomes unresponsive, it is recommended to install the lightweight browser Falkon:


<code>sudo apt install falkon</code>
<code>sudo apt install falkon</code>


=== 5.3 2.5G内网测试 ===
=== 5.3 2.5G Ethernet test in local network ===
安装网络测速软件iperf3:
Install the network speed testing tool iperf3:


<code>sudo apt install iperf3</code>
<code>sudo apt install iperf3</code>
第143行: 第210行:
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_20.jpg
http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_20.jpg


利用iperf3,在Ubuntu系统与PC之间进行测速。
Use iperf3 to perform a speed test between the Raspberry Pi OS and the PC via a 2.5G router.


'''测速结果如下:'''
'''The speed test results for eth1 are as follows:'''


当Ubuntu系统作为client时,速度大约为2.35Gbps:
When the Ubuntu system acts as the client, the speed is about 2.35 Gbps:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_07.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_07.jpg


当Ubuntu系统作为server时,速度大约为1.85Gbps:
When the Ubuntu system acts as the server, the speed is about 1.85 Gbps:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_08.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_08.jpg


'''''注意:网络测速受网络环境和测试方法影响,速度请以实际为准,本测试仅供参考。'''''
'''''Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.'''''
 
== '''六、OpenWrt系统操作演示''' ==


=== 6.1 概述 ===
== '''VI. OpenWrt system operation demonstration''' ==
MP2.5G扩展板在OpenWrt系统下,默认树莓派上的原生千兆网口为LAN口,我们可以把扩展板上的2.5G网口作为LAN口,而把树莓派5上的原生网口作为WAN口,这样就能利用2.5G网口在内网高速传输文件。


=== 6.2 准备工作 ===
=== 6.1 Overview ===
本文档使用的OpenWrt系统为:openwrt-bcm27xx-bcm2712-rpi-5-squashfs-sysupgrade-linux-6.1.100-20240805.img.gz
Under the OpenWrt system, the MP2.5GTPU expansion board defaults to the native Gigabit Ethernet port on the Raspberry Pi as the LAN port. We can use the 2.5G Ethernet on the expansion board as a LAN port and the native Ethernet on the Raspberry Pi 5 as a WAN port, thereby enabling high-speed file transfers within the local network using the 2.5G Ethernet.


烧写OpenWrt系统并上电启动后,我们将网线一端插在树莓派5的原生网口上,另一端插在PC上,待PC的网卡与树莓派5上的网口连接成功后,我们在Windows设置中找到网络和Internet,在以太网中打开连接的网络查看默认网关的IP地址,这个地址就是OpenWrt系统的后台配置页面地址,如图所示,本文测试的地址为192.168.198.1:
=== 6.2 Preparations ===
After flashing the OpenWrt system and powering the board on, we connect the Ethernet cable from the native Gigabit Ethernet port on the Raspberry Pi to the PC's Ethernet port. After the PC's network card successfully connects to the native Gigabit Ethernet port on the Raspberry Pi, we can find Network & Internet settings in the Windows settings. In the Ethernet open the "Change adapter options - Ethernet - Status" and view the IP address of the default gateway; this address is the backend configuration page address for the OpenWrt system. As shown in the figure, the address tested in this document is 192.168.198.1:


http://www.mcuzone.com/wiki/2001_CM4_Ultra/2001_CM4_Ultra_53.jpg
http://www.mcuzone.com/wiki/2001_CM4_Ultra/2001_CM4_Ultra_53.jpg


然后打开网页浏览器输入192.168.198.1进入OpenWrt系统。默认用户名为<code>root</code>,默认密码为<code>password</code>
Then open a web browser and enter 192.168.198.1 to access the OpenWrt system. The default username is <code>root</code>, and the default password is <code>password</code>.


http://www.mcuzone.com/wiki/2001_CM4_Ultra/2001_CM4_Ultra_54.jpg
http://www.mcuzone.com/wiki/2001_CM4_Ultra/2001_CM4_Ultra_54.jpg


=== 6.3 MP2.5G的2.5G网口的配置和应用 ===
=== 6.3 Configuration and application of the 2.5G Ethernet on the MP2.5GTPU ===
进入“系统 - TTYD终端”,输入ifconfig -a命令,可以看到有eth0和eth1两个网口,其中eth0为树莓派5的原生网口,eth1为扩展板的2.5G网口:
Click "System - TTYD Terminal" and enter the command <code>ifconfig -a</code>. We can see that there are two network interfaces: eth0 and eth1. eth0 is the native Ethernet port of the Raspberry Pi 5, and eth1 is the 2.5G Ethernet port of the expansion board:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_09.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_09.jpg


我们使用的宽带一般不会超过千兆,为了获得更好的内网性能,建议将树莓派5的原生千兆配置从默认的LAN配置为WAN,然后把扩展板的2.5G以太网口配置为LAN。
The broadband we typically use does not exceed one gigabit. To achieve better local network performance, it is recommended to configure the Raspberry Pi 5's native Gigabit Ethernet port from its default LAN setting to WAN, and then configure the expansion board's 2.5G Ethernet port as LAN.


点击“网络 - 接口”,点击“修改”:
Click on "Network - Interfaces", then click "Modify":


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_10.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_10.jpg


在“物理设置”中,把eth1选中,然后点击“保存&应用”按钮:
In the "Physical Settings", select eth1 and then click the "Save & Apply" button:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_11.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_11.jpg


将网线从树莓派5的原生网口中拔出,插入2.5G网口,待PC的网卡与2.5G网口连接成功后,我们刷新管理页面,点击“网络 - 接口”,点击“修改”:
Remove the Ethernet cable from the native port of the Raspberry Pi 5 and insert it into the 2.5G Ethernet port. After the PC's network card successfully connects to the 2.5G Ethernet, we refresh the management page, click on "Network - Interfaces", and then click "Edit":


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_12.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_12.jpg


在“物理设置”中,把eth0前面的勾去掉,然后点击“保存”按钮:
In the "Physical Settings", uncheck eth0, and then click the "Save" button:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_13.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_13.jpg


回到“网络 - 接口”,点击“添加新接口”:
Go back to "Network - Interfaces", and click "Add New Interface":


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_14.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_14.jpg


接口名称设置为WAN,接口协议选择DHCP客户端,接口选择eth0后点击“提交”按钮:
Set the interface name to WAN, select DHCP client for the interface protocol, choose eth0 for the interface, and then click the "Submit" button:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_15.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_15.jpg


在防火墙设置中选择WAN口后点击“保存&应用”按钮:
In the firewall settings, select the WAN and then click the "Save & Apply" button:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_16.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_16.jpg


把连接Internet网络的网线插到树莓派5的原生网口上,然后回到“网络 - 接口”,稍等片刻,就可以看见新建的WAN接口获取了IP地址,这样PC就可以通过连接2.5G网口进入内网上网了,此时网络结构为千兆网口(接Internet,树莓派上)进,2.5G网口(接内网,扩展板上)出:
Plug the network cable connected to the Internet into the native Ethernet port of the Raspberry Pi 5, then go back to "Network - Interfaces". After a moment, we will see that the newly created WAN interface has obtained an IP address. The PC can access the internal network through the connected 2.5G Ethernet port. At this time, the network structure is such that the Gigabit Ethernet port (connected to the Internet, on the Raspberry Pi) is the input, and the 2.5G Ethernet port (connected to the internal network, on the expansion board) is the output:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_17.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_17.jpg


我们在树莓派5的USB3.0接口上插入一个支持USB3.0的U盘或者移动硬盘,参考下面链接,将这个U盘或者移动硬盘配置为共享目录:
We insert a USB3.0 supported USB drive or mobile hard disk into the USB3.0 port of the Raspberry Pi 5. Refer to the link below to configure this USB drive or external hard drive as a shared directory:


[[2001 CM4 Ultra(CM4核心板的扩展板)#5.5 SSD硬盘测试|设置SSD硬盘为共享目录]]
[[2001 CM4 Ultra(CM4核心板的扩展板)#5.5 SSD硬盘测试|设置SSD硬盘为共享目录]]


设置完毕后,我们在资源管理器中输入<code>\\192.168.198.1</code>(地址为扩展板的地址,视实际情况而不同),就能看到所映射的共享目录了:
After setting it up, we enter <code>\\192.168.198.1</code> in the File Explorer (The address is that of the expansion board, which may vary depending on the actual situation),  and we will then be able to see the shared directory:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_18.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_18.jpg


将任意文件拖拽到桌面进行读取速度测试:
Copy any file to the desktop for a read speed test:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_19.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_19.jpg


将任意文件拖拽到SSD进行写入速度测试:
Copy any file to the SSD for a write speed test:


http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_20.jpg
http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_20.jpg


'''''注意:网络测速受网络环境和测试方法影响,速度请以实际为准,本测试仅供参考。'''''
'''''Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.'''''
 
=== 6.4 Other applications ===
The wireless module of the Raspberry Pi 5 can function as a wireless AP or as a wireless WAN port. For the implementation of these applications, please refer to the following link:


=== 6.4 其它应用 ===
[[0008 MPS2.5G(SSD和2.5G以太网)#6.4 树莓派自带WiFI做无线AP(master模式)使用|树莓派自带WiFI做无线AP(master模式)使用]]
树莓派5的无线模块可以作为无线AP,也可以作为无线WAN口,关于这些应用的实现,请参考下列链接:


[[0008 MPS2.5G(SSD和2.5G以太网)#6.4 树莓派5的无线模块作为无线AP|树莓派5的无线模块作为无线AP]]
[[0008 MPS2.5G(SSD和2.5G以太网)#6.5 树莓派自带WiFi做Client使用|树莓派自带WiFi做Client使用]]


[[0008 MPS2.5G(SSD和2.5G以太网)#6.5 PC通过树莓派5的无线模块上网|PC通过树莓派5的无线模块上网]]
== '''VII. Run the TPU module on Raspberry Pi OS''' ==
This chapter introduces how to run the TPU module on the Raspberry Pi OS.


== '''七、树莓派OS运行TPU模组''' ==
'''''Note: The operation requires a stable internet connection to the regions out of China (you may need to find your own method). Otherwise, many files may not download or may only partially download, which could ultimately lead to the code failing to run.'''''
本章介绍如何在树莓派OS运行TPU模组。


=== 7.1 配置config.txt ===
=== 7.1 Config config.txt ===
系统启动后打开树莓派终端输入命令:
After the system boots, open the Raspberry Pi terminal and enter the command:


<code>sudo nano /boot/firmware/config.txt</code>
<code>sudo nano /boot/firmware/config.txt</code>


或者:
Or:


<code>sudo mousepad /boot/firmware/config.txt</code>
<code>sudo mousepad /boot/firmware/config.txt</code>


在文件最下方添加以下代码:
Add the codes in the ending of this file:


<code>dtparam=pciex1</code>
<code>dtparam=pciex1</code>
第261行: 第328行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_02.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_02.jpg


代码添加成功后,保存并重启系统:
Then, save the file and reboot the system:


<code>sudo reboot</code>
<code>sudo reboot</code>


=== 7.2 确认软件环境 ===
=== 7.2 Ensuring software environment ===
系统重启后打开打开树莓派终端输入命令:
After reboot the system, open the Raspberry Pi terminal and enter the command:


<code>uname -r</code>
<code>uname -r</code>


确保内核版本大于4.18后输入:
After ensuring the kernel version is greater than 4.18, enter:


<code>lsmod | grep apex</code>
<code>lsmod | grep apex</code>


确保没有输出则可以开始安装TPU驱动。
Ensure there is no output, then you can begin installing the TPU driver.


http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_03.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_03.jpg


=== 7.3 安装必要软件 ===
=== 7.3 Install necessary software ===
确保网络能连通外网(需自备方法)后,添加Google TPU软件库:
Ensure the network is connected to internet connection to the regions out of China (you may need to find your own method), and then add the Google TPU software library:


<code>echo "deb <nowiki>https://packages.cloud.google.com/apt</nowiki> coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list</code>
<code>echo "deb <nowiki>https://packages.cloud.google.com/apt</nowiki> coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list</code>
第287行: 第354行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_04.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_04.jpg


添加完成后更新软件列表:
Update the software list after adding:


<code>sudo apt-get update</code>
<code>sudo apt-get update</code>
第293行: 第360行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_06.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_06.jpg


更新完成后安装必要的软件:
Install the necessary software after the update is completed:


<code>sudo apt-get install cmake libedgetpu1-std devscripts debhelper dkms dh-dkms</code>
<code>sudo apt-get install cmake libedgetpu1-std devscripts debhelper dkms dh-dkms</code>
第301行: 第368行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_08.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_08.jpg


=== 7.4 安装Gasket Driver ===
=== 7.4 Install Gasket Driver ===
依次输入以下命令安装Gasket Driver:
Enter the following commands in sequence to install the Gasket Driver:


<code>git clone <nowiki>https://github.com/google/gasket-driver.git</nowiki></code>
<code>git clone <nowiki>https://github.com/google/gasket-driver.git</nowiki></code>
第320行: 第387行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_11.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_11.jpg


安装完成后输入以下命令确保驱动以及软件安装成功:
After the installation is complete, enter the following command to ensure that the driver and software were installed successfully:


<code>sudo apt-get install gasket-dkms libedgetpu1-std</code>
<code>sudo apt-get install gasket-dkms libedgetpu1-std</code>
第326行: 第393行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_12.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_12.jpg


接下来添加udev rule去获得设备操作权限:
Then, add a udev rule to obtain device operation permissions:


<code>sudo sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules"</code>
<code>sudo sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules"</code>


添加用户到apex:
add user to apex:


<code>sudo groupadd apex</code>
<code>sudo groupadd apex</code>
第338行: 第405行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_13.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_13.jpg


设置完成后重启系统:
Reboot the system after the setup is complete:


<code>sudo reboot</code>
<code>sudo reboot</code>


=== 7.5 验证模块检测以及驱动安装 ===
=== 7.5 Verification module testing and driver installation ===
系统启动后验证模块检测以及驱动安装:
After system starting, verification module testing and driver installation:


<code>lspci -nn | grep 089a</code>
<code>lspci -nn | grep 089a</code>


这里需要看到TPU模块,如下图所示(具体参数显示以实际为准):
Here, you need to see the TPU module, as shown in the following figure (specific parameter display is subject to the actual device):


<code>ls /dev/apex_0</code>
<code>ls /dev/apex_0</code>
第353行: 第420行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_14.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_14.jpg


这里插了一个TPU模块,因此可以看到一个TPU模块。
This board has a single TPU onboard, so you can see a TPU module:


输入<code>sudo lspci -v</code>可以看到驱动加载,其中必须包括TPU驱动,如果插了SSD硬盘,还需要包括SSD模块,如下图所示:
By entering <code>sudo lspci -v</code>, you can see the driver loading, this must include the TPU driver, and if an SSD is inserted, it also needs to include the SSD module, as shown in the following figure:


http://www.mcuzone.com/wiki/0013_MPTPU_M/0013_MPTPU_M_01.jpg
http://www.mcuzone.com/wiki/0013_MPTPU_M/0013_MPTPU_M_01.jpg


=== 7.6 代码运行环境配置 ===
=== 7.6 Configuration of the Code Execution Environment ===
Google TPU模块代码运行需要在Python3.6-3.9之间,而树莓派最新系统的Python版本为3.11,因此我们需要使用Pyenv来下载老版本Python。
Running Google TPU module code requires Python versions between 3.6 and 3.9, while the latest Raspberry Pi system is Python 3.11. Therefore, we need to use Pyenv to download an older version of Python.


首先进行依赖安装:
First, install the depends:


<code>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl</code>
<code>sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl</code>
第370行: 第437行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_18.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_18.jpg


依赖安装完成后进行pyenv的安装:
Install pyenv after the depends are installed:


<code>curl <nowiki>https://pyenv.run</nowiki> | bash</code>
<code>curl <nowiki>https://pyenv.run</nowiki> | bash</code>
第376行: 第443行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_19.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_19.jpg


输入:
Enter the command:


<code>sudo nano ~/.bashrc</code>
<code>sudo nano ~/.bashrc</code>


或者:
Or:


<code>sudo mousepad ~/.bashrc</code>
<code>sudo mousepad ~/.bashrc</code>


在文件最下面添加以下代码:
Add the codes in the ending of this file:


<code>export PYENV_ROOT="$HOME/.pyenv"</code>
<code>export PYENV_ROOT="$HOME/.pyenv"</code>
第396行: 第463行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_21.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_21.jpg


添加完成后保存退出并重新加载shell:
Save and exit after adding, then reload the shell:


<code>exec "$SHELL"</code>
<code>exec "$SHELL"</code>
第402行: 第469行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_22.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_22.jpg


接下来我们可以利用pyenv安装老系统版本Python:
Then, we can use pyenv to install an older version of Python:


<code>pyenv install -v 3.8.8</code>
<code>pyenv install -v 3.8.8</code>
第410行: 第477行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_24.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_24.jpg


等待安装成功后我们将系统Python版本更改为3.8.8:
After the installation is successful, we will change the system Python version to 3.8.8:


<code>pyenv global 3.8.8</code>
<code>pyenv global 3.8.8</code>


更改成功后可以查看当前Python使用版本为3.8.8:
After the change is successful, you can check the current Python version is 3.8.8:


<code>pyenv versions</code>
<code>pyenv versions</code>
第422行: 第489行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_25.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_25.jpg


=== 7.7 下载代码和运行模组 ===
=== 7.7 Download the code and run the module ===
依次输入以下命令进行下载:
Enter the following commands in sequence to download:


<code>mkdir coral && cd coral</code>
<code>mkdir coral && cd coral</code>
第439行: 第506行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_27.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_27.jpg


接下来下载代码运行模组
Then, download the code and run the module:


<code>pip3 install numpy</code>
<code>pip3 install numpy</code>
第453行: 第520行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_30.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_30.jpg


=== 7.8 运行代码 ===
=== 7.8 Run the code ===
模组下载完成后返回 coral/pycoral路径下
After the module download is complete, back to the coral/pycoral path:


<code>cd ..</code>
<code>cd ..</code>


输入以下代码进行代码运行
Enter the following code to run it:


http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_39.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_39.jpg


注意:我们可以复制下列代码,但是请先粘贴到文本软件中,按照上图的格式,删除多余的回车符,再复制然后粘贴到终端中运行:
Note: You can copy the following code, but please paste it into a text editor first. Then, following the format shown above, remove any extra enter. After that, copy it again and paste it into the terminal to run.


<code>python3 examples/classify_image.py \</code>
<code>python3 examples/classify_image.py \</code>
第474行: 第541行:
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_31.jpg
http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_31.jpg


{{联系我们_图标}}
{{Contact_Us_icon}}

2024年10月14日 (一) 09:16的最新版本

切换语言为中文

Keywords

Raspberry Pi5, PCIe, Switch, RL8125, 2.5Gbps, Ethernet, iperf3 speed test, TPU, DTPU, Driver installation, Operation demonstration, AI, google, Coral, M.2 E key

I. Introduction

The Raspberry Pi 5 features a 16-pin PCIe interface, which we can use to expand a variety of peripheral devices. Now we utilize the PCIe interface, with one is an M.2 E key interface, which can connect to a TPU module with A+E Key. Another expands the Ethernet capability through the RTL8125 chip to 2.5Gbps. The 2.5G Ethernet on this expansion board is automatically recognized as eth1 in the Raspberry Pi OS without requiring any drivers upon power-up. If using the Ubuntu system, you need to install the RTL8125 driver first before it can be used. The Coral M.2 Accelerator is an M.2 sized module that can expand edge TPU coprocessing capabilities via the PCIE interface for platforms such as the Raspberry Pi.

II. Hardware Resources

1. Use a 0.5mm 16-pin PCIe cable to connect to the PCIE interface of the Raspberry Pi 5.

2. One PCIe expansion for 2.5Gbps Ethernet.

3. One PCIe expansion for M.2 E-key interface, it used to connect to Google Coral Edge TPU, with the Raspberry Pi official OS loading the driver.

4. The 2.5Gbps Ethernet is driver-free in the Raspberry Pi OS and OpenWrt system, but requires driver installation in Ubuntu system.

5. Gold immersion PCB process, lead-free production, certified by UL, compliant with ROHS standards, and has a fire rating of 94V-0.

6. The board has four M2.5 mounting holes, with a recessed design on the top of the board to facilitate the use of the 40-Pin GPIO.

0023_MP2_5GTPU_01.jpg

III. System flashing and setting

3.1 Overview

This document uses the Raspberry Pi OS, Ubuntu system and OpenWrt system for testing.

The version of the Raspberry Pi OS is: 2024-07-04-raspios-bookworm-arm64.img.xz

You can download the Raspberry Pi OS in:

https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit

Note: If you want to run the TPU module under Raspberry Pi OS, the TF card used for flashing the system should have a space of at least 16GB, otherwise, it will display space errors during the installation and configuration process!

The version of the Ubuntu system is: ubuntu-24.04-preinstalled-desktop-arm64+raspi.img.xz

You can download the Ubuntu system in:

https://ubuntu.com/download/raspberry-pi

The version of the OpenWrt system is: openwrt-bcm27xx-bcm2712-rpi-5-squashfs-sysupgrade-linux-6.1.100-20240805.img.gz

3.2 System flashed onto the SD (TF) card

Click here to read the instructions for System flashing

IV. Raspberry Pi OS operation demonstration

4.1 Internet test

The 2.5G Ethernet on the MP2.5GTPU expansion board is plug-and-play without requiring drivers in the Raspberry Pi OS. After the system starts, enter the command ifconfig -a in the terminal, and the 2.5G Ethernet will be recognized as eth1:

0015_MP2_5G_01.jpg

Using the speed test website of USTC, we conducted a speed test for the 2.5G Ethernet connected to the internet (with a 200M connection), and the results are as follows:

0015_MP2_5G_02.jpg

Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.

4.2 2.5G Ethernet test in local network

Install the network speed testing tool iperf3:

sudo apt install iperf3

0008_MPS2_5G_04.jpg

Use iperf3 to perform a speed test between the Raspberry Pi OS and the PC via a 2.5G router.

The speed test results for eth1 are as follows:

When the Raspberry Pi OS acts as the client, the speed is about 2.35 Gbps:

0015_MP2_5G_03.jpg

When the Raspberry Pi OS acts as the server, the speed is about 1.82 Gbps:

0015_MP2_5G_04.jpg

Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.

4.3 Fix the MAC address of the 2.5G Ethernet port

The 2.5G Ethernet port uses the RTL8125 network card, and during use, the MAC address is not fixed. Each time the device is powered on again, the MAC address changes randomly. The following explains how to set a fixed MAC address for the RTL8125 network card.

This explanation also applies to the Ubuntu system.

First, check the identification information of the RTL8125 network card in terminal:

ipconfig -a

0015_MP2_5G_28.jpg

Here, the RTL8125 network card is identified as eth1, but in practice, the name recognized by the system might be different.

Then input:

sudo mousepad /etc/systemd/system/macspoof@eth1.service

Or:

sudo nano /etc/systemd/system/macspoof@eth1.service

eth1 is the name recognized by the system for the network card shown above.

Executing the above command will create a new document, then enter the following text:

[Unit]

Description=MAC Address Change %I

Wants=network-pre.target

Before=network-pre.target

BindsTo=sys-subsystem-net-devices-%i.device

After=sys-subsystem-net-devices-%i.device

[Service]

Type=oneshot

ExecStart=/usr/bin/ip link set dev %i address xx:xx:xx:xx:xx:xx

ExecStart=/usr/bin/ip link set dev %i up

[Install]

WantedBy=multi-user.target

Here, "xx:xx:xx:xx:xx:xx" represents the MAC address you wish to assign. You can determine it according to the MAC address format (make sure it does not duplicate the MAC address of other network devices). After setting it, save and exit.

Then execute the following command to enable the service:

sudo systemctl enable macspoof@eth1.service

This completes the fixation of the MAC address for eth1.

After completing all operations, restart the system. Once the system has finished rebooting, execute ipconfig -a to see that the MAC address has been successfully changed.

0015_MP2_5G_29.jpg

V. Ubuntu system operation demonstration

5.1 Install the RTL8125 driver for Ubuntu system

The 2.5G Ethernet on the MP2.5GTPU expansion board is not plug-and-play in Ubuntu systems and requires the installation of the RTL8125 driver.

Since the wireless network module of the Raspberry Pi 5 is plug-and-play in Ubuntu systems, we need to use it to connect to a wireless network.

0009_MP2_5GD_11.jpg

We can also use an Ethernet cable to connect to the native Ethernet port on the Raspberry Pi 5.

The ifconfig tool is not installed by default in Ubuntu systems, so it needs to be installed manually:

sudo apt install net-tools

0008_MPS2_5G_13.jpg

Enter ifconfig -a, and we can see that the 2.5G Ethernet is not displayed at this time:

0009_MP2_5GD_12.jpg

Then we will begin installing the RTL8125 driver.

First, we need to update the system:

sudo apt-get update

0009_MP2_5GD_13.jpg

Then we need to prepare the compilation environment:

sudo apt-get install --reinstall linux-headers-$(uname -r) linux-headers-generic build-essential dkms

0009_MP2_5GD_14.jpg

And install drivers:

sudo apt-get install r8125-dkms

0009_MP2_5GD_15.jpg

After installation is complete, enter:

sudo modprobe r8125

0009_MP2_5GD_16.jpg

Enter ifconfig -a to see a network interface named enxxx, which indicates that the 2.5G Ethernet driver has been successfully installed.

0015_MP2_5G_05.jpg

5.2 Internet test

Using the speed test website of USTC, we conducted a speed test for the 2.5G Ethernet connected to the internet (with a 200M connection), and the results are as follows:

0015_MP2_5G_06.jpg

Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.

If the built-in Firefox browser in Ubuntu runs very slowly or frequently becomes unresponsive, it is recommended to install the lightweight browser Falkon:

sudo apt install falkon

5.3 2.5G Ethernet test in local network

Install the network speed testing tool iperf3:

sudo apt install iperf3

0009_MP2_5GD_20.jpg

Use iperf3 to perform a speed test between the Raspberry Pi OS and the PC via a 2.5G router.

The speed test results for eth1 are as follows:

When the Ubuntu system acts as the client, the speed is about 2.35 Gbps:

0015_MP2_5G_07.jpg

When the Ubuntu system acts as the server, the speed is about 1.85 Gbps:

0015_MP2_5G_08.jpg

Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.

VI. OpenWrt system operation demonstration

6.1 Overview

Under the OpenWrt system, the MP2.5GTPU expansion board defaults to the native Gigabit Ethernet port on the Raspberry Pi as the LAN port. We can use the 2.5G Ethernet on the expansion board as a LAN port and the native Ethernet on the Raspberry Pi 5 as a WAN port, thereby enabling high-speed file transfers within the local network using the 2.5G Ethernet.

6.2 Preparations

After flashing the OpenWrt system and powering the board on, we connect the Ethernet cable from the native Gigabit Ethernet port on the Raspberry Pi to the PC's Ethernet port. After the PC's network card successfully connects to the native Gigabit Ethernet port on the Raspberry Pi, we can find Network & Internet settings in the Windows settings. In the Ethernet open the "Change adapter options - Ethernet - Status" and view the IP address of the default gateway; this address is the backend configuration page address for the OpenWrt system. As shown in the figure, the address tested in this document is 192.168.198.1:

2001_CM4_Ultra_53.jpg

Then open a web browser and enter 192.168.198.1 to access the OpenWrt system. The default username is root, and the default password is password.

2001_CM4_Ultra_54.jpg

6.3 Configuration and application of the 2.5G Ethernet on the MP2.5GTPU

Click "System - TTYD Terminal" and enter the command ifconfig -a. We can see that there are two network interfaces: eth0 and eth1. eth0 is the native Ethernet port of the Raspberry Pi 5, and eth1 is the 2.5G Ethernet port of the expansion board:

0015_MP2_5G_09.jpg

The broadband we typically use does not exceed one gigabit. To achieve better local network performance, it is recommended to configure the Raspberry Pi 5's native Gigabit Ethernet port from its default LAN setting to WAN, and then configure the expansion board's 2.5G Ethernet port as LAN.

Click on "Network - Interfaces", then click "Modify":

0015_MP2_5G_10.jpg

In the "Physical Settings", select eth1 and then click the "Save & Apply" button:

0015_MP2_5G_11.jpg

Remove the Ethernet cable from the native port of the Raspberry Pi 5 and insert it into the 2.5G Ethernet port. After the PC's network card successfully connects to the 2.5G Ethernet, we refresh the management page, click on "Network - Interfaces", and then click "Edit":

0015_MP2_5G_12.jpg

In the "Physical Settings", uncheck eth0, and then click the "Save" button:

0015_MP2_5G_13.jpg

Go back to "Network - Interfaces", and click "Add New Interface":

0015_MP2_5G_14.jpg

Set the interface name to WAN, select DHCP client for the interface protocol, choose eth0 for the interface, and then click the "Submit" button:

0015_MP2_5G_15.jpg

In the firewall settings, select the WAN and then click the "Save & Apply" button:

0015_MP2_5G_16.jpg

Plug the network cable connected to the Internet into the native Ethernet port of the Raspberry Pi 5, then go back to "Network - Interfaces". After a moment, we will see that the newly created WAN interface has obtained an IP address. The PC can access the internal network through the connected 2.5G Ethernet port. At this time, the network structure is such that the Gigabit Ethernet port (connected to the Internet, on the Raspberry Pi) is the input, and the 2.5G Ethernet port (connected to the internal network, on the expansion board) is the output:

0015_MP2_5G_17.jpg

We insert a USB3.0 supported USB drive or mobile hard disk into the USB3.0 port of the Raspberry Pi 5. Refer to the link below to configure this USB drive or external hard drive as a shared directory:

设置SSD硬盘为共享目录

After setting it up, we enter \\192.168.198.1 in the File Explorer (The address is that of the expansion board, which may vary depending on the actual situation), and we will then be able to see the shared directory:

0015_MP2_5G_18.jpg

Copy any file to the desktop for a read speed test:

0015_MP2_5G_19.jpg

Copy any file to the SSD for a write speed test:

0015_MP2_5G_20.jpg

Note: The speed test can be affected by the network environment and the testing method. Speeds should be considered based on actual results; this test is for reference only.

6.4 Other applications

The wireless module of the Raspberry Pi 5 can function as a wireless AP or as a wireless WAN port. For the implementation of these applications, please refer to the following link:

树莓派自带WiFI做无线AP(master模式)使用

树莓派自带WiFi做Client使用

VII. Run the TPU module on Raspberry Pi OS

This chapter introduces how to run the TPU module on the Raspberry Pi OS.

Note: The operation requires a stable internet connection to the regions out of China (you may need to find your own method). Otherwise, many files may not download or may only partially download, which could ultimately lead to the code failing to run.

7.1 Config config.txt

After the system boots, open the Raspberry Pi terminal and enter the command:

sudo nano /boot/firmware/config.txt

Or:

sudo mousepad /boot/firmware/config.txt

Add the codes in the ending of this file:

dtparam=pciex1

kernel=kernel8.img

dtoverlay=pineboards-hat-ai

0006_MPW7_TPU_01.jpg

0006_MPW7_TPU_02.jpg

Then, save the file and reboot the system:

sudo reboot

7.2 Ensuring software environment

After reboot the system, open the Raspberry Pi terminal and enter the command:

uname -r

After ensuring the kernel version is greater than 4.18, enter:

lsmod | grep apex

Ensure there is no output, then you can begin installing the TPU driver.

0006_MPW7_TPU_03.jpg

7.3 Install necessary software

Ensure the network is connected to internet connection to the regions out of China (you may need to find your own method), and then add the Google TPU software library:

echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

0006_MPW7_TPU_04.jpg

Update the software list after adding:

sudo apt-get update

0006_MPW7_TPU_06.jpg

Install the necessary software after the update is completed:

sudo apt-get install cmake libedgetpu1-std devscripts debhelper dkms dh-dkms

0006_MPW7_TPU_07.jpg

0006_MPW7_TPU_08.jpg

7.4 Install Gasket Driver

Enter the following commands in sequence to install the Gasket Driver:

git clone https://github.com/google/gasket-driver.git

cd gasket-driver

sudo debuild -us -uc -tc -b

cd ..

sudo dpkg -i gasket-dkms_1.0-18_all.deb

0006_MPW7_TPU_09.jpg

0006_MPW7_TPU_10.jpg

0006_MPW7_TPU_11.jpg

After the installation is complete, enter the following command to ensure that the driver and software were installed successfully:

sudo apt-get install gasket-dkms libedgetpu1-std

0006_MPW7_TPU_12.jpg

Then, add a udev rule to obtain device operation permissions:

sudo sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules"

add user to apex:

sudo groupadd apex

sudo adduser $USER apex

0006_MPW7_TPU_13.jpg

Reboot the system after the setup is complete:

sudo reboot

7.5 Verification module testing and driver installation

After system starting, verification module testing and driver installation:

lspci -nn | grep 089a

Here, you need to see the TPU module, as shown in the following figure (specific parameter display is subject to the actual device):

ls /dev/apex_0

0006_MPW7_TPU_14.jpg

This board has a single TPU onboard, so you can see a TPU module:

By entering sudo lspci -v, you can see the driver loading, this must include the TPU driver, and if an SSD is inserted, it also needs to include the SSD module, as shown in the following figure:

0013_MPTPU_M_01.jpg

7.6 Configuration of the Code Execution Environment

Running Google TPU module code requires Python versions between 3.6 and 3.9, while the latest Raspberry Pi system is Python 3.11. Therefore, we need to use Pyenv to download an older version of Python.

First, install the depends:

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl

0006_MPW7_TPU_17.jpg

0006_MPW7_TPU_18.jpg

Install pyenv after the depends are installed:

curl https://pyenv.run | bash

0006_MPW7_TPU_19.jpg

Enter the command:

sudo nano ~/.bashrc

Or:

sudo mousepad ~/.bashrc

Add the codes in the ending of this file:

export PYENV_ROOT="$HOME/.pyenv"

[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"

eval "$(pyenv init -)"

0006_MPW7_TPU_36.jpg

0006_MPW7_TPU_21.jpg

Save and exit after adding, then reload the shell:

exec "$SHELL"

0006_MPW7_TPU_22.jpg

Then, we can use pyenv to install an older version of Python:

pyenv install -v 3.8.8

0006_MPW7_TPU_23.jpg

0006_MPW7_TPU_24.jpg

After the installation is successful, we will change the system Python version to 3.8.8:

pyenv global 3.8.8

After the change is successful, you can check the current Python version is 3.8.8:

pyenv versions

python3 -V

0006_MPW7_TPU_25.jpg

7.7 Download the code and run the module

Enter the following commands in sequence to download:

mkdir coral && cd coral

git clone https://github.com/google-coral/pycoral.git

cd pycoral

cd test_data

git clone https://github.com/google-coral/test_data.git

0006_MPW7_TPU_26.jpg

0006_MPW7_TPU_27.jpg

Then, download the code and run the module:

pip3 install numpy

0006_MPW7_TPU_28.jpg

pip3 install Pillow

0006_MPW7_TPU_29.jpg

pip3 install --extra-index-url https://google-coral.github.io/py-repo/ pycoral

0006_MPW7_TPU_30.jpg

7.8 Run the code

After the module download is complete, back to the coral/pycoral path:

cd ..

Enter the following code to run it:

0006_MPW7_TPU_39.jpg

Note: You can copy the following code, but please paste it into a text editor first. Then, following the format shown above, remove any extra enter. After that, copy it again and paste it into the terminal to run.

python3 examples/classify_image.py \

--model test_data/test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \

--labels test_data/test_data/inat_bird_labels.txt \

--input test_data/test_data/parrot.jpg

0006_MPW7_TPU_31.jpg

Contact Us

0001_x.jpg 0002_fb.jpg 0004_ytb.jpg 0003_bb.jpg 0005_qq.jpg QQ:8204136

Email: mcuzone@vip.qq.com

Tel: +86(0)13957118045

If there are any omissions, errors, or infringements on this page, please contact us through the above methods. Thank you!

Copyright 2004-2024 Wildchip