Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rockpi4/install/NVME"

(Method Two: Write image to SPI flash using mtd tool)
 
(4 intermediate revisions by 2 users not shown)
Line 49: Line 49:
 
=== Method Two: Write image to SPI flash using mtd tool ===
 
=== Method Two: Write image to SPI flash using mtd tool ===
  
This method requires a running system ( [https://dl.radxa.com/rockpi/images/ubuntu/rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz Ubuntu Server] or [https://dl.radxa.com/rockpi/images/debian/rockpi4_debian_stretch_lxde_armhf_20181105_2120-gpt.img.gz Debian Desktop] ) on ROCK Pi 4 board. So now power on the ROCK Pi 4. Maybe your ROCK Pi system is running on eMMC module or uSD card. It is OK.
+
<p>
 +
<b> THIS METHOD IS NO LONGER APPLICABLE TO OUR LATEST LINUX 5.10 SYSTEM! </b><br/>
 +
Please use Method 3 instead.<br/>
 +
Below content preserved for users of older system.<br/>
 +
</p>
 +
 
 +
This method requires a running Linux system ( [https://wiki.radxa.com/Rockpi4/downloads Ubuntu Server] or [https://wiki.radxa.com/Rockpi4/downloads Debian Desktop] ) on ROCK Pi 4 board. So now power on the ROCK Pi 4. Maybe your ROCK Pi system is running on eMMC module or uSD card. Either is OK.
  
 
Firstly, add Radxa APT source. The latest version of u-boot and kernel is still in testing.
 
Firstly, add Radxa APT source. The latest version of u-boot and kernel is still in testing.
Line 175: Line 181:
 
   Done.
 
   Done.
  
== Step 2 Install ROCK Pi 4 system image to M.2 NVME SSD ==
+
=== Method Three: Use the Armbian nand-sata-install script ===
  
It is convenient to install a system image to M.2 NVME SSD. System images used include [https://dl.radxa.com/rockpi/images/ubuntu/rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img.gz Ubuntu Server] and [https://dl.radxa.com/rockpi/images/debian/rockpi4_debian_stretch_lxde_armhf_20181105_2120-gpt.img.gz Debian Desktop].
+
The install script for Armbian, nand-sata-install, in versions 20.11 or later makes it easy to write a mainline u-boot image to the RockPi’s SPI to enable booting directly from nvme disks. You can boot other distributions of Linux such as Manjaro using the Armbian u-boot. I have confirmed these instructions work on a RockPi 4c using a Samsung EVO 960 SSD.
 +
 
 +
Prerequisities: ROCK Pi 4(A/B/C) v1.4 or 1.3 with SPI soldered in (v1.3 comes without SPI flash from the factory). If you already have Radxa’s u-boot written to SPI you need to short pins 23 and 25 for Armbian to boot.
 +
 
 +
Boot Armbian v20.11.x or later on your ROCK Pi 4(A/B/C). Note that as of March 2022, Armbian for the RockPi 4 doesn’t have a maintainer so you will have to download an archived install image [https://armbian.hosthatch.com/archive/rockpi-4b/archive/ from here.] These are images for the rockpi4b but they also work with the 4c.
 +
 
 +
After booting into Armbian 20.11 or later (i used a 21.08.1 image), add the following lines to /boot/armbianEnv.txt
 +
 
 +
overlays=spi-jedec-nor
 +
param_spinor_spi_bus=1
 +
 
 +
After rebooting, verify that the SPI mtd interface is enabled by running:
 +
 
 +
$ ls /dev/mtdblock0
 +
 
 +
You need to create at least one empty partition on your nvme disk using your favourite partitioning tool (cfdisk, sgdisk, gparted…) before you can run the armbian installer:
 +
 
 +
# cfdisk /dev/nvme0n1
 +
 
 +
After creating a partition, run nand-sata-install then choose:
 +
 
 +
    Choose option: "Boot from SPI - system on SATA, USB or NVMe"
 +
    Choose NVMe partition, eg. /dev/nvme0n1p1
 +
    Accept erasing of the choosen partition with "Yes"
 +
    Choose fs type (tested with ext4)
 +
    Wait a few minutes for rootfs transfer to chosen partition
 +
    Choose writing SPI bootloader with "Yes"
 +
    Confirm that you want to flash it with "Yes"
 +
    Wait ~60 seconds for writing
 +
    Choose Exit
 +
    Reboot or poweroff
 +
 
 +
== Step 2 Install ROCK Pi 4 system image to M.2 NVME SSD ==
  
Put the M.2 NVME SSD into M.2 NVMe SSD Reader Adapter, and then insert them to PC.
+
It is convenient to install a system image to M.2 NVME SSD. System images used include [https://wiki.radxa.com/Rockpi4/downloads Ubuntu Server] and [https://wiki.radxa.com/Rockpi4/downloads Debian Desktop].
  
 
When they are ready, use tool command '''dd''' or APP '''Etcher''' to install system image to M.2 NVME SSD.
 
When they are ready, use tool command '''dd''' or APP '''Etcher''' to install system image to M.2 NVME SSD.
  
==== Use Etcher APP====
+
==== Option1: Use Etcher APP on PC====
  
 
You can use NVMe reader on PC to write ROCK Pi 4 image to NVMe. Check [[Rockpi4/install/NVME-reader | NVMe Reader]] page.
 
You can use NVMe reader on PC to write ROCK Pi 4 image to NVMe. Check [[Rockpi4/install/NVME-reader | NVMe Reader]] page.
  
==== Use tool command "dd"====
+
==== Option 2: Use tool command "dd" on ROCK Pi 4====
  
Get your NVME SSD device path:
+
Boot your ROCK Pi 4 with uSD/eMMC and SSD attached. Get your NVME SSD device path:
  
 
     sudo fdisk -l
 
     sudo fdisk -l

Latest revision as of 06:40, 12 June 2023

    ROCK Pi 4 >  Install >  Install on M.2 NVME SSD

It is exciting that, on ROCK Pi 4, NVME is able to boot from SPI Flash. Here is the tutorial about the Linux system running on M.2 NVME SSD.

This tutorial applies to ROCK Pi 4A, ROCK Pi 4B, and ROCK Pi 4C.

Prerequisites

To follow this tutorial, you will need:

  • A well-running ROCK Pi with eMMC or Micro SD Card
  • Linux system image for ROCK Pi 4
  • SPI Flash image (ROCK Pi 4 u-boot image)
  • SPI Flash IC on ROCK Pi 4
    • Single power supply voltage range: 2.7~3.6V
    • Space: at least 4MB
  • M.2 NVME SSD
    • Check the FAQs page for compatible SSD models.
  • M.2 NVMe USB Reader(Optional)
    • Use it to write image to NVMe SSD on PC

Step 1 Install ROCK Pi 4 u-boot image to SPI Flash

There are two methods to install the u-boot image to SPI Flash. But before you do that, you need to have an SPI Flash IC on your board.

Check if there is an SPI flash on ROCK Pi 4 board. See SPI Flash.

Method One: Write image to SPI flash from USB OTG port

Firstly, remove booting devices such as uSD card, eMMC, and M.2 NVME SSD from ROCK Pi 4.

Secondly, get ROCK Pi 4 u-boot image from here . Select the target files, called uboot-trust-spi.img and rk3399_loader_spinor_v1.15.114.bin .

Thirdly, follow Write image to SPI flash from USB OTG port to flash image.

Finally, we can see that red(or blue) led is always on.

Method Two: Write image to SPI flash using mtd tool

THIS METHOD IS NO LONGER APPLICABLE TO OUR LATEST LINUX 5.10 SYSTEM!
Please use Method 3 instead.
Below content preserved for users of older system.

This method requires a running Linux system ( Ubuntu Server or Debian Desktop ) on ROCK Pi 4 board. So now power on the ROCK Pi 4. Maybe your ROCK Pi system is running on eMMC module or uSD card. Either is OK.

Firstly, add Radxa APT source. The latest version of u-boot and kernel is still in testing.

For Debian stretch

 $ export DISTRO=stretch-testing # update more frequently but maybe unstable
 $ echo "deb http://apt.radxa.com/$DISTRO/ stretch main" | sudo tee /etc/apt/sources.list.d/apt-radxa-com.list

or Ubuntu server

 $ export DISTRO=bionic-testing # update more frequently but maybe unstable
 $ echo "deb http://apt.radxa.com/$DISTRO/ bionic main" | sudo tee /etc/apt/sources.list.d/apt-radxa-com.list

Get the pub key

 $ wget -O -  apt.radxa.com/$DISTRO/public.key | sudo apt-key add -

Update APT

 $ sudo apt-get update && sudo apt-get upgrade

Install necessary packages

 $ sudo apt-get install -y rockchip-fstab
 $ sudo apt-get install -y rockchip-overlay
 $ sudo apt-get install -y rockpi4-dtbo
 $ sudo apt-get install -y linux-4.4-latest # Will update kernel

Update u-boot in uSD card or eMMC:

for ROCK Pi 4A

 $ sudo apt-get install -y rockpi4a-rk-u-boot-latest

for ROCK Pi 4B

 $ sudo apt-get install -y rockpi4b-rk-u-boot-latest

for ROCK Pi 4C

 $ sudo apt-get install -y rockpi4c-rk-u-boot-latest

Screen shows

 ...
 You are currently running on board:
 ROCK PI 4B 
 There will be two steps that you have to confirm. One is upgrading bootloader on SPI Flash.
 The other is upgrading bootloader on eMMC or uSD card.
 
 Step one: upgrade bootloader on SPI Flash
 Boot device, SPI Flash, is not found. Make sure there is one SPI Flash on board.
 You can install package rockpi4-dtbo later manually and uncomment three lines in file /boot/hw_intfc.conf.
 intfc:uart4=off
 intfc:spi1=on
 intfc:dtoverlay=spi1-flash
 After restarting the Pi, execute command, /usr/local/sbin/rockpi4b_upgrade_bootloader.sh.

 Step two: upgrade bootloader on uSD card or eMMC.
 Boot device, uSD card or eMMC, is found. Would you like to upgrade bootloader on it?
 If yes, type Y/y. If no, type N/n.

Just type Y or y.

 y
 Backup bootloader on boot device (/dev/mmcblk1p2).
 8192+0 records in
 8192+0 records out
 4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.107356 s, 39.1 MB/s
 Overwrite bootloader to boot device (/dev/mmcblk1p2).
 2048+0 records in
 2048+0 records out
 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.140072 s, 7.5 MB/s
 Done.

Edit file /boot/hw_intfc.conf. Make sure the following configuration are there:

 intfc:uart4=off
 intfc:spi1=on
 intfc:dtoverlay=spi1-flash

Reboot the machine.

After login, there is a device /dev/mtd0.

 $ ls /dev/mtd*
 /dev/mtd0  /dev/mtd0ro  /dev/mtdblock0

Execute command

 $ sudo /usr/local/sbin/rockpi4b_upgrade_bootloader.sh

Screen shows

 You are currently running on board:
 ROCK PI 4B 
 There will be two steps that you have to confirm. One is upgrading bootloader on SPI Flash.
 The other is upgrading bootloader on eMMC or uSD card.
 
 Step one: upgrade bootloader on SPI Flash
 One boot device, SPI Flash, is found, would you like to upgrade bootloader on it?
 The installation would cost several minutes.
 If yes, type Y/y. If no, type N/n.

Just type Y or y.

 y
 Overwrite bootloader to SPI Flash device.
 Writing /dev/mtd0 with content of /usr/lib/u-boot-rockpi4b/spi/uboot-trust-spi.img
 Erasing 4 Kibyte @ 3ff000 -- 100 % complete 
 Writing data to block 0 at offset 0x0
 Writing data to block 1 at offset 0x1000
 Writing data to block 2 at offset 0x2000
 Writing data to block 3 at offset 0x3000
 Writing data to block 4 at offset 0x4000
 ...
 Writing data to block 1020 at offset 0x3fc000
 Writing data to block 1021 at offset 0x3fd000
 Writing data to block 1022 at offset 0x3fe000
 Writing data to block 1023 at offset 0x3ff000
 
 Step two: upgrade bootloader on uSD card or eMMC
 Boot device, uSD card or eMMC, is found. Would you like to upgrade bootloader on it?
 If yes, type Y/y. If no, type N/n.

Type N or n.

 n
 Do not overwrite bootloader to uSD card or eMMC device.
 You can upgrade it by executing /usr/local/sbin/rockpi4b_upgrade_bootloader.sh later.
 Done.

Method Three: Use the Armbian nand-sata-install script

The install script for Armbian, nand-sata-install, in versions 20.11 or later makes it easy to write a mainline u-boot image to the RockPi’s SPI to enable booting directly from nvme disks. You can boot other distributions of Linux such as Manjaro using the Armbian u-boot. I have confirmed these instructions work on a RockPi 4c using a Samsung EVO 960 SSD.

Prerequisities: ROCK Pi 4(A/B/C) v1.4 or 1.3 with SPI soldered in (v1.3 comes without SPI flash from the factory). If you already have Radxa’s u-boot written to SPI you need to short pins 23 and 25 for Armbian to boot.

Boot Armbian v20.11.x or later on your ROCK Pi 4(A/B/C). Note that as of March 2022, Armbian for the RockPi 4 doesn’t have a maintainer so you will have to download an archived install image from here. These are images for the rockpi4b but they also work with the 4c.

After booting into Armbian 20.11 or later (i used a 21.08.1 image), add the following lines to /boot/armbianEnv.txt

overlays=spi-jedec-nor
param_spinor_spi_bus=1

After rebooting, verify that the SPI mtd interface is enabled by running:

$ ls /dev/mtdblock0

You need to create at least one empty partition on your nvme disk using your favourite partitioning tool (cfdisk, sgdisk, gparted…) before you can run the armbian installer:

# cfdisk /dev/nvme0n1

After creating a partition, run nand-sata-install then choose:

   Choose option: "Boot from SPI - system on SATA, USB or NVMe"
   Choose NVMe partition, eg. /dev/nvme0n1p1
   Accept erasing of the choosen partition with "Yes"
   Choose fs type (tested with ext4)
   Wait a few minutes for rootfs transfer to chosen partition
   Choose writing SPI bootloader with "Yes"
   Confirm that you want to flash it with "Yes"
   Wait ~60 seconds for writing
   Choose Exit
   Reboot or poweroff

Step 2 Install ROCK Pi 4 system image to M.2 NVME SSD

It is convenient to install a system image to M.2 NVME SSD. System images used include Ubuntu Server and Debian Desktop.

When they are ready, use tool command dd or APP Etcher to install system image to M.2 NVME SSD.

Option1: Use Etcher APP on PC

You can use NVMe reader on PC to write ROCK Pi 4 image to NVMe. Check NVMe Reader page.

Option 2: Use tool command "dd" on ROCK Pi 4

Boot your ROCK Pi 4 with uSD/eMMC and SSD attached. Get your NVME SSD device path:

   sudo fdisk -l

You can see the output message just like this:

   Disk /dev/nvme0n1: 232.9 GiB, 250059350016 bytes, 488397168 sectors             #The '/dev/nvme0n1' is your NVME SSD device path
   Units: sectors of 1 * 512 = 512 bytes                                           
   Sector size (logical/physical): 512 bytes / 512 bytes                           
   I/O size (minimum/optimal): 512 bytes / 512 bytes 

Write Image:

   sudo dd if='your image path' of='your NVME SSD device path' bs=1M             
   #such as: sudo dd if=rockpi4-debian-stretch-desktop-arm64-20190710_1940-gpt.img of=/dev/nvme0n1 bs=1M

Step 3 Test M.2 NVME SSD booting from SPI Flash

Power off ROCK Pi 4, remove eMMC module or uSD Card from ROCK Pi 4 since there is a system image in eMMC module or uSD Card.

Insert M.2 NVME SSD into ROCK Pi 4.

Power on ROCK Pi 4 and the system runs on M.2 NVME SSD. Now we need to check out some important information.

Use lsusb to see whether the fourth partition is mounted on /boot directory. If not, just install package, rockchip-fstab, which will add the following lines in file /etc/fstab. If the contents of /etc/fstab are incorrect, just modify it. Then execute sudo mount -a.

The contents of files /etc/fstab.

 # UNCONFIGURED FSTAB FOR BASE SYSTEM
 # /etc/fstab: static file system information.
 #
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 
 /dev/nvme0n1p4  /boot   vfat    defaults        0       2

lsblk should show like this when the system runs on M.2 NVMEE SSD.

 root@linaro-alip:/boot# lsblk
 NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 nvme0n1     259:0    0 232.9G  0 disk 
 ├─nvme0n1p1 259:1    0   3.9M  0 part 
 ├─nvme0n1p2 259:2    0     4M  0 part 
 ├─nvme0n1p3 259:3    0     4M  0 part 
 ├─nvme0n1p4 259:4    0   112M  0 part /boot
 └─nvme0n1p5 259:5    0 232.8G  0 part /

Since the fourth partition, /dev/nvme0n1p4, is mounted on /boot directory. Now you need to update necessary u-boot and kernel packages.

 $ sudo apt-get install -y rockchip-overlay
 $ sudo apt-get install -y linux-4.4-latest rockpi4-dtbo rockpi4b-rk-u-boot-latest

Modify file, /boot/hw_intfc.conf. Uncomment these lines. Thus we can use SPI Flash device (/dev/mtd0)

intfc:uart4=off
intfc:spi1=on
intfc:dtoverlay=spi1-flash

Reboot the Pi.

Step 4 Enable PCIe Gen2 mode to get max speed

By default, the PCIe of ROCK Pi 4 runs on Gen1 mode for the most capability. Once you confirm that your NVMe works well you can try to enable the PCIe gen2 mode to get the max speed of NVMe(reading/writing > 1000MB/s).

To enable PCIe gen2 mode, make sure you are booting on NVMe as rootfs and /boot is mounted:

     ├─nvme0n1p4 259:4    0   112M  0 part /boot

edit /boot/hw_intfc.conf, uncomment the line:

   intfc:dtoverlay=pcie-gen2

save and reboot. You should have a higher speed on NVMe.

FAQs

  • u-boot supporting NVME booting version
    • 2017.09-2676-g4490220395 (or newer)
  • kernel version
    • 4.4.154-90-rockchip-ga14f6502e045 (or newer)
  • rockpi4-dtbo version
    • 4 (or newer)
  • Debug log
 rock@ubuntu:~$ ls /dev/mtd*
 /dev/mtd0  /dev/mtd0ro  /dev/mtdblock0
 
 rock@ubuntu:~$ cat /proc/mtd 
 dev:    size   erasesize  name
 mtd0: 00400000 00001000 "loader"
 
 rock@ubuntu:~$ sudo dmesg | grep spi  
 [sudo] password for rock: 
 [    2.227001] rockchip-spi ff1d0000.spi: Failed to request TX DMA channel
 [    2.227587] rockchip-spi ff1d0000.spi: Failed to request RX DMA channel
 [    2.228171] rockchip-spi ff1d0000.spi: no high_speed pinctrl state
 [    2.229257] m25p80 spi32766.0: xt25f32b (4096 Kbytes)
 [    2.229715] 1 ofpart partitions found on MTD device spi32766.0
 [    2.230273] Creating 1 MTD partitions on "spi32766.0":
  • Verified SPI Flash
    • W25Q64FV
    • GD25Q127CSIG
    • XT25F32B
    • XT25F128B
  • How to know that the image has been successfully installed to SPI Flash?
    • For the newest version of u-boot, when it runs, the red(or blue) led is on.
    • You can remove booting devices such as uSD card, eMMC module, and so on. Power on ROCK Pi 4 with SPI Flash on board to see if the red(or blue) led is on. If yes, it means that you make it.
  • Check if there is an SPI flash on ROCK Pi 4 board. See SPI Flash.

Change log

uboot-trust-spi-20190816_1128.img

  • Check
    • md5sum: 45e8f258d8fcdf3c2d5571b37c30716c
    • sha256sum: 7f453ccd2009df3b6aaa2ab37b465f78cdd5962c665726651c86237a8b041095
  • Support MS Dos(MBR) partition table
  • Support Armbian system image for ROCK Pi 4.

Troubleshooting