Google Chat:---
+86-0755-88291180
sales@spotpear.com
dragon_manager@163.com
tech-support@spotpear.com
zhoujie@spotpear.com
WhatsApp:13246739196
WhatsApp:13424403025


This section introduces how to use the NVMe hard drive function on the Raspberry Pi, laying the foundation for subsequent project development.
Note: The PCIe interface must be enabled before using this function.
sudo nano /boot/firmware/config.txt
dtparam=pciex1_gen=3
sudo reboot
lspci

sudo mkfs. and press the tab key to see various suffixes corresponding to different format typessudo mkfs.
lsblk

/dev/nvme0n1p1 as ext4, for example, execute:sudo mkfs.ext4 /dev/nvme0n1p1

sudo fdisk -l for detailed information)lsblk

/dev/nvme0n1, execute the following command (Note: Use the main device number, not a partition like p1):sudo fdisk /dev/nvme0n1
n to add a new partition, and finally w to save and exitfdisk command functions:n Create a new partitionq Quit without savingp Print the partition tablem Print the menud Delete a partitionw Write table to disk and exitt Change a partition's system IDtoshiba folder in the current directory, create it if missing):sudo mkdir toshiba
sudo fdisk -l for detailed information)lsblk

/dev/nvme0n1 to the toshiba folder in the current directory, for example:sudo mount /dev/nvme0n1p1 ./toshiba
df -h
fstab filesudo nano /etc/fstab
/dev/nvme0n1p1 /home/pi/toshiba ext4 defaults 0 0
sudo mount -a
sudo reboot
lsblk
If the PCIe interface is not enabled, enable the PCIe interface first
Check the mount status
lsblk
If mounted correctly, navigate to the mount directory (here /home/pi/toshiba)
cd /home/pi/toshiba
Copy data from Raspberry Pi memory to the drive (Write Test)
# Clear memory before the write test
sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
sudo dd if=/dev/zero of=./test_write count=2000 bs=1024k

Copy data from the drive to Raspberry Pi memory (Read Test)
# Clear memory before the read test
sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
sudo dd if=./test_write of=/dev/null count=2000 bs=1024k

Note: Performance varies depending on the drive and the environment on the Raspberry Pi. Some drives may be speed-limited. For accurate performance testing, use a PC
This section introduces how to use NVMe SSD booting on the Raspberry Pi, laying the foundation for subsequent project development.
Note: Do not enable Auto-mount on Boot when booting from an NVMe SSD.
sudo raspi-config

sudo reboot
sudo rpi-eeprom-config --edit
BOOT_ORDER in the Raspberry Pi's bootloader configurationBOOT_ORDER=0xf41 to BOOT_ORDER=0xf416 
sudo reboot
This section introduces how to use the DSI interface function on the Raspberry Pi, laying the foundation for subsequent project development.
Note: If a DSI configuration is added to config.txt, regardless of whether a DSI screen is connected, the display output will primarily use the DSI interface (i.e., if the DSI configuration is enabled and only an HDMI interface is connected (if the hardware has HDMI), the HDMI will not display the main desktop but will function as an extended display).
Note: The DSI interface is disabled by default and requires configuration in the config.txt file before use.
sudo nano /boot/firmware/config.txt
# DSI0 (MIPI0)
dtoverlay=vc4-kms-dsi-7inch,dsi0
# DSI1 (MIPI1)
dtoverlay=vc4-kms-dsi-7inch,dsi1
# DSI0 (MIPI0) and DSI1 (MIPI1)
dtoverlay=vc4-kms-dsi-7inch,dsi0
dtoverlay=vc4-kms-dsi-7inch,dsi1
sudo rebootThis section introduces how to use the CSI interface function on the Raspberry Pi, laying the foundation for subsequent project development.
Note: A single camera can only be connected to MIPI0.
Note: The CSI interface is disabled by default and requires configuration in the config.txt file before use.
Enable the CSI interface (disabled by default)
Edit the config.txt file
sudo nano /boot/firmware/config.txt
Add the appropriate configuration to config.txt based on the camera model used (examples below use the imx219 driver for cameras):
| Camera Driver Model | CAM0 Setting Statement | CAM1 Setting Statement |
|---|---|---|
| OV9281 | dtoverlay=ov9281,cam0 | dtoverlay=ov9281,cam1 |
| IMX290/IMX327 | dtoverlay=imx290,clock-frequency=37125000,cam0 | dtoverlay=imx290,clock-frequency=37125000,cam1 |
| IMX378 | dtoverlay=imx378,cam0 | dtoverlay=imx378,cam1 |
| IMX219 | dtoverlay=imx219,cam0 | dtoverlay=imx219,cam1 |
| IMX477 | dtoverlay=imx477,cam0 | dtoverlay=imx477,cam1 |
| IMX296 | dtoverlay=imx296,cam0 | dtoverlay=imx296,cam1 |
| IMX708 | dtoverlay=imx708,cam0 | dtoverlay=imx708,cam1 |
To use only CSI0 (MIPI0), add the following line:
# CSI0 (MIPI0)
dtoverlay=imx219,cam0
To use only CSI1 (MIPI1), add the following line:
# CSI1 (MIPI1)
dtoverlay=imx219,cam1
To use both CSI0 (MIPI0) and CSI1 (MIPI1) simultaneously, add following lines:
# CSI0 (MIPI0) and CSI1 (MIPI1)
dtoverlay=imx219,cam0
dtoverlay=imx219,cam1
After modification, restart the Raspberry Pi to use the CSI interface to drive the camera normally:
sudo reboot
rpicam-hello --list-cameras
# Open camera 0
rpicam-hello --camera 0 -t 0
# Open camera 1
rpicam-hello --camera 1 -t 0
sudo rpi-update
rpicam-hello -t 0
rpicam-jpeg -o test.jpg
rpicam-vid -t 10s -o test.h264This section introduces how to use the FAN interface function on the Raspberry Pi, laying the foundation for subsequent project development.
/sys/devices/platform/cooling_fan/hwmon/hwmon/pwm1 (The fan device is only recognized if connected before powering on)The fan interface is set to automatic temperature control by default and adjusts its speed based on the core temperature. Setting the speed manually will disable the automatic temperature control function. It is recommended to switch back to automatic mode when manual control is not required.
Refer to the relevant note: FAN Key Note
Check if the fan device exists (the device exists if the command outputs a listing)
ls /sys/devices/platform/cooling_fan/hwmon/hwmon0
Switch to manual control (automatic temperature control is default)
echo 1 | sudo tee /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1_enable
# sudo echo 1 > /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1_enable
Set fan speed to 100% (255: fan speed value, range 0~255)
echo 255 | sudo tee /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
# sudo echo 255 > /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
Set fan speed to 50% (255: fan speed value, range 0~255)
echo 128 | sudo tee /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
# sudo echo 128 > /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
Set fan speed to 0% (255: fan speed value, range 0~255)
echo 0 | sudo tee /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
# sudo echo 0 > /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1
By default, the fan on the Pi 5 starts at 50°C. If you want it to start at a different temperature, add the appropriate configuration.
Edit the config.txt file
sudo nano /boot/firmware/config.txt
Add the following lines at the end (fan_temp0/1/2/3 specifies the temperature (36000 means 36°C), fan_temp0/1/2/3_hyst is the hysteresis temperature, and fan_temp0/1/2/3_speed is the corresponding speed (maximum 255)):
dtparam=fan_temp0=36000,fan_temp0_hyst=2000,fan_temp0_speed=90
dtparam=fan_temp1=40000,fan_temp1_hyst=3000,fan_temp1_speed=150
dtparam=fan_temp2=52000,fan_temp2_hyst=4000,fan_temp2_speed=200
dtparam=fan_temp3=58000,fan_temp3_hyst=5000,fan_temp3_speed=255
Refer to the relevant note: FAN Key Note
Check if the fan device exists (the device exists if the command outputs a listing)
ls /sys/devices/platform/cooling_fan/hwmon/hwmon0
Print the current fan speed
cat /sys/devices/platform/cooling_fan/hwmon/hwmon0/fan1_input
Refer to the relevant note: FAN Key Note
Check if the fan device exists (the device exists if the command outputs a listing)
ls /sys/devices/platform/cooling_fan/hwmon/hwmon0
Switch to automatic temperature control
echo 2 | sudo tee /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1_enable
# sudo echo 2 > /sys/devices/platform/cooling_fan/hwmon/hwmon0/pwm1_enableThis section introduces how to use the RTC function on the Raspberry Pi, laying the foundation for subsequent project development.
To use the full RTC functionality, please connect the RTC battery.
/dev/rtc0.hwclock related commands installed by default. Please install the necessary tools:sudo apt install -y util-linux-extra
hwclock tool for testing.hwclock fails, refer to RTC Key Note and execute the installation command.sudo hwclock -r
-f: followed by the selected device, /dev/rtc0: specifies the RTC device to operate on):sudo hwclock -f /dev/rtc0 -r
hwclock fails, refer to RTC Key Note and execute the installation commandsudo hwclock --set --date="3/7/2024 16:55:05"
hwclock fails, refer to RTC Key Note and execute the installation command.sudo hwclock -w
sudo hwclock -s
shutdown command to automatically shut down the system after a specified time.sudo shutdown -h +10
sudo shutdown -h 23:30
To enable this feature, an RTC battery must be connected to ensure the RTC continues functioning even when external power is disconnected.
sudo -E rpi-eeprom-config --edit
POWER_OFF_ON_HALT=1
WAKE_ON_GPIO=0
sudo reboot
echo +600 | sudo tee /sys/class/rtc/rtc0/wakealarm
sudo halt
# or sudo poweroff
This operation can only be performed when a rechargeable RTC battery is connected.
sudo nano /boot/firmware/config.txt
dtparam=rtc_bbat_vchg=3000000This section introduces how to use the RS485 interface functions on the Raspberry Pi, laying the foundation for subsequent project development.
sudo nano /boot/firmware/config.txt
# Corresponding to CH1
dtoverlay=uart4-pi5
# Corresponding to CH2
dtoverlay=uart2-pi5
# Enable CH1 ~ CH2 RS485 channels at the same time
dtoverlay=uart2-pi5
dtoverlay=uart4-pi5
sudo rebootThis section introduces how to use the M.2 B KEY interface functions on the Raspberry Pi, laying the foundation for subsequent project development.
sudo modprobe option
sudo sh -c 'echo "1e0e 9011" > /sys/bus/usb-serial/drivers/option1/new_id'
sudo sh -c 'echo "1e0e 9018" > /sys/bus/usb-serial/drivers/option1/new_id'
sudo sh -c 'echo "1e0e 901E" > /sys/bus/usb-serial/drivers/option1/new_id'
Install the text-based serial communication tool minicom:
sudo apt-get install minicom
Connect to the 4G/5G module port (use ttyUSB2, which appears when the module is connected; adjust the port according to your actual situation):
sudo minicom -D /dev/ttyUSB2
The following AT commands are common to both 4G and 5G modules:
| Command | Description | Return Value |
|---|---|---|
| AT | Test command | OK |
| ATE | ATE1 enables echo ATE0 disables echo | OK |
| AT+CGMI | Query module manufacturer | OK |
| AT+CGMM | Query module model | OK |
| AT+CGSN | Query product serial number | OK |
| AT+CSUB | Query module version and chip | OK |
| AT+CGMR | Query firmware version serial number | OK |
| AT+IPREX | Set module hardware serial port baud rate +IPREX: | OK |
| AT+CRESET | Reset module | OK |
| AT+CSQ | Query network signal quality; returns signal value +CSQ: 17,99 | OK |
| AT+CPIN? | Query SIM card status; returns READY if the SIM card is recognized properly | +CPIN: READY |
| AT+COPS? | Query current operator; returns operator information when connected to the network +COPS: | OK |
| AT+CREG? | Query network registration status +CREG: | OK |
| AT+CPSI? | Query UE system information | |
| AT+CNMP | Network mode selection command: 2: Automatic 13: GSM only 38: LTE only 48: Any modes but LTE ... .... | OK |
sudo minicom -D /dev/ttyUSB2
AT+CUSBCFG=USBID,1E0E,9011

ifconfig
ifconfig

sudo dhclient -v usb0
sudo apt-get install udhcpc
sudo udhcpc -i usb0
sudo route add -net 0.0.0.0 usb0
ping -I usb0 www.baidu.com # Here the port added by the 4G/5G module is usb0; adjust the command according to your actual situation
AT+CNBP=0x0002000000400183,0x000001E000000000,0x0000000000000021
AT+CNBP=0x0002000000400180,0x480000000000000000000000000000000000000000000042000001E200000095,0x0000000000000021This section introduces how to use the Lora function on the Raspberry Pi, laying the foundation for subsequent project development.
This section introduces how to use the CAN interface function on the Raspberry Pi, laying the foundation for subsequent project development.
sudo nano /boot/firmware/config.txt
dtoverlay=spi0-1cs,cs0_pin=8
dtoverlay=mcp2515,spi0-0,oscillator=16000000,interrupt=25
sudo reboot
ifconfig
sudo ip link set can0 up type can bitrate 500000
dmesg | grep spi

sudo apt update
sudo apt-get install can-utils
cansend can0 000#11.22.33.44

candump can0
