Raspberry Pi M.2 HAT+

From Waveshare Wiki
Jump to: navigation, search
Raspberry Pi M.2 HAT+
Raspberry Pi M.2 HAT+.jpg

PCIe TO M.2
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

Introduction

Official Raspberry Pi PCIe To M.2 HAT, Designed For Raspberry Pi 5, Adapter For NVMe Protocol M.2 Solid State Drive, Compatible With 2230/2242 Size M.2 Solid State Drive, Supports Gen2 And Gen3 Modes, Supports Booting PI5 From Solid State Drive

Features

  • Support NVMe protocol M.2 solid state drive, high-speed reading/writing, higher operation efficiency.
  • Support PCI-E×1 Gen2 or Gen3 mode.
  • Only support Pi5B.
  • Compatible with 2230/2242 Size M.2 Solid State Drive.
  • Onboard operation indicator, PWR indicator is always on when power on; ACT indicator blinking while reading/writing, easy to learn its operation status.
  • Features HAT + design with onboard EEPROM chip.

Note

  • Raspberry Pi does not support booting From NVME by default, so you need to modify its setting.

How to Use

Hardware Connection

Please pay attention to the cable orientation, as shown below:
Raspberry Pi M.2 HAT+ hard.jpg

Load

1. Enable PCIe interface:
Connect the hardware and the PCIE interface will automatically open as the latest system detects the hardware.
If it does not open, you can execute: add "dtparam=pciex1" in the /boot/firmware/config.txt 
2. PCIE selects GEN2 mode by default. If PCIE gen3 is needed, you can add the following content in /boot/firmware/config.txt:
dtparam=pciex1_gen=3
3. Reboot the PI5 after modifying, and then the device can be recognized.
As shown below, SM2263 is the recognized solid-state drive that I use, and the other one is the RPI chip for PI5:
PCIe TO M.2 HAT+ W 1.png
4. Partitioning: If partitioning and formatting have already been performed on another platform, skip this step. Caution: Partitioning and formatting will erase all data on the SSD, so proceed with caution.
lsblk  #see the disk (execute "sudo fdisk -l" for more details)
PCIe TO M.2 HAT+ W 2.png
Partition 
sudo fdisk /dev/nvme0n1    #dev is the total device number, do not add "p1", just one partition 
How do use fdisk
n New partition
q Exit without saving
p Print partition table 
m Print selection menu  
d Delete partition  
w Save and exit
t Modify ID 
Add the partition and execute "n", and then press "w" to save and exit. 

5: Format:

sudo mkfs.  #Then, pressing Tab will display various file extensions. Each extension corresponds to a format you may want to format the drive into
PCIe TO M.2 HAT+ W 3.png
If I need to format it in "ext4" format, execute:  
sudo mkfs.ext4 /dev/nvme0n1p1
Wait for a moment, when "done" appears for all, it means the formatting is complete.
PCIe TO M.2 HAT+ W 4.png

6: Load:

Create the mounting directory:
sudo mkdir toshiba
Mount the device
sudo mount /dev/nvme0n1p1 ./toshiba
Check disk status
df -h

Read/Write Test

Enter the directory to mount the disk:

cd toshiba
  • Release the caches:
sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
  • Copy the Raspberry Pi memory to the hard flash driver (write).
sudo dd if=/dev/zero of=./test_write count=2000 bs=1024k

PCIe TO M.2 HAT+ W 5.png

  • Copy the contents of the hard drive to the Raspberry Pi's memory. ("/etc/fstab" for reading).
 sudo dd if=./test_write of=/dev/null count=2000 bs=1024k

Pcie-m2-6new.png

  • Note: Different cards and environments may have different results. Raspberry Pi's performance is significantly affected, so for accurate performance testing, it's recommended to use a PC.

Auto Mount

If there are no issues with the test and the disk is not needed as a system disk, only for expanding disk usage, set up automatic mounting.

sudo nano /etc/fstab

#Add the following content at the end:
/dev/nvme0n1p1  /home/pi/toshiba  ext4  defaults  0  0
#/dev/nvme0n1p1 device name, /home/pi/toshiba mount to the directory, ext4 is the file system type, defaults means using the default mounting options  
#Reboot to take effect (Please make sure there are no issues before rebooting, otherwise it can not be booted without mounting)  
sudo mount -a

#And then reboot
Check the device through lsblk 

NVMe SSD Booting

Start the Raspberry Pi using the SD card, mount, and test to ensure that the hardware is functioning properly.
We provide two methods for you, you can select one to operate:

Method 1

1: Execute:

sudo raspi-config

PCIE NVME BOOT-1.png

2: Reboot the Raspberry Pi:

If you find that you can't modify the file several times, please connect to the network and modify it again (wait for the network time synchronization), or set the correct time before modifying the file.

3: Flash the system into NVME, then connect the NVME to the expansion board, remove the SD card and re-power on.

Method 2

1: Start the Raspberry Pi using the SD card and modify the BOOT_ORDER in the Raspberry Pi's bootloader configuration.

sudo rpi-eeprom-config --edit 
Modify BOOT_ORDER=0xf41 as BOOT_ORDER=0xf416
PCIe TO M.2 HAT+ W 6.png
For details, please refer to BOOT_ORDER 

2: Reboot the Raspberry Pi:

If you find that you can't modify the file several times, please connect to the network before modifying the file (wait for the network to time itself), or set the correct time before modifying the file.

3: Just program the system into NVME, then connect it to the expansion board, remove the SD card, and re-power it up.

Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)