树莓派5 PCIe转M.2 NVMe "PCIe gen4" SSD存储报错记录

我原本计划 树莓派5 PCIe转M.2 NVMe SSD存储 采用 铠侠KIOXIA EXCERIA G2 NVMe SSD存储 ,但是淘宝商家发错成 kioxia EXCERIA Plus 版本,也就是 PCIe gen4 规格的NVMe。从官方文档来看,树莓派似乎只能工作于PCIe gen2 和 gen3,其中gen 3模式需要特定激活。

和商家协商后准备寄还错发的 kioxia EXCERIA Plus` PCIe gen4 ,换成正确的 铠侠KIOXIA EXCERIA G2 NVMe SSD存储 。不过,此时我已经拿到 微雪电子 树莓派5 PCIe转M.2转接板 D型 ,就在想是否可以用我曾经购买过 PCIe gen 4三星PM9A1 NVMe存储 试试。毕竟 PCIe gen 4 号称是兼容 PCIe gen 3 ,如果测试成功,也可以避免重复投资购买 NVMe存储 存储。

警告

现在回看当时尝试其实存在没有注意到的疏忽,所以我在 更新三星PM9A1 NVMe存储firmware 实践中修复了使用 三星PM9A1 NVMe存储 ,本文仅记录当时的尝试。

实际上,2021年购买的 三星PM9A1 NVMe存储 的firmware存在缺陷,无法用于USB移动硬盘,也无法用于 树莓派Raspberry Pi 5 的PCIe转接 M.2 NVMe。通过升级到新版本firmware可以解决本文遇到的识别问题。

默认 pcie 2 模式

默认没有激活 pcie 3 ,所以 树莓派Raspberry Pi 5 启动的是 pcie 2 模式。我通过 树莓派5 UART串口通讯 观察看到如下日志,显示 NVMe 存储识别,但是无法工作:

默认 pcie 2 模式下,识别到 gen 4 的NVMe设备但无法工作
...
[    1.764300] brcm-pcie 1000110000.pcie: host bridge /axi/pcie@110000 ranges:
[    1.771301] brcm-pcie 1000110000.pcie:   No bus range found for /axi/pcie@110000, using [bus 00-ff]
[    1.780396] brcm-pcie 1000110000.pcie:      MEM 0x1b00000000..0x1bfffffffb -> 0x0000000000
[    1.788699] brcm-pcie 1000110000.pcie:      MEM 0x1800000000..0x1affffffff -> 0x0400000000
[    1.797002] brcm-pcie 1000110000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[    1.806481] brcm-pcie 1000110000.pcie: Forcing gen 2
[    1.811674] brcm-pcie 1000110000.pcie: PCI host bridge to bus 0000:00
[    1.818141] pci_bus 0000:00: root bus resource [bus 00-ff]
[    1.823649] pci_bus 0000:00: root bus resource [mem 0x1b00000000-0x1bfffffffb] (bus address [0x00000000-0xfffffffb])
[    1.834219] pci_bus 0000:00: root bus resource [mem 0x1800000000-0x1affffffff pref] (bus address [0x400000000-0x6ff)
[    1.845411] pci 0000:00:00.0: [14e4:2712] type 01 class 0x060400
[    1.851466] pci 0000:00:00.0: PME# supported from D0 D3hot
[    1.857856] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    1.970147] brcm-pcie 1000110000.pcie: link up, 5.0 GT/s PCIe x1 (!SSC)
[    1.976811] pci 0000:01:00.0: [144d:a80a] type 00 class 0x010802
[    1.982861] pci 0000:01:00.0: reg 0x10: [mem 0x1b00000000-0x1b00003fff 64bit]
[    1.990215] pci 0000:01:00.0: 4.000 Gb/s available PCIe bandwidth, limited by 5.0 GT/s PCIe x1 link at 0000:00:00.0)
[    2.014166] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    2.020815] pci 0000:00:00.0: BAR 8: assigned [mem 0x1b00000000-0x1b000fffff]
[    2.027982] pci 0000:01:00.0: BAR 0: assigned [mem 0x1b00000000-0x1b00003fff 64bit]
[    2.035679] pci 0000:00:00.0: PCI bridge to [bus 01]
[    2.040662] pci 0000:00:00.0:   bridge window [mem 0x1b00000000-0x1b000fffff]
[    2.047829] pci 0000:00:00.0: Max Payload Size set to  256/ 512 (was  128), Max Read Rq  512
[    2.056311] pci 0000:01:00.0: Max Payload Size set to  256/ 256 (was  128), Max Read Rq  512
[    2.064841] pcieport 0000:00:00.0: enabling device (0000 -> 0002)
[    2.070994] pcieport 0000:00:00.0: PME: Signaling with IRQ 38
[    2.076832] pcieport 0000:00:00.0: AER: enabled with IRQ 38
[    2.082561] nvme nvme0: pci function 0000:01:00.0
[    2.087300] nvme 0000:01:00.0: enabling device (0000 -> 0002)
[   62.778158] nvme nvme0: I/O 13 QID 0 timeout, disable controller
[   62.786204] nvme nvme0: Device not ready; aborting shutdown, CSTS=0x1
[   62.806249] nvme: probe of 0000:01:00.0 failed with error -4
[   62.811949] brcm-pcie 1000110000.pcie: clkreq control enabled
[   62.817775] brcm-pcie 1000120000.pcie: host bridge /axi/pcie@120000 ranges:
[   62.824769] brcm-pcie 1000120000.pcie:   No bus range found for /axi/pcie@120000, using [bus 00-ff]
[   62.833862] brcm-pcie 1000120000.pcie:      MEM 0x1f00000000..0x1ffffffffb -> 0x0000000000
[   62.842165] brcm-pcie 1000120000.pcie:      MEM 0x1c00000000..0x1effffffff -> 0x0400000000
[   62.850470] brcm-pcie 1000120000.pcie:   IB MEM 0x1f00000000..0x1f003fffff -> 0x0000000000
[   62.858772] brcm-pcie 1000120000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[   62.868143] brcm-pcie 1000120000.pcie: Forcing gen 2
[   62.873160] brcm-pcie 1000120000.pcie: PCI host bridge to bus 0001:00
[   62.879628] pci_bus 0001:00: root bus resource [bus 00-ff]
[   62.885135] pci_bus 0001:00: root bus resource [mem 0x1f00000000-0x1ffffffffb] (bus address [0x00000000-0xfffffffb])
[   62.895705] pci_bus 0001:00: root bus resource [mem 0x1c00000000-0x1effffffff pref] (bus address [0x400000000-0x6ff)
[   62.906898] pci 0001:00:00.0: [14e4:2712] type 01 class 0x060400
[   62.912949] pci 0001:00:00.0: PME# supported from D0 D3hot
[   62.919326] pci 0001:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[   63.034144] brcm-pcie 1000120000.pcie: link up, 5.0 GT/s PCIe x4 (!SSC)
[   63.040803] pci 0001:01:00.0: [1de4:0001] type 00 class 0x020000
[   63.046846] pci 0001:01:00.0: reg 0x10: [mem 0xffffc000-0xffffffff]
[   63.053143] pci 0001:01:00.0: reg 0x14: [mem 0xffc00000-0xffffffff]
[   63.059439] pci 0001:01:00.0: reg 0x18: [mem 0xffff0000-0xffffffff]
[   63.065798] pci 0001:01:00.0: supports D1
[   63.069819] pci 0001:01:00.0: PME# supported from D0 D1 D3hot D3cold
[   63.086150] pci_bus 0001:01: busn_res: [bus 01-ff] end is updated to 01
[   63.092799] pci 0001:00:00.0: BAR 8: assigned [mem 0x1f00000000-0x1f005fffff]
[   63.099966] pci 0001:01:00.0: BAR 1: assigned [mem 0x1f00000000-0x1f003fffff]
[   63.107134] pci 0001:01:00.0: BAR 2: assigned [mem 0x1f00400000-0x1f0040ffff]
[   63.114301] pci 0001:01:00.0: BAR 0: assigned [mem 0x1f00410000-0x1f00413fff]
[   63.121468] pci 0001:00:00.0: PCI bridge to [bus 01]
[   63.126450] pci 0001:00:00.0:   bridge window [mem 0x1f00000000-0x1f005fffff]
[   63.133616] pci 0001:00:00.0: Max Payload Size set to  256/ 512 (was  128), Max Read Rq  512
[   63.142097] pci 0001:01:00.0: Max Payload Size set to  256/ 256 (was  128), Max Read Rq  512
[   63.150637] pcieport 0001:00:00.0: enabling device (0000 -> 0002)
[   63.156789] pcieport 0001:00:00.0: PME: Signaling with IRQ 39
[   63.162617] pcieport 0001:00:00.0: AER: enabled with IRQ 39
...

激活 pcie 3 模式

  • 修改 /boot/firmware/config.txt 设置:

配置激活 PCIe gen 3
[all]
dtparam=nvme
dtparam=pciex1_gen=3

可以看到确实激活了 pcie 3 模式,但是很不幸,无法正常使用 PCIe gen 4三星PM9A1 NVMe存储

强制激活 pcie 3 模式下,但是依然无法使用 gen 4 的NVMe设备 三星PM9A1 NVMe存储
[    1.763943] brcm-pcie 1000110000.pcie: host bridge /axi/pcie@110000 ranges:
[    1.770947] brcm-pcie 1000110000.pcie:   No bus range found for /axi/pcie@110000, using [bus 00-ff]
[    1.780045] brcm-pcie 1000110000.pcie:      MEM 0x1b00000000..0x1bfffffffb -> 0x0000000000
[    1.788348] brcm-pcie 1000110000.pcie:      MEM 0x1800000000..0x1affffffff -> 0x0400000000
[    1.796652] brcm-pcie 1000110000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[    1.806127] brcm-pcie 1000110000.pcie: Forcing gen 3
[    1.811311] brcm-pcie 1000110000.pcie: PCI host bridge to bus 0000:00
[    1.817780] pci_bus 0000:00: root bus resource [bus 00-ff]
[    1.823288] pci_bus 0000:00: root bus resource [mem 0x1b00000000-0x1bfffffffb] (bus address [0x00000000-0xfffffffb])
[    1.833859] pci_bus 0000:00: root bus resource [mem 0x1800000000-0x1affffffff pref] (bus address [0x400000000-0x6ffffffff])
[    1.845049] pci 0000:00:00.0: [14e4:2712] type 01 class 0x060400
[    1.851103] pci 0000:00:00.0: PME# supported from D0 D3hot
[    1.857487] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    1.986228] brcm-pcie 1000110000.pcie: link up, 8.0 GT/s PCIe x1 (!SSC)
[    1.992890] pci 0000:01:00.0: [144d:a80a] type 00 class 0x010802
[    1.998936] pci 0000:01:00.0: reg 0x10: [mem 0x1b00000000-0x1b00003fff 64bit]
[    2.006263] pci 0000:01:00.0: 7.876 Gb/s available PCIe bandwidth, limited by 8.0 GT/s PCIe x1 link at 0000:00:00.0 (capable of 63.012 Gb/s with 16.0 GT/s PCIe x4 link)
[    2.030249] pci_bus 0000:01: busn_res: [bus 01-ff] end is updated to 01
[    2.036898] pci 0000:00:00.0: BAR 8: assigned [mem 0x1b00000000-0x1b000fffff]
[    2.044065] pci 0000:01:00.0: BAR 0: assigned [mem 0x1b00000000-0x1b00003fff 64bit]
[    2.051761] pci 0000:00:00.0: PCI bridge to [bus 01]
[    2.056744] pci 0000:00:00.0:   bridge window [mem 0x1b00000000-0x1b000fffff]
[    2.063911] pci 0000:00:00.0: Max Payload Size set to  256/ 512 (was  128), Max Read Rq  512
[    2.072391] pci 0000:01:00.0: Max Payload Size set to  256/ 256 (was  128), Max Read Rq  512
[    2.080922] pcieport 0000:00:00.0: enabling device (0000 -> 0002)
[    2.087076] pcieport 0000:00:00.0: PME: Signaling with IRQ 38
[    2.092897] pcieport 0000:00:00.0: AER: enabled with IRQ 38
[    2.098617] nvme nvme0: pci function 0000:01:00.0
[    2.103354] nvme 0000:01:00.0: enabling device (0000 -> 0002)
[   62.778247] nvme nvme0: I/O 1 QID 0 timeout, disable controller
[   62.788206] nvme nvme0: Device not ready; aborting shutdown, CSTS=0x1
[   62.810336] nvme: probe of 0000:01:00.0 failed with error -4
[   62.816036] brcm-pcie 1000110000.pcie: clkreq control enabled
[   62.821858] brcm-pcie 1000120000.pcie: host bridge /axi/pcie@120000 ranges:
[   62.828851] brcm-pcie 1000120000.pcie:   No bus range found for /axi/pcie@120000, using [bus 00-ff]
[   62.837944] brcm-pcie 1000120000.pcie:      MEM 0x1f00000000..0x1ffffffffb -> 0x0000000000
[   62.846249] brcm-pcie 1000120000.pcie:      MEM 0x1c00000000..0x1effffffff -> 0x0400000000
[   62.854554] brcm-pcie 1000120000.pcie:   IB MEM 0x1f00000000..0x1f003fffff -> 0x0000000000
[   62.862856] brcm-pcie 1000120000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[   62.872226] brcm-pcie 1000120000.pcie: Forcing gen 2
[   62.877246] brcm-pcie 1000120000.pcie: PCI host bridge to bus 0001:00
[   62.883714] pci_bus 0001:00: root bus resource [bus 00-ff]
[   62.889221] pci_bus 0001:00: root bus resource [mem 0x1f00000000-0x1ffffffffb] (bus address [0x00000000-0xfffffffb])
[   62.899791] pci_bus 0001:00: root bus resource [mem 0x1c00000000-0x1effffffff pref] (bus address [0x400000000-0x6ffffffff])
[   62.910980] pci 0001:00:00.0: [14e4:2712] type 01 class 0x060400
[   62.917031] pci 0001:00:00.0: PME# supported from D0 D3hot
[   62.923415] pci 0001:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[   63.038229] brcm-pcie 1000120000.pcie: link up, 5.0 GT/s PCIe x4 (!SSC)
[   63.044890] pci 0001:01:00.0: [1de4:0001] type 00 class 0x020000
[   63.050932] pci 0001:01:00.0: reg 0x10: [mem 0xffffc000-0xffffffff]
[   63.057229] pci 0001:01:00.0: reg 0x14: [mem 0xffc00000-0xffffffff]
[   63.063525] pci 0001:01:00.0: reg 0x18: [mem 0xffff0000-0xffffffff]
[   63.069884] pci 0001:01:00.0: supports D1
[   63.073906] pci 0001:01:00.0: PME# supported from D0 D1 D3hot D3cold
[   63.090236] pci_bus 0001:01: busn_res: [bus 01-ff] end is updated to 01
[   63.096884] pci 0001:00:00.0: BAR 8: assigned [mem 0x1f00000000-0x1f005fffff]
[   63.104051] pci 0001:01:00.0: BAR 1: assigned [mem 0x1f00000000-0x1f003fffff]
[   63.111218] pci 0001:01:00.0: BAR 2: assigned [mem 0x1f00400000-0x1f0040ffff]
[   63.118385] pci 0001:01:00.0: BAR 0: assigned [mem 0x1f00410000-0x1f00413fff]
[   63.125552] pci 0001:00:00.0: PCI bridge to [bus 01]
[   63.130535] pci 0001:00:00.0:   bridge window [mem 0x1f00000000-0x1f005fffff]
[   63.137702] pci 0001:00:00.0: Max Payload Size set to  256/ 512 (was  128), Max Read Rq  512
[   63.146182] pci 0001:01:00.0: Max Payload Size set to  256/ 256 (was  128), Max Read Rq  512
[   63.154716] pcieport 0001:00:00.0: enabling device (0000 -> 0002)
[   63.160867] pcieport 0001:00:00.0: PME: Signaling with IRQ 39
[   63.166690] pcieport 0001:00:00.0: AER: enabled with IRQ 39

实验失败,准备继续等待换回 铠侠KIOXIA EXCERIA G2 NVMe SSD存储 ( PCIe gen 3 SSD存储)再测试