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

Can't boot Pi 5 via NVMe behind PCIe switch / bridge #1833

Open
geerlingguy opened this issue Oct 17, 2023 · 61 comments
Open

Can't boot Pi 5 via NVMe behind PCIe switch / bridge #1833

geerlingguy opened this issue Oct 17, 2023 · 61 comments
Assignees

Comments

@geerlingguy
Copy link

geerlingguy commented Oct 17, 2023

Describe the bug

I am unable to boot a Raspberry Pi 5 from an external NVMe SSD if used behind a PCIe switch (e.g. not as the root device on the external connection).

To reproduce

  1. Ensure you have an NVMe SSD that can boot the Raspberry Pi 5 when connected directly. (BOOT_ORDER=0xf25416)
  2. Connect a PCI Express switch to the external PCIe connection on the Raspberry Pi 5.
  3. Move the NVMe SSD you previously used to boot the Pi 5 to a port behind the PCIe switch.
  4. Attempt to boot the Raspberry Pi 5 off the NVMe SSD.

Expected behaviour

I would expect the NVMe SSD to be selected for boot, wherever it is enumerated on the PCIe bus.

Actual behaviour

The Raspberry Pi 5 bootloader attempts to load nvme but fails, likely due to it only enumerating devices directly attached to the external port, and not walking down the tree of any other connected PCIe bridges...

System
Copy and paste the results of the raspinfo command in to this section. Alternatively, copy and paste a pastebin link, or add answers to the following questions:

  • Which model of Raspberry Pi? e.g. Pi3B+, PiZeroW
  • Which OS and version (cat /etc/rpi-issue)?
  • Which firmware version (vcgencmd version)?
  • Which kernel version (uname -a)?

Logs

Click to expand full bootloader log (captured via UART)
RPi: BOOTSYS release VERSION:9d494316 DATE: 2023/09/13 TIME: 11:37:06
BOOTMODE: 0x06 partition 0 build-ts BUILD_TIMESTAMP=1694601426 serial e3ae743b boardrev d04170 stc 1604502
AON_RESET: 00000003 PM_RSTS 00001000
RP1_BOOT chip ID: 0x20001927
PM_RSTS: 0x00001000
part 00000000 reset_info 00000000
PMIC reset-event 00000000 rtc 65299da7 alarm 00000000 enabled 0
uSD voltage 3.3V
Initialising SDRAM 'Micron' 32Gb x2 total-size: 64 Gbit 4267
DDR 4267 1 0 64 152
RP1_BOOT chip ID: 0x20001927

RP1_BOOT chip ID: 0x20001927
RP1_BOOT: fw size 25968
PCI2 init
PCI2 reset
PCIe scan 00001de4:00000001
RP1_CHIP_INFO 20001927

RPi: BOOTLOADER release VERSION:9d494316 DATE: 2023/09/13 TIME: 11:37:06
BOOTMODE: 0x06 partition 0 build-ts BUILD_TIMESTAMP=1694601426 serial e3ae743b boardrev d04170 stc 4469863
AON_RESET: 00000003 PM_RSTS 00001000
 status
USB_PD CONFIG 0 43
Boot mode: NVME (06) order f41
PCI1 init
PCI1 reset
USB-PD: src-cap PDO object1 0x0a0191f4
Current 5000 mA
Voltage 5000 mV
USB-PD: src-cap PDO object2 0x0002d12c
Current 3000 mA
Voltage 9000 mV
USB-PD: src-cap PDO object3 0x0003c0e1
Current 2250 mA
Voltage 12000 mV
USB-PD: src-cap PDO object4 0x0004b0b4
Current 1800 mA
Voltage 15000 mV
Failed to open device: 'nvme'
Retry NVME 1
Failed to open device: 'nvme'
Boot mode: SD (01) order f4
SD HOST: 200000000 CTL0: 0x00800f00 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD HOST: 200000000 CTL0: 0x00800f00 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
EMMC
SD retry 1 oc 0
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD retry 2 oc 0
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SDV1
SD CMD: 0x371a0010 (55) 0x0 0x1fff0001
Failed to open device: 'sdcard' (cmd 371a0010 status 1fff0001)
Retry SD 1
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD HOST: 200000000 CTL0: 0x00800f00 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
EMMC
SD retry 1 oc 0
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD retry 2 oc 0
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SDV1
SD CMD: 0x371a0010 (55) 0x0 0x1fff0001
Failed to open device: 'sdcard' (cmd 371a0010 status 1fff0001)
Boot mode: USB-MSD (04) order f
XHCI-STOP
xHC0 ver: 0 HCS: 00000085 00000085 00000085 HCC: 00000085
USBSTS 85
xHC0 ver: 0 HCS: 00000085 00000085 00000085 HCC: 00000085
xHC0 ports 0 slots 133 intrs 0
USB xHC init failed
Boot mode: RESTART (0f) order 0
Restart 0 max -1
Boot mode: NVME (06) order f41
PCI1 init
PCI1 reset
Failed to open device: 'nvme'
Retry NVME 1
Failed to open device: 'nvme'

Additional context

When behind the bridge, here is the hierarchy according to lspci:

pi@pi5:~ $ lspci -tv
-+-[0000:00]---00.0-[01-04]----00.0-[02-04]--+-01.0-[03]--
 |                                           \-02.0-[04]----00.0  KIOXIA Corporation Device 0010
 \-[0001:00]---00.0-[01]----00.0  Device 1de4:0001

I know for the Compute Module 4, the concern was a lack of space in the bootloader to successfully enumerate all PCIe devices, no matter where they are on the bus. Does the Pi 5's bootloader overcome that limitation? I don't expect this to work on launch day, but it is something I think a lot of people would like to do (e.g. stack an 'NVMe + 2.5G Ethernet' HAT, or 'NVMe + WiFi 7' HAT, etc. on top).

@timg236
Copy link

timg236 commented Oct 17, 2023

It's not supported right now

@peterharperuk
Copy link

What "PCIe switch" do you have?

@geerlingguy
Copy link
Author

@peterharperuk - I'm testing with this I/O Crest switch:

pi@pi5:~ $ lspci
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
0000:01:00.0 PCI bridge: Pericom Semiconductor PI7C9X2G304 EL/SL PCIe2 3-Port/4-Lane Packet Switch (rev 05)
0000:02:01.0 PCI bridge: Pericom Semiconductor PI7C9X2G304 EL/SL PCIe2 3-Port/4-Lane Packet Switch (rev 05)
0000:02:02.0 PCI bridge: Pericom Semiconductor PI7C9X2G304 EL/SL PCIe2 3-Port/4-Lane Packet Switch (rev 05)
0000:04:00.0 Non-Volatile memory controller: KIOXIA Corporation Device 0010 (rev 01)
0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
0001:01:00.0 Ethernet controller: Device 1de4:0001

@cnxsoft
Copy link

cnxsoft commented Feb 4, 2024

I've just come across a HAT+ (Geekworm X1004) with an ASM1182e PCIe switch for two SSDs and the manufacturer claims it can't be used for booting at this time. It looks related.

@geerlingguy
Copy link
Author

@cnxsoft - It is most definitely related! And thanks for you post on that board, I really do hope Raspberry Pi can support at least a few switches (the asmedia ones seem extremely popular for smaller companies. I don't see Pericom that often).

@ghakfoort
Copy link

I heard the guys from Pineberry are also already experimenting with a hat that supports 2 m.2 devices... (no promises though.. ) 2 NVME drives or 1 NVME drive and room for a pcie coral TPU would be nice but of course we need to be able to boot from it too if a pcie switch is involved :)

@peterharperuk peterharperuk self-assigned this Feb 7, 2024
@raspberrypi raspberrypi deleted a comment from pbrueckner Feb 19, 2024
@timg236
Copy link

timg236 commented Feb 19, 2024

Removed off topic comment about a CM4. This issue is specifically about Pi5 / BCM2712

@pelwell
Copy link
Contributor

pelwell commented Feb 24, 2024

That's covered in the documentation. From https://www.raspberrypi.com/documentation/computers/raspberry-pi-5.html#pcie-gen-3-0:

The Raspberry Pi 5 is not certified for Gen 3.0 speeds, and connections to PCIe devices at these speeds may be unstable.

If Gen 3 was guaranteed to be stable then it would be enabled by default.

@geerlingguy
Copy link
Author

@Ronald1817 - The title of this GitHub issue is "Can't boot Pi 5 via NVMe behind PCIe switch / bridge" and is meant to discuss that topic, not general NVMe SSD issues you may be having. The Raspberry Pi forums, or the manufacturer of the HAT / Bottom you're using, would be a better avenue for questions about Pi boot issues with NVMe.

That is all that is implied by @timg236—this GitHub repository is for issues pertaining to the Pi firmware, and this issue is about a specific feature request. These comments don't have anything to do with that, so typically the maintainers will clean them out at some point.

@greyltc
Copy link

greyltc commented Mar 15, 2024

A new dual NVMe rpi5 product has appeared with a PCIe switch in it https://pimoroni.com/nvmeduo
Anyone know what the switch part number is?

@geerlingguy
Copy link
Author

@greyltc - Looks like ASM1182e. Same as the Geekworm—and Pineberry Pi!

@timg236 / @pelwell — it seems like by some stroke of luck, all the main vendors of PCIe addon boards have settled on the asmedia ASM1182e as their PCIe gen 2 switch of choice... would it be possible for that chip (at least for now) to be supported for switch traversal for NVMe boot?

@Phlogistons
Copy link

https://pineberrypi.com/products/hatdrive-ai-coral-edge-tpu-bundle-nvme-2230-2242-gen-2-for-raspberry-pi-5
This new very sweet toy is also going to use the ASMedia switch, at this point I guess it's going to be the "standard" for most devices.

@rushtoshankar
Copy link

rushtoshankar commented Apr 5, 2024

Recently I have bought an PCIe HAT from aliexpress.com. The link is https://www.aliexpress.us/item/3256806347359812.html.
This has one 2.5Gb Eth and one NVM. This board has the 'ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch'. I have installed an NVMe drive of 512G from my old laptop. I had issues booting it from. Then switched back to SD card boot using EEPROM recovery image.

But I found two interesting things:

  • First, I was able to use NVMe for OS
  • Second, I was able to fully boot from NVMe (without setting the boot order to NVMe but with the help of SD card)

Let me explain below what I did, I didn't go in depth to find out how it worked. But at a high level,

  • To make bootable NVMe, instead of installing from the scratch in the NVMe, I just did a 'dd' from SD card to NVMe (This copied the UUIDs as well)
  • Then changed the boot order to NVMe and removed the SD card
  • First many attempts to boot from NVMe without SD card didn't work.
  • Next, I have updated the boot order back to SD card and used my original SD card (which was used to duplicate to NVMe)
  • Then it booted, I thought it booted from SD card.
    But when I checked, the mounted partitions, I saw, the /boot/firmware was from SD card and the '/' (root) partition was from my NVMe. So basically, the OS was running on NVMe.

I didn't know what I did except expanding the root partition size to utilize the full NVMe (512G) size, (SD card was 128G), I resized the partition in NVMe. While preparing to answer this, I found that the below in lsblk command.

mmcblk0 179:0 0 116.2G 0 disk
├─mmcblk0p1 179:1 0 512M 0 part
└─mmcblk0p2 179:2 0 115.7G 0 part
nvme0n1 259:0 0 476.9G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/firmware
└─nvme0n1p2 259:2 0 476.4G 0 part /

Both boot and root partitions are used from NVMe only. Now this is running as my home router / gateway. So, I can't do much tests immediately. But I will try to reboot multiple times/ try without SD card and see what's happening when I get a chance and post it here.

@mahtin
Copy link

mahtin commented Apr 6, 2024

Can I please add the ASM1184e PCIe packet switch chip to this issue? It shows up on the ZS ZHISHANG PCI-E X1 to 4 PCI-E X16 Expansion Riser as documented by @geerlingguy.

The ASM1182e is mentioned above. It's a 2 by PCIe chip vs the ASM1184e which is 4 by PCIe chip; so similar(ish).

Boards available on Amazon via:

I will note that this PCIe bridge works fine once the system is booted.

@timg236
Copy link

timg236 commented Apr 12, 2024

@greyltc - Looks like ASM1182e. Same as the Geekworm—and Pineberry Pi!

@timg236 / @pelwell — it seems like by some stroke of luck, all the main vendors of PCIe addon boards have settled on the asmedia ASM1182e as their PCIe gen 2 switch of choice... would it be possible for that chip (at least for now) to be supported for switch traversal for NVMe boot?

In principle any switch that follows the spec should work with generic firmware (once written). Supporting / debugging individual switch/PCIe devices would be up to the HAT designer i.e. debugging low level electronic issues.

@timg236
Copy link

timg236 commented Apr 12, 2024

To be clear, my obeys the spec I mean that anything that requires a ton of quirks an interop fixes just won't be supported. No immediate plans to do this though

@timg236
Copy link

timg236 commented Apr 12, 2024

Go easy with the adverts...

Wasn’t trying to plug anything, just geeking out over the tech specs a bit too much, maybe. There are no other solutions like this so it was almost impossible to keep the name of the board out of the discussion. Thanks for the nudge!

Going back to the topic. If someone desperately needs to boot from NVMe/SATA behind the switch it works with both the UEFI approach and uboot(it applies to the CM4 too). Having to place a secondary bootloader on the SD card is not perfect but no changes are required to the OS itself and this is a huge plus.

Agreed. The intention would be to support booting from an NVMe driver behind a switch, probably only simple hardware topologies would be supported

@geerlingguy
Copy link
Author

geerlingguy commented Apr 12, 2024

@timg236 - The other use case I have is to have multiple boot drives in a compact solution, so a Pi could boot into different OSes more easily than with a bunch of USB stuff hanging off it (or PXE boot). That... would be interesting to do from the Pi OS default firmware experience, though a UEFI bootloader could have boot order priority.

I don't know the default way the bootloader picks which device to boot from first, if there are multiple on one bus like USB. Is it by device ID?

@timg236
Copy link

timg236 commented Apr 12, 2024

The bootloader enumerates MSD in parallel and you get the first one that looks like valid OS. It’s mentioned in the msd docs.
The design goal is to do the right thing based on hardware detection and sensible defaults without ever inflicting a PC BIOS style UI on the end user. That said there’s scope for advanced users to have more flexibility eg via boot loader config specified GUIDs or ids. It very much a second order feature

@raspberrypi raspberrypi deleted a comment from Ronald1817 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from Ronald1817 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from Ronald1817 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from Ronald1817 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from Ronald1817 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from b0n541 Apr 23, 2024
@raspberrypi raspberrypi deleted a comment from EnziinSystem Apr 23, 2024
@peterharperuk
Copy link

@geerlingguy The output of lspci would be interesting. To fully debug you devices I'd need the output of "sudo lspci -xxx" If you attach it as a file I'll try and take a look. If you see the same problems when booting from an SD card with rootfs on the NVMe disk then that would rule out your issues being caused by some side effect from the bootloader.

@mikegapinski
Copy link

@peterharperuk it seems like the Phison E13 controller has aspm issues behind the switch. The latest firmware is dated August 2022, maybe they'll update it at some point. I tested all the problematic drives from WD and they boot normally with ASM1182 and the latest firmware.

@geerlingguy instead of globally disabling aspm please use: dtparam=pciex1_no_l0s=on and it'll work fine.

mgapinski@nvmebootpi:~$ sudo fio nvme-read.fio
nvme0: (g=0): rw=read, bs=(R) 256KiB-256KiB, (W) 256KiB-256KiB, (T) 256KiB-256KiB, ioengine=libaio, iodepth=32
fio-3.33
Starting 1 process
Jobs: 1 (f=1): [R(1)][100.0%][r=430MiB/s][r=1718 IOPS][eta 00m:00s]
nvme0: (groupid=0, jobs=1): err= 0: pid=2040: Tue May 14 12:29:45 2024
  read: IOPS=1715, BW=429MiB/s (450MB/s)(12.6GiB/30019msec)
    slat (nsec): min=8463, max=58890, avg=10840.75, stdev=605.38
    clat (usec): min=9271, max=36096, avg=18632.93, stdev=407.18
     lat (usec): min=9297, max=36107, avg=18643.77, stdev=407.15
    clat percentiles (usec):
     |  1.00th=[17695],  5.00th=[18220], 10.00th=[18482], 20.00th=[18744],
     | 30.00th=[18744], 40.00th=[18744], 50.00th=[18744], 60.00th=[18744],
     | 70.00th=[18744], 80.00th=[18744], 90.00th=[18744], 95.00th=[19006],
     | 99.00th=[19792], 99.50th=[20055], 99.90th=[21365], 99.95th=[25035],
     | 99.99th=[33162]
   bw (  KiB/s): min=438272, max=441344, per=100.00%, avg=439603.37, stdev=500.65, samples=60
   iops        : min= 1712, max= 1724, avg=1717.15, stdev= 1.95, samples=60
  lat (msec)   : 10=0.01%, 20=99.43%, 50=0.62%
  cpu          : usr=0.33%, sys=2.47%, ctx=51429, majf=0, minf=9
  IO depths    : 1=0.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=100.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.1%, 64=0.0%, >=64=0.0%
     issued rwts: total=51505,0,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=32

Run status group 0 (all jobs):
   READ: bw=429MiB/s (450MB/s), 429MiB/s-429MiB/s (450MB/s-450MB/s), io=12.6GiB (13.5GB), run=30019-30019msec

Disk stats (read/write):
  nvme0n1: ios=60086/35, merge=0/14, ticks=1119131/482, in_queue=1119622, util=99.75%
mgapinski@nvmebootpi:~$ lspci -vvvv
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21) (prog-if 00 [Normal decode])
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 38
        Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
        Memory behind bridge: 00000000-000fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit]
        Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
        BridgeCtl: Parity- SERR- NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Capabilities: <access denied>
        Kernel driver in use: pcieport

0000:01:00.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch (prog-if 00 [Normal decode])
        Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 38
        Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
        I/O behind bridge: 0000f000-00000fff [disabled] [32-bit]
        Memory behind bridge: 00000000-000fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit]
        Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
        BridgeCtl: Parity- SERR+ NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Capabilities: <access denied>
        Kernel driver in use: pcieport

0000:02:03.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch (prog-if 00 [Normal decode])
        Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Control: I/O- Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 40
        Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: 0000f000-00000fff [disabled] [32-bit]
        Memory behind bridge: fff00000-000fffff [disabled] [32-bit]
        Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit]
        Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
        BridgeCtl: Parity- SERR+ NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Capabilities: <access denied>
        Kernel driver in use: pcieport

0000:02:07.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch (prog-if 00 [Normal decode])
        Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 41
        Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
        I/O behind bridge: 0000f000-00000fff [disabled] [32-bit]
        Memory behind bridge: 00000000-000fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit]
        Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
        BridgeCtl: Parity- SERR+ NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Capabilities: <access denied>
        Kernel driver in use: pcieport

0000:04:00.0 Non-Volatile memory controller: Phison Electronics Corporation PS5013 E13 NVMe Controller (rev 01) (prog-if 02 [NVM Express])
        Subsystem: Phison Electronics Corporation PS5013-E13 PCIe3 NVMe Controller (DRAM-less)
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 39
        Region 0: Memory at 1b00000000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: <access denied>
        Kernel driver in use: nvme

0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21) (prog-if 00 [Normal decode])
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 47
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        Memory behind bridge: 00000000-005fffff [size=6M] [32-bit]
        Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit]
        Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
        BridgeCtl: Parity- SERR- NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
                PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
        Capabilities: <access denied>
        Kernel driver in use: pcieport

0001:01:00.0 Ethernet controller: Device 1de4:0001
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0
        Interrupt: pin A routed to IRQ 47
        Region 0: Memory at 1f00410000 (32-bit, non-prefetchable) [size=16K]
        Region 1: Memory at 1f00000000 (32-bit, non-prefetchable) [virtual] [size=4M]
        Region 2: Memory at 1f00400000 (32-bit, non-prefetchable) [size=64K]
        Capabilities: <access denied>
        Kernel driver in use: rp1

@geerlingguy
Copy link
Author

@mikegapinski - Ah, thanks. I have edited /boot/firmware/config.txt and added dtparam=pciex1_no_l0s=on to the end, and rebooted.

Everything seems to be working fine now, and my impromptu benchmark gives:

Run status group 0 (all jobs):
   READ: bw=435MiB/s (456MB/s), 435MiB/s-435MiB/s (456MB/s-456MB/s), io=12.8GiB (13.7GB), run=30019-30019msec

So getting PCIe Gen 2 without issue now. Thanks!

Now the race begins to figure out which drives work better than others out of the box behind a switch :D

@mikegapinski
Copy link

@mikegapinski - Ah, thanks. I have edited /boot/firmware/config.txt and added dtparam=pciex1_no_l0s=on to the end, and rebooted.

Everything seems to be working fine now, and my impromptu benchmark gives:


Run status group 0 (all jobs):

   READ: bw=435MiB/s (456MB/s), 435MiB/s-435MiB/s (456MB/s-456MB/s), io=12.8GiB (13.7GB), run=30019-30019msec

So getting PCIe Gen 2 without issue now. Thanks!

Now the race begins to figure out which drives work better than others out of the box behind a switch :D

I can think of at least 5 SKUs that throw errors only behind a switch (Not only Phison but also Maxio controllers).

@peterharperuk at least initially pciex1_no_l0s could be set by default when you boot behind a switch. Having to remove a drive and put it in the enclosure to set it up after NVMe boot is enabled is not ideal.

I don't know why ASPM errors on certain drives are only thrown behind a switch, maybe it could be fixed in the firmware update.

@timg236
Copy link

timg236 commented May 15, 2024

Changing global default to workaround drive specific issues is generally the wrong thing to do. It's possible to set these as board level options via the bootloader flash config.

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#config_txt

[config.txt]
dtparam=pciex1_no_l0s=on

@EnziinSystem
Copy link

@timg236

What you mean is that instead of adding "pcie_aspm=off" to "/boot/firmware/cmdline.txt" we should:

sudo nano /boot/firmware/config.txt

[all]
# Enable the PCIe External connector.
dtparam=pciex1
dtparam=pciex1_gen=3
dtparam=pciex1_no_l0s=on
kernel=kernel8.img

Is the above method correct?

@mikegapinski
Copy link

@EnziinSystem

dtparam=pciex1_gen=3 - does not make sense with a switch, those are mostly Gen 2
kernel=kernel8.img - this is only needed for Coral and other devices that need the 4K kernel

@EnziinSystem
Copy link

EnziinSystem commented May 15, 2024

@EnziinSystem

dtparam=pciex1_gen=3 - does not make sense with a switch, those are mostly Gen 2 kernel=kernel8.img - this is only needed for Coral and other devices that need the 4K kernel

OK, we are interested in this configuration.

sudo nano /boot/firmware/config.txt

[all]
# Enable the PCIe External connector.
dtparam=pciex1
dtparam=pciex1_gen=2
dtparam=pciex1_no_l0s=on

And remove "pcie_aspm=off" from "/boot/firmware/cmdline.txt"

@timg236
Copy link

timg236 commented May 15, 2024

If the HAT meets the M2.HAT spec or the system has booted from NVMe then these lines are redundant.

dtparam=pciex1
dtparam=pciex1_gen=2

@peterharperuk
Copy link

I don't have any drives that suffer from this problem and I've got the cheapest drives I could find from Amazon. Where can I get these problematic drives from?

@mikegapinski
Copy link

I don't have any drives that suffer from this problem and I've got the cheapest drives I could find from Amazon. Where can I get these problematic drives from?

Those have the controller that only throws errors behind a switch (Phison E13, make sure it has the latest 2022 firmware. The last character in the firmware version corresponds to NAND type):

  • Cytron Maker Drive,
  • Pinedrive 2242,
  • Patriot M.2 P300,
  • Apacer AS2280P4 256GB [AP256GAS2280P4-1]
    – Crucial P2 1000 [CT1000P2SSD8]
    – DEXP L3 PCIe Gen3x4 [EPA256GNLNXE30CD-DRL3]
    – Gigabyte GP-GSM2NE256GNTD 256GB
    – GIGABYTE NVMe SSD [GP-GSM2NE3256GNTD]
    – Kingston NV1 500GB SNVS-500G
    – MSI SPATIUM M370 1TB
    – MSI SPATIUM M371 1TB
    – Patriot P300 256GB
    – Seagate Barracuda Q5 500GB ZP500CV3A001
    – Smartbuy Stream E13T [SBSSD-512GT-PH13T-M2P4]
    – Smartbuy Stream E13T Pro [SBSSD-128GT-PH13P-M2P4]
    – Team Group MP33 256GB [TM8FP6256G0C101]
  • SSD OWC Aura P13 Pro 1TB M.2 2242 PCI-E x4 Gen3.1 NVMe (OWCS3DN3P3T10)

If you want something that always throws ASPM errors and barely works in GEN 3 on regular M.2 HAT+ boards go with the Lexar NM620

@peterharperuk
Copy link

ok, found one drive (Patriot) that seems to have a problem. Oddly, it only has an issue if it's plugged into the second downstream bridge.

@DanielOrneling
Copy link

I had this issue yesterday as well but a sudo rpi-update solved it for me so I´m up and running with my DIY NAS :)

I´m using the below parts:

  • Raspberry Pi 5 8 GB
  • Geekworm X1009 Sata controller
  • Geekworm X1001 NVME controller
  • HatBRICK! Commander PCIe-switch (2 PCIe)
  • Kingston NV2 M.2 NVMe Gen 4 250GB

@mahtin
Copy link

mahtin commented May 16, 2024

A side note for @peterharperuk (if I may) ...

You can update by running sudo rpi-update. I think the following might just update the bootloader? SKIP_KERNEL=1 SKIP_FIRMWARE=1 SKIP_SDK=1 SKIP_VCLIBS=1 && sudo rpi-update

Sadly the && will not do what you think it does. Per-command exported environment variables don't need the &&; however, the sudo command scoffs at that anyway and completely squashes them.

$ env | egrep ^TEST_
$
$ TEST_A=1 TEST_B=2 TEST_C=3 env | egrep ^TEST_
TEST_A=1
TEST_C=3
TEST_B=2
$
$ TEST_A=1 TEST_B=2 TEST_C=3 && env | egrep ^TEST_
$
$ TEST_A=1 TEST_B=2 TEST_C=3 sudo env | egrep ^TEST_
$
$ TEST_A=1 TEST_B=2 TEST_C=3 && sudo env | egrep ^TEST_
$
$ (export TEST_A=1 TEST_B=2 TEST_C=3 && env | egrep ^TEST_ )
TEST_A=1
TEST_C=3
TEST_B=2
$ 
$ (export TEST_A=1 TEST_B=2 TEST_C=3 && sudo env | egrep ^TEST_ )
$

You've got to do the environment variable allocation after the sudo.

$ sudo bash -c "TEST_A=1 TEST_B=2 TEST_C=3 env" | egrep ^TEST_
TEST_A=1
TEST_C=3
TEST_B=2
$

This is a thing in all shell's dating back since the start.

That all said, the sudo command has a --preserve-env (or -E) flag; which could well be useful for this (but again, without the &&).

$ TEST_A=1 TEST_B=2 TEST_C=3 sudo --preserve-env env | egrep TEST_
TEST_A=1
TEST_C=3
TEST_B=2
$ TEST_A=1 TEST_B=2 TEST_C=3 && sudo --preserve-env env | egrep TEST_
$

Hence my final recommended version would be:

$ SKIP_KERNEL=1 SKIP_FIRMWARE=1 SKIP_SDK=1 SKIP_VCLIBS=1 sudo -E rpi-update
...
$

Hope that helps. (PS: can't wait to test the new boot this weekend as I also have NVMe's installed after a switches)

@timg236
Copy link

timg236 commented May 16, 2024

@mahtin It might be better to move rpi-updapte params to an issue on that repo.

I'd recommend just running vanilla rpi-update because you almost certainly want the latest 6.6 kernel when testing pre-releases of the Pi5 firmware. BETA bootloader releases were dropped from rpi-eeprom APT and made available because it's easier to bisect releases via commit ids with rpi-update and on Pi5 the bootloader SPI flash image is effectively start5.elf.

sudo rpi-eeprom-update

@peterharperuk
Copy link

Thanks @mahtin I have updated the original post in case anyone finds it again.

@mahtin
Copy link

mahtin commented May 16, 2024

Thank you @peterharperuk,

Thanks @mahtin I have updated the original post in case anyone finds it again.

I think the anyone these days will mainly be some LLM scraper; but, I digress.

I took @timg236's advice and went and looked at https://github.com/raspberrypi/rpi-update and sure enough it gets it right by using the somewhat simpler (and specific to sudo) ability to set environment variables before the command. I will have to admit that I have never used that method. So today is a TIL moment [1]. I correct myself (sorry about that) and go with:

$ sudo SKIP_KERNEL=1 SKIP_FIRMWARE=1 SKIP_SDK=1 SKIP_VCLIBS=1 rpi-update
...
$

Sorry to distract from the task at hand.

[1] Insert oblatory quote: If you learn something new every day, you can teach something new every day. - Martha Stewart

@HonzaJaros
Copy link

HonzaJaros commented Jun 14, 2024

Hi,
I have RPI5 with NVME, commander and dual TPU board.

I followed manual on https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5

firstly it didn't boot from the NVMe behind switch and it did boot without it.
then I played with it a bit and I swap pcie1 and pcie2 and it start booting (so name is working behind the switch on pcie2 currently)

the TPU works only connected to RPi (but I successfully saw the TPU before I started messing with the NVMe booting)

I have tried every manual, all here what I could read.

the only thing I haven't try is the "NVME_Controller=0", because I don't know where to write it, but not sure if it help. (I would rather have the NVMe on pcie1 so the cooling works better, but it does not work.

pls see below info:

pi@hoobs:~ $ sudo lspci
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
0000:01:00.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
0000:02:03.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
0000:02:07.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
0000:03:00.0 Non-Volatile memory controller: Shenzhen Longsys Electronics Co., Ltd. Device 1602 (rev 01)
0000:04:00.0 PCI bridge: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
0001:01:00.0 Ethernet controller: Device 1de4:0001

pi@hoobs:~ $ uname -a
Linux hoobs 6.6.33-v8+ #1770 SMP PREEMPT Wed Jun 12 17:47:55 BST 2024 aarch64 GNU/Linux

pi@hoobs:~ $ cat /etc/rpi-issue
Raspberry Pi reference 2023-12-11
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 2acf7afcba7d11500313a7b93bb55a2aae20b2d6, stage2

pi@hoobs:~ $ vcgencmd version
2024/06/05 16:41:49 
Copyright (c) 2012 Broadcom
version 6fe0b091 (release) (embedded)
pi@hoobs:~ $ 

nvme0: (g=0): rw=read, bs=(R) 256KiB-256KiB, (W) 256KiB-256KiB, (T) 256KiB-256KiB, ioengine=libaio, iodepth=32
fio-3.33
Starting 1 process
Jobs: 1 (f=0): [f(1)][100.0%][r=433MiB/s][r=1730 IOPS][eta 00m:00s]
nvme0: (groupid=0, jobs=1): err= 0: pid=6381: Sat Jun 15 02:42:24 2024
  read: IOPS=1724, BW=431MiB/s (452MB/s)(12.6GiB/30016msec)
    slat (usec): min=10, max=1828, avg=82.45, stdev=73.40
    clat (usec): min=5706, max=35617, avg=18454.52, stdev=767.51
     lat (usec): min=5810, max=35636, avg=18536.98, stdev=755.66
    clat percentiles (usec):
     |  1.00th=[16450],  5.00th=[17957], 10.00th=[18220], 20.00th=[18220],
     | 30.00th=[18220], 40.00th=[18482], 50.00th=[18482], 60.00th=[18482],
     | 70.00th=[18482], 80.00th=[18744], 90.00th=[18744], 95.00th=[18744],
     | 99.00th=[20579], 99.50th=[21890], 99.90th=[27395], 99.95th=[30278],
     | 99.99th=[33424]
   bw (  KiB/s): min=438124, max=446332, per=100.00%, avg=442248.86, stdev=965.96, samples=59
   iops        : min= 1711, max= 1743, avg=1727.25, stdev= 3.82, samples=59
  lat (msec)   : 10=0.04%, 20=98.68%, 50=1.34%
  cpu          : usr=3.50%, sys=18.22%, ctx=50189, majf=0, minf=37
  IO depths    : 1=0.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=100.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.1%, 64=0.0%, >=64=0.0%
     issued rwts: total=51772,0,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=32

Run status group 0 (all jobs):
   READ: bw=431MiB/s (452MB/s), 431MiB/s-431MiB/s (452MB/s-452MB/s), io=12.6GiB (13.6GB), run=30016-30016msec

Disk stats (read/write):
  nvme0n1: ios=59994/138, merge=0/59, ticks=1106549/133, in_queue=1106696, util=99.92%

@pelwell
Copy link
Contributor

pelwell commented Jun 14, 2024

Your comment doesn't seem to be about booting from NVME behind a PCIe switch.

@HonzaJaros
Copy link

Your comment doesn't seem to be about booting from NVME behind a PCIe switch.

it is, because it doesn't work on pcie1 and also there is the secondary problem with TPU

@mikegapinski
Copy link

mikegapinski commented Jun 14, 2024

Your comment doesn't seem to be about booting from NVME behind a PCIe switch.

it is, because it doesn't work on pcie1 and also there is the secondary problem with TPU

It is drive related, some of them need a PCIe compat flag for ASPM behind a switch. I don't know anything about Shenzhen Longsys Electronics controllers, but adding one of those overlays should make it work:

Name:   pciex1-compat-pi5
Info:   Compatibility features for pciex1 on Pi 5.
Load:   dtoverlay=pciex1-compat-pi5,<param>=<val>
Params: l1ss                    Enable ASPM L1 sub-state support
        no-l0s                  Disable ASPM L0s
        no-mip                  Revert to the MSI target in the RC, instead of
                                the MSI-MIP peripheral. Use if a) more than 8
                                interrupt vectors are required or b) the EP
                                requires DMA and MSI addresses to be 32bit.
        mmio-hi                 Move the start of outbound 32bit addresses to
                                2GB and expand 64bit outbound space to 14GB.

@HonzaJaros generally you should contact our support before raising an issue here, it is slightly offtopic (as @pelwell highlighted)

@pelwell
Copy link
Contributor

pelwell commented Jun 14, 2024

I see. The TPU issue is a distraction here.

It is worth trying the TPU with combinations of the compatibility flags @mikegapinski mentions above, but that won't affect booting.

@mikegapinski
Copy link

I see. The TPU issue is a distraction here.

It is worth trying the TPU with combinations of the compatibility flags @mikegapinski mentions above, but that won't affect booting.

@pelwell Yes and no, drives with Phison E12 controllers won't boot past bootloader without the no-l0s flag. Coral needs no-mip. But that's a different story

@pelwell
Copy link
Contributor

pelwell commented Jun 14, 2024

Yes, that's possible - but then it would be a kernel issue, not a firmware issue.

@HonzaJaros
Copy link

Your comment doesn't seem to be about booting from NVME behind a PCIe switch.

it is, because it doesn't work on pcie1 and also there is the secondary problem with TPU

It is drive related, some of them need a PCIe compat flag for ASPM behind a switch. I don't know anything about Shenzhen Longsys Electronics controllers, but adding one of those overlays should make it work:

Name:   pciex1-compat-pi5
Info:   Compatibility features for pciex1 on Pi 5.
Load:   dtoverlay=pciex1-compat-pi5,<param>=<val>
Params: l1ss                    Enable ASPM L1 sub-state support
        no-l0s                  Disable ASPM L0s
        no-mip                  Revert to the MSI target in the RC, instead of
                                the MSI-MIP peripheral. Use if a) more than 8
                                interrupt vectors are required or b) the EP
                                requires DMA and MSI addresses to be 32bit.
        mmio-hi                 Move the start of outbound 32bit addresses to
                                2GB and expand 64bit outbound space to 14GB.

@HonzaJaros generally you should contact our support before raising an issue here, it is slightly offtopic (as @pelwell highlighted)

Hi Mike, I did, 2x (email and form), sorry I didn't realised that its not related.
it is lexar 720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests