update 2020-07-18:
Refer wiki page for the updated and maintained version.
https://wiki.radxa.com/Rockpi4/Linux_system_runs_on_M.2_NVME_SSD
update 2019-07-31:
Since many user have issue with SPI + NVMe booting, we have updated a new Debian stretch firmware with everything ready to use. Here is the steps to use it.
1. Boot with uSD card or eMMC module
Download the image from:
Write it to uSD card or eMMC module with dd or ecther, attach your NVMe disk to ROCK Pi 4, and boot from uSD card or eMMC module.
2. Write the SPI flash
After boot from eMMC or uSD card, you should have /dev/mtd0 device if your ROCK Pi 4 has SPI flash soldered, run the script to write the bootloader to SPI flash.
sudo /usr/local/sbin/rockpi4b_upgrade_bootloader.sh
Output
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.
Type Y to confirm. It takes several minutes to erase and write the SPI flash. Have some tea and wait.
3. Write the NVMe disk
Copy the same image you downloaded on your ROCK Pi 4 and dd it to NVMe.
sudo apt-get install pigz
unpigz -p 6 -c /path/to/rockpi4-debian-stretch-desktop-arm64-20190730_2022-gpt.img.gz | sudo dd of=/dev/nvme0n1 bs=4M conv=fsync status=progress
It should be pretty quick.
4. Boot from SPI + NVMe
Now power off the ROCK Pi 4, remove the eMMC module or uSD card. With NVMe attached and boot.
You should see the green led on first, then red/blue led on, then red/blue led start blink. When blinking, it means it boots the kernel in NVMe.
Tested NVMe SSD
For some reason, some NVMe SSD can be recognized under Linux but failed on bootloader. Here is some models we tested.
Known booting:
- MaxMemory 128G: boots fine
- HP EX900: boots fine
- Kingbank 240G: boots fine
- Lenovo SL700: boots fine
Known not booting:
- Samsung EVO 960: it can detect gpt partition in NVMe but failed to load the kernel, no problem formatting or making fs under Linux. Maybe this SSD in our office is somehow defective.
/* Below is old content */
Dear community,
After fixing the bug of u-boot in SPI with NVMe driver, we have the working bootchain from SPI to NVMe now. The new u-boot package is pushed to the testing apt repository. Below is how to enable the SPI to NVMe boot chain.
deb http://apt.radxa.com/stretch-testing/ stretch main
or
deb http://apt.radxa.com/bionic-testing/ bionic main
To update to the latest testing repo, change your apt repo address to the testing one, and
sudo apt-get install rockpi4b-rk-u-boot-latest /usr/local/sbin/rockpi4b_upgrade_bootloader.sh
Edit
/boot/hw_intfc.conf
and enabled the following:intfc:uart4=off intfc:spi1=on intfc:dtoverlay=spi1-flash
Reboot, the SPI flash will be shown as /dev/mtd0 under Linux.
Use the script to flash the uboot image to SPI flash and type YES to perform the flash.
sudo /usr/local/sbin/rockpi4b_write_spi_flash.sh
Now we have the uboot image installed to SPI flash. It’s time to move the image to NVMe.
For new installation and simpacity, you can just download a fresh ROCK Pi 4 image(Android is not supported at the moment, other images should be all supported) dd the whole image to /dev/nvme0n1 on ROCK Pi 4.
For moving existing image from uSD or eMMC to NVMe disk, just dd
/dev/mmcblk0
or/dev/mmcblk1
to /dev/nvme0n1.sudo dd if=/dev/mmcblk0 conv=sync,noerror of=/dev/nvme0n1 bs=16M
or
sudo dd if=/dev/mmcblk1 conv=sync,noerror of=/dev/nvme0n1 bs=16M