Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: install os form nvme using SD card/eMMC as a boot disk #47

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,6 @@ en/zero/zero/radxa-os/remote-access.md @CodeChenL
static/img/rock3/3c/rock3c-8hd-overlay.webp @Radxa-Alvin
docs/nio/nio12l/install-yocto-system.md @Radxa-Alvin
i18n/en/docusaurus-plugin-content-docs/current/nio/nio12l/install-yocto-system.md @Radxa-Alvin
static/img/common/nvme/writing_mtd.webp @nascs
i18n/en/docusaurus-plugin-content-docs/current/common/dev/_nvme.mdx @nascs
static/img/common/nvme/success.webp @nascs
90 changes: 90 additions & 0 deletions docs/common/dev/_nvme.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Image } from "@site/src/utils/docs";
import { PreView } from "@site/src/utils/docs";

### 整体步骤:

- 准备一张 SD 卡或者 eMMC Module, 充当启动盘

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eMMC => eMMC Module

- 使用系统工具 rsetup 刷 SPI

- 将系统镜像刷到 NVME SSD 里面

- 拔掉 SD 卡/eMMC Module, 从 NVME 启动

### 准备一张 SD 卡或者 eMMC Module, 充当启动盘

参考<a href={props.install_os_path}>安装操作系统部分</a>将系统安装在 SD 卡/eMMC Module 当中。

这里 SD 卡/eMMC Module 的作用相当于 x86 的启动盘,目的是拿到 spi.img, 将 spi.img 刷到 spi flash 中。

从 SD 卡/eMMC Module 启动后,执行一下命令以更新系统:

```
sudo apt-get update
sudo apt-get full-upgrade
```

### 使用系统工具 rsetup 刷 SPI

<img
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片过大

src="/img/common/nvme/system_maintenance.webp"
width="700"
height="500"
alt="system maintenance"
/>

<img
src="/img/common/nvme/update_spi_bootloader.webp"
width="700"
alt="update spi bootloader"
/>

<Image
src="/img/common/nvme/rsetup-select-bootloader-#model#.webp"
model={props.model}
fallback={props.model}
width="700"
/>

<img src="/img/common/nvme/writing_mtd.webp" width="700" alt="writing to mtd" />

<img src="/img/common/nvme/success.webp" width="700" alt="success" />

### 将系统镜像刷到 NVME SSD 里面

确认 NVME 是否被系统识别,

<PreView params={{ model: props.model }}>
{`
radxa@#model#:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 14.5G 0 disk
├─mmcblk0p1 179:1 0 16M 0 part /config
└─mmcblk0p2 179:2 0 14.4G 0 part /
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
zram0 254:0 0 3.8G 0 disk [SWAP]
nvme0n1 259:0 0 238.5G 0 disk
`}
</PreView>

如上所示系统已经识别到 NVME SSD 即 nvme0n1。

将系统镜像拷贝到当前系统下,

<PreView params={{ model: props.model, release_num: props.release_num }}>
{`
PC Host: scp /path/to/img radxa@boardIP:/home/radxa/
例如:
scp ~/Download/#model#_debian_bullseye_xfce_#release_num#.img.xz [email protected]:/home/xxa/
`}
</PreView>

然后在**板子**上将系统镜像 dd 到 NVME 中。

<PreView params={{ model: props.model, release_num: props.release_num }}>
sudo xzcat /home/radxa/#model#_debian_bullseye_xfce_#release_num#.img.xz | dd
of=/dev/nvme0n1 bs=1M status=progress
</PreView>

### 拔掉 SD 卡/eMMC Module, 从 NVME 启动
9 changes: 9 additions & 0 deletions docs/rock3/rock3c/low-level-dev/install-os-on-nvme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 22
---

# 从 NVME 启动系统

import NVME from '../../../common/dev/\_nvme.mdx'

<NVME model="rock-3c" release_num="b42" install_os_path="../getting-started/install-os" />
73 changes: 3 additions & 70 deletions docs/rock5/rock5b/low-level-dev/install-os-on-nvme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,8 @@
sidebar_position: 22
---

import Etcher from '../../../common/general/\_etcher.mdx'
# 从 NVME 启动系统

# 安装系统到 NVME 固态硬盘上
import NVME from '../../../common/dev/\_nvme.mdx'

## 方案 1:使用 NVME 转 USB3.0 读卡器或带有 NVME 插槽的电脑

#### 准备工作

- ROCK 5B 主板
- 1x 5V 电源适配器(推荐 [Radxa Power PD30W](../accessories/pd-30w))
- 一个 M.2 NVME 固态硬盘
- NVME 转 USB3.0 读卡器或带 NVME 插槽的 PC

### 镜像下载

请前往 [资源下载摘要](/rock5/rock5b/getting-started/download.md) 下载相应的镜像文件。

### 使用 etcher 将镜像写入 M.2 NVME 固态硬盘

<Etcher model="rock5b" />

### 方案 2: 写入 ROCK 5B 上的 NVME 固态硬盘

### 准备工作

- ROCK 5B 主板
- 1x 5V 电源适配器(推荐 [Radxa Power PD30W](../accessories/pd-30w)
- 一个 M.2 NVME 固态硬盘
- NVME 转 USB3.0 读卡器或带 NVME 插槽的 PC
- SD 卡或 eMMC 模块

### 将 Debian Linux 镜像安装到 SD 卡或 eMMC 模块中

请参考[SD 卡/eMMC 系统安装指南](../getting-started/install-os) 将系统安装到 SD 卡/eMMC。

### 从连接有 NVME 固态硬盘的 ROCK 5B 上的 SD 卡或 eMMC 模块启动

### 在 ROCK 5B 上运行 Debian 时,下载 ROCK 5B 镜像

### 检查是否检测到 NVME 固态硬盘

在 ROCK 5B 上

```
sudo fdisk -l
```

你可以看到这样的输出信息:

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

#### 写镜像

在 ROCK 5B 上:

```
sudo sudo xzcat 'your compressed image path' | dd of='your NVME SSD device path' bs=1M status=progress
#例如: sudo xzcat rock-5b-debian-bullseye-xfce4-arm64-20220906-0626-gpt.img.xz | dd of=/dev/nvme0n1 bs=1M status=progress
```

## 方案 3:擦除 M.2 NVME 固态硬盘

当 M.2 NVME 固态硬盘之前使用安卓(或Linux)镜像写入时,现在我们改用Linux(或安卓)。建议先擦除 M.2 NVME SSD。然后写入目标镜像。

## 从 NVME 固态硬盘启动

将镜像写入 NVME SSD 后,要从 NVME SSD 启动,需要将引导加载程序写入 SPI 闪存。选中[安装到 SPI 以从 NVME SSD 启动](./bootloader_spi_flash)。
<NVME model="rock-5b" release_num="b39" install_os_path="../getting-started/install-os" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Image } from "@site/src/utils/docs";
import { PreView } from "@site/src/utils/docs";

### Overall steps:

- Prepare an SD card or eMMC Module as a boot disk.

- Use the system utility rsetup to flash the SPI.

- Flush the system image to the NVME SSD.

- Unplug the SD card/eMMC Module and boot from NVME.

### Prepare an SD card or eMMC Module as a boot disk.

Refer to the <a href={props.install_os_path}>Installing the OS section</a> to install the system on the SD card/eMMC Module.

Here the SD card/eMMC Module acts as a boot disk for x86, the purpose is to get the spi.img, and flush the spi.img to the spi flash.

After booting from the SD card/eMMC Module, execute the following command to update the system.

```
sudo apt-get update
sudo apt-get full-upgrade
```

### Use the system utility rsetup to flush the SPI.

<img
src="/img/common/nvme/system_maintenance.webp"
width="700"
height="500"
alt="system maintenance"
/>

<img
src="/img/common/nvme/update_spi_bootloader.webp"
width="700"
alt="update spi bootloader"
/>

<Image
src="/img/common/nvme/rsetup-select-bootloader-#model#.webp"
model={props.model}
fallback={props.model}
width="700"
/>

<img src="/img/common/nvme/writing_mtd.webp" width="700" alt="writing to mtd" />

<img src="/img/common/nvme/success.webp" width="700" alt="success" />

### Flashing the system image to the NVME SSD

Verify that NVME is recognized by the system.

<PreView params={{ model: props.model }}>
{`
radxa@#model#:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 14.5G 0 disk
├─mmcblk0p1 179:1 0 16M 0 part /config
└─mmcblk0p2 179:2 0 14.4G 0 part /config
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
zram0 254:0 0 3.8G 0 disk [SWAP]
nvme0n1 259:0 0 238.5G 0 disk
`}
</PreView>

As shown above the system has recognized the NVME SSD as nvme0n1.

Copy the system image to the current system.

<PreView params={{ model: props.model, release_num: props.release_num }}>
{`
PC Host: scp /path/to/img radxa@boardIP:/home/radxa/
Example:
scp ~/Download/#model#_debian_bullseye_xfce_#release_num#.img.xz [email protected]:/home/xxa/
`}
</PreView>

Then dd the system image into NVME on the **board**.

<PreView params={{ model: props.model, release_num: props.release_num }}>
sudo xzcat /home/radxa/#model#_debian_bullseye_xfce_#release_num#.img.xz | dd
of=/dev/nvme0n1 bs=1M status=progress
</PreView>

### Unplug SD card/eMMC Module, boot from NVME
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 22
---

# Boot the system from NVME

import NVME from '../../../common/dev/\_nvme.mdx'

<NVME model="rock-3c" release_num="b42" install_os_path="../getting-started/install-os" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,8 @@
sidebar_position: 22
---

import Etcher from '../../../common/general/\_etcher.mdx'
# Boot the system from NVME

# Install the system to NVME SSD
import NVME from '../../../common/dev/\_nvme.mdx'

## Option 1: with NVME to USB3.0 reader or PC with NVME slot

### Preparation

- ROCK 5B main board
- 1x 5V power adapter (recommended [Radxa Power PD30W](../accessories/pd-30w))
- One M.2 NVME SSD
- NVME to USB3.0 reader or a PC with NVME slot

### Image Download

Please go to [Resource Download Summary](/rock5/rock5b/getting-started/download.md) to download the corresponding image file.

### Write the image to M.2 NVME SSD with etcher

<Etcher model="rock5b" />

## Option 2: Write to NVME SSD on ROCK 5B

### Preparation

- ROCK 5B main board
- 1x 5V power adapter (recommended [Radxa Power PD30W](../accessories/pd-30w))
- One M.2 NVME SSD
- NVME to USB3.0 reader or a PC with NVME slot
- SD card or eMMC module

### Install Debian Linux image to SD card or eMMC module

Please refer to the [System Installation Guide for SD Card/eMMC](../getting-started/install-os) to install the system to SD Card/eMMC.

### Boot from SD card or eMMC module on ROCK 5B with NVME SSD attached

### Download the ROCK 5B image when running Debian on ROCK 5B

### Check if NVME SSD is detected

On ROCK 5B:

```
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 devicpath
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

On ROCK 5B:

```
sudo sudo xzcat 'your compressed image path' | dd of='your NVME SSD device path' bs=1M status=progress
#such as: sudo xzcat rock-5b-debian-bullseye-xfce4-arm64-20220906-0626-gpt.img.xz | dd of=/dev/nvme0n1 bs=1M status=progress
```

## Option 3: Erase M.2 NVME SSD

When M.2 NVME SSD is written with Android (or Linux) images before, now we change to Linux (or Android). It's recommended that you erase M.2 NVME SSD first. Then write the target images.

## Boot from NVME SSD

After you write the image to NVME SSD, to boot from the NVME SSD, you need to write the bootloader to SPI flash. Check [Install to SPI to boot from NVME SSD](./bootloader_spi_flash).
<NVME model="rock-5b" release_num="b39" install_os_path="../getting-started/install-os" />
Binary file not shown.
Binary file not shown.
Binary file added static/img/common/nvme/success.webp
Binary file not shown.
Binary file added static/img/common/nvme/system_maintenance.webp
Binary file not shown.
Binary file not shown.
Binary file added static/img/common/nvme/writing_mtd.webp
Binary file not shown.
Loading