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

Closed
geerlingguy opened this issue Oct 17, 2023 · 81 comments
Closed

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

geerlingguy opened this issue Oct 17, 2023 · 81 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
@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

@D3M1Y0
Copy link

D3M1Y0 commented Oct 2, 2024

Hello,

is there already a solution for this? I would like to use the HatDrive! AI board from Pineboards for my Pi 5 with NVMe and use the TPU chip for my local AI environment.

Thank you

@timg236
Copy link

timg236 commented Oct 2, 2024

The latest bootloader firmware has some support for PCIe switches (apt update / apt upgrade). In a future update (next couple of weeks) we will be switching the bootloader to use mmio-hi and make that the default.

@HonzaJaros
Copy link

HonzaJaros commented Oct 2, 2024 via email

@csobrinho
Copy link

The latest bootloader firmware has some support for PCIe switches (apt update / apt upgrade). In a future update (next couple of weeks) we will be switching the bootloader to use mmio-hi and make that the default.

Hi @timg236, is the latest bootloader Mon 23 Sep 13:02:56 UTC 2024 (1727096576)?
Is it also dependent on a specific kernel version? I currently have 6.6.51+rpt-rpi-2712.

I haven't tried it yet because I'm waiting for confirmation that a dual NVME M.2 can boot before changing my current system from the single NVME M2.

Thanks!!

@peterharperuk
Copy link

peterharperuk commented Oct 9, 2024

Is it also dependent on a specific kernel version?

No

@konsim83
Copy link

konsim83 commented Oct 15, 2024

Hi, is there already a PR for the new bootloader to follow? I would be highly interested as I am using a pineboards hat that bundles an AI accelerator and a NVMe drive adapter. The Pi5 used to boot from it but stopped doing so after the latest bootloader update from version September 23rd to October 9 (the devices are recognized though after booting from a USB) .

Also, later I would like to use it behind a pcie bridge as the one that @geerlingguy described.

Cheers,
Konrad

@peterharperuk
Copy link

@konsim83 Need more details. Where is it failing? Do you see any errors? It should have worked since the 2024-06-05 release of the bootloader.

@konsim83
Copy link

konsim83 commented Oct 15, 2024

Hi @peterharperuk
I collected some information about the device when booting form a USB. Devices (Pineboards Hat with NVMe + AI accelerator, see here) are recognized after boot. It does not boot from NvMe though after boot loader update a few days ago. Thanks a lot for picking this up :-)

Here some output:

sudo lspci -v

$ sudo lspci -v
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 38
        Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [48] Power Management version 3
        Capabilities: [ac] Express Root Port (Slot-), MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [160] Virtual Channel
        Capabilities: [180] Vendor Specific Information: ID=0000 Rev=0 Len=028 <?>
        Capabilities: [240] L1 PM Substates
        Capabilities: [300] Secondary PCI Express
        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
        Flags: bus master, fast devsel, latency 0, IRQ 38
        Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Upstream Port, MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Vendor Specific Information: ID=0000 Rev=0 Len=c00 <?>
        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
        Flags: bus master, fast devsel, latency 0, IRQ 40
        Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: [disabled] [64-bit]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        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
        Flags: bus master, fast devsel, latency 0, IRQ 41
        Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: [disabled] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Kernel driver in use: pcieport

0000:03:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01) (prog-if 02 [NVM Express])
        Subsystem: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (DRAM-less)
        Flags: bus master, fast devsel, latency 0, IRQ 39
        Memory at 1b80000000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 1f
        Capabilities: [b0] MSI-X: Enable+ Count=9 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Alternative Routing-ID Interpretation (ARI)
        Capabilities: [168] Secondary PCI Express
        Capabilities: [1d4] Latency Tolerance Reporting
        Capabilities: [1dc] L1 PM Substates
        Capabilities: [1ec] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
        Capabilities: [2ec] Vendor Specific Information: ID=0001 Rev=1 Len=038 <?>
        Kernel driver in use: nvme

0000:04:00.0 Co-processor: Hailo Technologies Ltd. Hailo-8 AI Processor (rev 01)
        Subsystem: Hailo Technologies Ltd. Hailo-8 AI Processor
        Flags: bus master, fast devsel, latency 0, IRQ 39
        Memory at 1800000000 (64-bit, prefetchable) [size=16K]
        Memory at 1800008000 (64-bit, prefetchable) [size=4K]
        Memory at 1800004000 (64-bit, prefetchable) [size=16K]
        Capabilities: [80] Express Endpoint, MSI 00
        Capabilities: [e0] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [f8] Power Management version 3
        Capabilities: [100] Vendor Specific Information: ID=1556 Rev=1 Len=008 <?>
        Capabilities: [108] Latency Tolerance Reporting
        Capabilities: [110] L1 PM Substates
        Capabilities: [128] Alternative Routing-ID Interpretation (ARI)
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Secondary PCI Express
        Kernel driver in use: hailo
        Kernel modules: hailo_pci

0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, 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: [disabled] [64-bit]
        Capabilities: [48] Power Management version 3
        Capabilities: [ac] Express Root Port (Slot-), MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [160] Virtual Channel
        Capabilities: [180] Vendor Specific Information: ID=0000 Rev=0 Len=028 <?>
        Capabilities: [240] L1 PM Substates
        Capabilities: [300] Secondary PCI Express
        Kernel driver in use: pcieport

0001:01:00.0 Ethernet controller: Raspberry Pi Ltd RP1 PCIe 2.0 South Bridge
        Flags: bus master, fast devsel, latency 0, IRQ 47
        Memory at 1f00410000 (32-bit, non-prefetchable) [size=16K]
        Memory at 1f00000000 (32-bit, non-prefetchable) [virtual] [size=4M]
        Memory at 1f00400000 (32-bit, non-prefetchable) [size=64K]
        Capabilities: [40] Power Management version 3
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [b0] MSI-X: Enable+ Count=61 Masked-
        Capabilities: [100] Advanced Error Reporting
        Kernel driver in use: rp1

Could it be an incompatibility with the NVMe controller? -> Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01) (prog-if 02 [NVM Express])

lsblk -f

$ lsblk -f
NAME        FSTYPE FSVER LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                 
├─sda1      vfat   FAT32 bootfs 9BE2-1346                             434.4M    15% /boot/firmware
└─sda2      ext4   1.0   rootfs 12974fe2-889e-4060-b497-1d6ac3fbbb4b     20G    24% /
nvme0n1                                                                             
├─nvme0n1p1 vfat   FAT32 bootfs 91FE-7499                                           
└─nvme0n1p2 ext4   1.0   rootfs 56f80fa2-e005-4cca-86e6-19da1069914d 

bootloader

$ sudo rpi-eeprom-config
[all]
BOOT_UART=1
POWER_OFF_ON_HALT=0
BOOT_ORDER=0xf416
#NET_INSTALL_AT_POWER_ON=1

and bootloader version

    CURRENT: Wed Oct  9 11:36:47 PM UTC 2024 (1728517007)
    UPDATE: Wed Oct  9 11:36:47 PM UTC 2024 (1728517007)
    BOOTFS: /boot/firmware

sudo cat /boot/firmware/config.txt

$ sudo cat /boot/firmware/config.txt
 
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Additional overlays and parameters are documented
# /boot/firmware/overlays/README

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Automatically load initramfs files, if found
auto_initramfs=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# Run as fast as firmware / board allows
arm_boost=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[cm5]
dtoverlay=dwc2,dr_mode=host

[all]
dtparam=pciex1
dtparam=pciex1_gen=2 # may be redundant, but let's be explicit
usb_max_current_enable=1

This is a picture that I see upon boot from NVMe:

screen

@mikegapinski
Copy link

Hi @peterharperuk I collected some information about the device when booting form a USB. Devices (Pineboards Hat with NVMe + AI accelerator, see here) are recognized after boot. It does not boot from NvMe though after boot loader update a few days ago. Thanks a lot for picking this up :-)

Here some output:

sudo lspci -v

$ sudo lspci -v
0000:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 38
        Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [48] Power Management version 3
        Capabilities: [ac] Express Root Port (Slot-), MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [160] Virtual Channel
        Capabilities: [180] Vendor Specific Information: ID=0000 Rev=0 Len=028 <?>
        Capabilities: [240] L1 PM Substates
        Capabilities: [300] Secondary PCI Express
        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
        Flags: bus master, fast devsel, latency 0, IRQ 38
        Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Upstream Port, MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Vendor Specific Information: ID=0000 Rev=0 Len=c00 <?>
        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
        Flags: bus master, fast devsel, latency 0, IRQ 40
        Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: 80000000-800fffff [size=1M] [32-bit]
        Prefetchable memory behind bridge: [disabled] [64-bit]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        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
        Flags: bus master, fast devsel, latency 0, IRQ 41
        Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled] [32-bit]
        Memory behind bridge: [disabled] [32-bit]
        Prefetchable memory behind bridge: 1800000000-18000fffff [size=1M] [32-bit]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. ASM1182e 2-Port PCIe x1 Gen2 Packet Switch
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Kernel driver in use: pcieport

0000:03:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01) (prog-if 02 [NVM Express])
        Subsystem: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (DRAM-less)
        Flags: bus master, fast devsel, latency 0, IRQ 39
        Memory at 1b80000000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 1f
        Capabilities: [b0] MSI-X: Enable+ Count=9 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Alternative Routing-ID Interpretation (ARI)
        Capabilities: [168] Secondary PCI Express
        Capabilities: [1d4] Latency Tolerance Reporting
        Capabilities: [1dc] L1 PM Substates
        Capabilities: [1ec] Vendor Specific Information: ID=0002 Rev=4 Len=100 <?>
        Capabilities: [2ec] Vendor Specific Information: ID=0001 Rev=1 Len=038 <?>
        Kernel driver in use: nvme

0000:04:00.0 Co-processor: Hailo Technologies Ltd. Hailo-8 AI Processor (rev 01)
        Subsystem: Hailo Technologies Ltd. Hailo-8 AI Processor
        Flags: bus master, fast devsel, latency 0, IRQ 39
        Memory at 1800000000 (64-bit, prefetchable) [size=16K]
        Memory at 1800008000 (64-bit, prefetchable) [size=4K]
        Memory at 1800004000 (64-bit, prefetchable) [size=16K]
        Capabilities: [80] Express Endpoint, MSI 00
        Capabilities: [e0] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [f8] Power Management version 3
        Capabilities: [100] Vendor Specific Information: ID=1556 Rev=1 Len=008 <?>
        Capabilities: [108] Latency Tolerance Reporting
        Capabilities: [110] L1 PM Substates
        Capabilities: [128] Alternative Routing-ID Interpretation (ARI)
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Secondary PCI Express
        Kernel driver in use: hailo
        Kernel modules: hailo_pci

0001:00:00.0 PCI bridge: Broadcom Inc. and subsidiaries BCM2712 PCIe Bridge (rev 21) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, 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: [disabled] [64-bit]
        Capabilities: [48] Power Management version 3
        Capabilities: [ac] Express Root Port (Slot-), MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [160] Virtual Channel
        Capabilities: [180] Vendor Specific Information: ID=0000 Rev=0 Len=028 <?>
        Capabilities: [240] L1 PM Substates
        Capabilities: [300] Secondary PCI Express
        Kernel driver in use: pcieport

0001:01:00.0 Ethernet controller: Raspberry Pi Ltd RP1 PCIe 2.0 South Bridge
        Flags: bus master, fast devsel, latency 0, IRQ 47
        Memory at 1f00410000 (32-bit, non-prefetchable) [size=16K]
        Memory at 1f00000000 (32-bit, non-prefetchable) [virtual] [size=4M]
        Memory at 1f00400000 (32-bit, non-prefetchable) [size=64K]
        Capabilities: [40] Power Management version 3
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [b0] MSI-X: Enable+ Count=61 Masked-
        Capabilities: [100] Advanced Error Reporting
        Kernel driver in use: rp1

Could it be an incompatibility with the NVMe controller? -> Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01) (prog-if 02 [NVM Express])

lsblk -f

$ lsblk -f
NAME        FSTYPE FSVER LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                 
├─sda1      vfat   FAT32 bootfs 9BE2-1346                             434.4M    15% /boot/firmware
└─sda2      ext4   1.0   rootfs 12974fe2-889e-4060-b497-1d6ac3fbbb4b     20G    24% /
nvme0n1                                                                             
├─nvme0n1p1 vfat   FAT32 bootfs 91FE-7499                                           
└─nvme0n1p2 ext4   1.0   rootfs 56f80fa2-e005-4cca-86e6-19da1069914d 

bootloader

$ sudo rpi-eeprom-config
[all]
BOOT_UART=1
POWER_OFF_ON_HALT=0
BOOT_ORDER=0xf416
#NET_INSTALL_AT_POWER_ON=1

and bootloader version

    CURRENT: Wed Oct  9 11:36:47 PM UTC 2024 (1728517007)
    UPDATE: Wed Oct  9 11:36:47 PM UTC 2024 (1728517007)
    BOOTFS: /boot/firmware

sudo cat /boot/firmware/config.txt

$ sudo cat /boot/firmware/config.txt
 
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Additional overlays and parameters are documented
# /boot/firmware/overlays/README

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Automatically load initramfs files, if found
auto_initramfs=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1

# Run in 64-bit mode
arm_64bit=1

# Disable compensation for displays with overscan
disable_overscan=1

# Run as fast as firmware / board allows
arm_boost=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[cm5]
dtoverlay=dwc2,dr_mode=host

[all]
dtparam=pciex1
dtparam=pciex1_gen=2 # may be redundant, but let's be explicit
usb_max_current_enable=1

This is a picture that I see upon boot from NVMe:

screen

@peterharperuk that is concerning... the ASM1182e is the most popular switch and the board mentioned (the Hailo bundle) has the latest revision of the IC as well. Maybe it is a regression from the recent PCI BAR allocation that fixed the Gen 3 ASMedia switch?

I think you have our boards and NVMe's but it should be easy to reproduce with the Pimoroni NVMe Base Duo as well

@konsim83
Copy link

As mentioned, it used to work before the update. Behind an additional pcie switch from pineboards (brick commander) the devices cannot even be recognized

@peterharperuk
Copy link

We're looking at this now.

Maybe it is a regression from the recent PCI BAR allocation that fixed the Gen 3 ASMedia switch?

Which change are you referring to?

@mikegapinski
Copy link

We're looking at this now.

Maybe it is a regression from the recent PCI BAR allocation that fixed the Gen 3 ASMedia switch?

Which change are you referring to?

This one b154632

It was also done in the firmware recently as far as I remember.

Thank you for taking a look - I can already see a small spike in the support tickets on our end after the recent kernel/firmware update.

@peterharperuk
Copy link

This one b154632

Thanks - just wanted to check we were looking at the same change. Yes, reverting that fixes things.

@pelwell
Copy link
Contributor

pelwell commented Oct 16, 2024

FYI, @P33M.

@P33M
Copy link

P33M commented Oct 16, 2024

It'd be nice if Asmedia could make products that didn't have overlapping interop bugs. The Gen3 switch refuses to use low addresses, the Gen2 switch has some nonstandard default that makes downstream address decode extremely narrow.

@mikegapinski
Copy link

It'd be nice if Asmedia could make products that didn't have overlapping interop bugs. The Gen3 switch refuses to use low addresses, the Gen2 switch has some nonstandard default that makes downstream address decode extremely narrow.

that's not all... The Gen 2 ones made before 2024 need ASPM disabled in order to function

@peterharperuk
Copy link

Attached is the latest development version of the bootloader, which has this problem fixed. You can flash this to a spare BLANK sd card with the RPi Imager app and update the bootloader. Or wait a few days for this to reach rpi-update. It should show up as version 7749803e. The code had restricted the memory space size to 0x4000000 rather than 0x40000000, and we've improved the bridge handling code generally. I'll try and make sure we catch regressions like this in future.

This bootloader also includes changes to the "net install" UI. It might appear on boot when it didn't previously - this is a done on purpose to make this feature more visible. You can now press the space bar to interrupt boot and change the boot order via a new boot order menu.

rpi-eeprom-recovery.zip

@konsim83
Copy link

Really nice, thank you @peterharperuk !

timg236 added a commit to raspberrypi/rpi-eeprom that referenced this issue Oct 21, 2024
…s (latest)

* Fix PCIe BAR setup issue which prevented NVMe boot from working with some PCIe switches
  See: raspberrypi/firmware#1833
* Boot-menu improvements
  Remain in the forced boot mode until the menu is used to select a different
  boot-mode or reset to the original boot-order.
timg236 added a commit to raspberrypi/rpi-eeprom that referenced this issue Oct 21, 2024
…s (latest)

* Fix PCIe BAR setup issue which prevented NVMe boot from working with some PCIe switches
  See: raspberrypi/firmware#1833
* Boot-menu improvements
  Remain in the forced boot mode until the menu is used to select a different
  boot-mode or reset to the original boot-order.
@peterharperuk
Copy link

You should be able to get the fix from rpi-update now - the usual warnings about using pre-release software applies...

SKIP_FIRMWARE=1 SKIP_SDK=1 SKIP_VCLIBS=1 sudo -E rpi-update

@peterharperuk
Copy link

peterharperuk commented Oct 23, 2024

The fix is now in apt, so the following should update your bootloader to the 21 October 2024 release.

sudo apt update
sudo apt install rpi-eeprom
sudo rpi-eeprom-update -a

I am closing this issue as I think it has served its purpose. If you have further issues with this feature please raise a new issue.

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