跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
Mcuzone Wiki
搜索
搜索
登录
个人工具
登录
查看“0013 MPSTPU(M.2 E) EN”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
0013 MPSTPU(M.2 E) EN
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[[0013 MPSTPU(M.2 E)|切换语言为中文]] == '''Keywords''' == Raspberry Pi 5, PCIe, TPU, DTPU, Driver installation, Operation demonstration, AI, google, Coral, 2230, 2242, 2280, NVMe SSD, SSD X1 == '''I. Introduction''' == 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. Our MPSTPU expansion board adds two PCIe interfaces via a PCIe Switch, One is an M.2 E key interface, which can be used to connect a TPU module with an A+E Key interface, the other is an M.2 M key interface, which can be used to connect an NVMe SSD. The MPSTPU expansion board can provide the system with massive SSD storage while adding TPU edge computing capabilities. == '''II. Hardware Resources''' == 1. Designed for the Raspberry Pi 5, it uses a 16-pin FPC to connect to the Raspberry Pi 5's PCIe interface. 2. The MPSTPU expansion board adds two PCIe interfaces via a PCIe Switch. 3. One PCIe extension M.2 E key interface, used for connecting the Google Coral Edge TPU, with the official Raspberry Pi OS loading the driver. 4. One PCIe expanded M.2 M key slot, for connecting NVMe SSD (PCIe X1, Gen2 mode only). Supports 2230/2242/2280 size SSDs (defaulting to welded mounting posts for 2280 size). 5. The SSD can be used for data storage and system booting. When booting from the SSD, the Raspberry Pi official firmware needs to be version 2024.5.13 or later. 6. The 40-pin GPIO section adopts an unobstructed design on the top. It can be connected via DuPont cable, without affecting the use of the Raspberry Pi 5's own GPIO pins. 7. Gold immersion PCB process, lead-free production, certified by UL, compliant with ROHS standards, and has a fire rating of 94V-0. http://www.mcuzone.com/wiki/0013_MPTPU_M/0013_MPTPU_M_03.jpg Note: 1. After the Raspberry Pi 5 firmware update, the settings cannot be modified, or else the firmware will automatically revert to the old version. 2. Due to the limitations of the switch, PCIe only supports X1 Gen2, with SSD speeds of approximately 400 MB/s. == '''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]] === 3.3 System flashed onto the SSD === [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#3.3 Boot from SSD|Click here to read the instructions for System flashing]] == '''IV. Raspberry Pi OS operation demonstration''' == This chapter introduces how to run the TPU module on the Raspberry Pi OS. The steps in this chapter apply to both systems booting from TF card and from SSD. === 4.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> === 4.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 === 4.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 === 4.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> === 4.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 === 4.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 === 4.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 === 4.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 == '''V. Using SSD in the Raspberry Pi OS''' == For basic operations on the SSD, we can refer to the following link: [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#4.1 Use the SSD for storage expansion|Use the SSD for storage expansion (Raspberry Pi OS)]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#VI. Perform partitioning and other operations on the SSD|Perform partitioning and other operations on the SSD]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#cite ref-1|Adjust the peripheral boot order]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#7.2 Test the SSD speed in PCIe Gen2 mode|Install the SSD speed testing software hdparm]] For how to test the SSD, we can refer to the following link: [[0008 MPS2.5G(SSD和2.5G以太网)#4.2 SSD硬盘测试|SSD硬盘测试(树莓派OS下)]] == '''VI. Using SSD in the Ubuntu system''' == For basic operations on the SSD, we can refer to the following link, apart from the SSD being used for storage expansion, which operates slightly differently under Raspberry Pi OS, the rest is basically the same. [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#5.1 Use the SSD for storage expansion|Use the SSD for storage expansion(Ubuntu system)]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#VI. Perform partitioning and other operations on the SSD|Perform partitioning and other operations on the SSD]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#cite ref-1|Adjust the peripheral boot order]] [[0005 MPS2242 2280 2280P(Single SSD Expansion Board)#7.2 Test the SSD speed in PCIe Gen2 mode|Install the SSD speed testing software hdparm]] For how to test the SSD, we can refer to the following link: [[0008 MPS2.5G(SSD和2.5G以太网)#5.2 SSD硬盘测试|SSD硬盘测试(Ubuntu系统下)]] == '''VII. Using SSD in the OpenWrt system''' == For how to use the SSD in the OpenWrt system, we can refer to the following link: [[2001 CM4 Ultra(CM4核心板的扩展板)#5.5 SSD硬盘测试|SSD硬盘测试(OpenWrt系统下)]] {{Contact_Us_icon}}
本页使用的模板:
模板:Contact Us icon
(
查看源代码
)
返回
0013 MPSTPU(M.2 E) EN
。
开关有限宽度模式