跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
Mcuzone Wiki
搜索
搜索
登录
个人工具
登录
查看“0023 MP2.5GTPU(M.2 E) EN”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
0023 MP2.5GTPU(M.2 E) EN
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[[0023_MP2.5GTPU(M.2_E)|切换语言为中文]] == '''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. http://www.mcuzone.com/wiki/0023_MP2_5GTPU/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 === [[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 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 <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 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 '''''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: <code>sudo apt install iperf3</code> http://www.mcuzone.com/wiki/0008_MPS2_5G/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: http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_03.jpg 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 '''''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.''''' == '''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 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: <code>sudo apt install net-tools</code> http://www.mcuzone.com/wiki/0008_MPS2_5G/0008_MPS2_5G_13.jpg 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 Then we will begin installing the RTL8125 driver. First, we need to update the system: <code>sudo apt-get update</code> 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> http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_14.jpg And install drivers: <code>sudo apt-get install r8125-dkms</code> http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_15.jpg After installation is complete, enter: <code>sudo modprobe r8125</code> http://www.mcuzone.com/wiki/0009_MP2_5GD/0009_MP2_5GD_16.jpg 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 === 5.2 Internet test === 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 '''''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: <code>sudo apt install falkon</code> === 5.3 2.5G Ethernet test in local network === Install the network speed testing tool iperf3: <code>sudo apt install iperf3</code> http://www.mcuzone.com/wiki/0009_MP2_5GD/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: http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_07.jpg 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 '''''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: http://www.mcuzone.com/wiki/2001_CM4_Ultra/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 <code>root</code>, and the default password is <code>password</code>. http://www.mcuzone.com/wiki/2001_CM4_Ultra/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 <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 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 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 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 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 Go back to "Network - Interfaces", and click "Add New Interface": http://www.mcuzone.com/wiki/0015_MP2_5G/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: http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_15.jpg 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 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 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硬盘为共享目录]] 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 Copy any file to the desktop for a read speed test: http://www.mcuzone.com/wiki/0015_MP2_5G/0015_MP2_5G_19.jpg Copy any file to the SSD for a write speed test: 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: [[0008 MPS2.5G(SSD和2.5G以太网)#6.4 树莓派自带WiFI做无线AP(master模式)使用|树莓派自带WiFI做无线AP(master模式)使用]] [[0008 MPS2.5G(SSD和2.5G以太网)#6.5 树莓派自带WiFi做Client使用|树莓派自带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: <code>sudo nano /boot/firmware/config.txt</code> Or: <code>sudo mousepad /boot/firmware/config.txt</code> Add the codes in the ending of this file: <code>dtparam=pciex1</code> <code>kernel=kernel8.img</code> <code>dtoverlay=pineboards-hat-ai</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_01.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> === 7.2 Ensuring software environment === After reboot the system, open the Raspberry Pi terminal and enter the command: <code>uname -r</code> After ensuring the kernel version is greater than 4.18, enter: <code>lsmod | grep apex</code> 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 === 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: <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>curl <nowiki>https://packages.cloud.google.com/apt/doc/apt-key.gpg</nowiki> | sudo apt-key add -</code> 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> 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> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_07.jpg http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_08.jpg === 7.4 Install 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>cd gasket-driver</code> <code>sudo debuild -us -uc -tc -b</code> <code>cd ..</code> <code>sudo dpkg -i gasket-dkms_1.0-18_all.deb</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_09.jpg http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_10.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> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_12.jpg 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> add user to apex: <code>sudo groupadd apex</code> <code>sudo adduser $USER apex</code> 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> === 7.5 Verification module testing and driver installation === After system starting, verification module testing and driver installation: <code>lspci -nn | grep 089a</code> 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> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_14.jpg This board has a single TPU onboard, so you can see a TPU module: 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 === 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: <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> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_17.jpg http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_18.jpg Install pyenv after the depends are installed: <code>curl <nowiki>https://pyenv.run</nowiki> | bash</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_19.jpg Enter the command: <code>sudo nano ~/.bashrc</code> Or: <code>sudo mousepad ~/.bashrc</code> Add the codes in the ending of this file: <code>export PYENV_ROOT="$HOME/.pyenv"</code> <code><nowiki>[[ -d $PYENV_ROOT/bin ]]</nowiki> && export PATH="$PYENV_ROOT/bin:$PATH"</code> <code>eval "$(pyenv init -)"</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_36.jpg http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_21.jpg Save and exit after adding, then reload the shell: <code>exec "$SHELL"</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_22.jpg Then, we can use pyenv to install an older version of Python: <code>pyenv install -v 3.8.8</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_23.jpg http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_24.jpg After the installation is successful, we will change the system Python version to 3.8.8: <code>pyenv global 3.8.8</code> After the change is successful, you can check the current Python version is 3.8.8: <code>pyenv versions</code> <code>python3 -V</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_25.jpg === 7.7 Download the code and run the module === Enter the following commands in sequence to download: <code>mkdir coral && cd coral</code> <code>git clone <nowiki>https://github.com/google-coral/pycoral.git</nowiki></code> <code>cd pycoral</code> <code>cd test_data</code> <code>git clone <nowiki>https://github.com/google-coral/test_data.git</nowiki></code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_26.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> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_28.jpg <code>pip3 install Pillow</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_29.jpg <code>pip3 install --extra-index-url <nowiki>https://google-coral.github.io/py-repo/</nowiki> pycoral</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_30.jpg === 7.8 Run the code === After the module download is complete, back to the coral/pycoral path: <code>cd ..</code> Enter the following code to run it: 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>--model test_data/test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \</code> <code>--labels test_data/test_data/inat_bird_labels.txt \</code> <code>--input test_data/test_data/parrot.jpg</code> http://www.mcuzone.com/wiki/0006_MPW7_TPU/0006_MPW7_TPU_31.jpg {{Contact_Us_icon}}
本页使用的模板:
模板:Contact Us icon
(
查看源代码
)
返回
0023 MP2.5GTPU(M.2 E) EN
。
开关有限宽度模式