From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8365D9418D7 for ; Wed, 21 May 2025 17:00:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=I6O7gpD0xKTcJBdBHDtdoWQAJdtN+y9+PkvF9T5yORQ=; c=relaxed/simple; d=groups.io; h=MIME-Version:From:Date:Message-ID:Subject:To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240830; t=1747846830; v=1; x=1748106029; b=G4+mkltG2rvBpLobNzSqL2TMal9pDcWbQVg0F/edLU5az/kUIyVMSvnJSQSBhdlcPZhbzjZV 4EEM/llaItLMd0ozlQr0VOksZ/NjMjOlJw7ebsckzKitHSPR7W91uNyTaXZAVhql83dAoCVInKZ Kvlv9KVqtEnaHKtBO/l6ClyIsQdOk/ZoAmPzhnypEzaFpckgQC+97lUJkH3BejOTDhQh1f1U0L4 cl9KVWQqFivw6eOunuiIrAXEZDoDpl8pkB4Vt/fEUZI1B/Bq+LFmndClKcK2CmMZd0wKPaCwtob jR2m41PuSvZ+Ffg/jWwpz2VTQAfli5ap1bM0bpDrG33gg== X-Received: by 127.0.0.2 with SMTP id WNEdYY7687511xAUi7lxrdeO; Wed, 21 May 2025 10:00:29 -0700 X-Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mx.groups.io with SMTP id smtpd.web10.3722.1747845361041474068 for ; Wed, 21 May 2025 09:36:01 -0700 X-Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-30ea8e2bbaaso3999592a91.2 for ; Wed, 21 May 2025 09:36:00 -0700 (PDT) X-Gm-Message-State: UzMdjEh5o6AkONNUB1TsZdFUx7686176AA= X-Gm-Gg: ASbGncuZLvjBmhUIIsLn0R94kbOISV2XihrwqI5mPHzI6FwFaewQRGmFQIhlmP5h9W4 O5qvHkko7OOWu0CxuQ5u0iPZXLgWVZ2CPr9p5koQy1SgyFzVhxgOE1MAN7P/V59JaUt3ClBLS16 Vv4No3+3AV6F2uwRQBZViAcm7eZDaKcYLg X-Google-Smtp-Source: AGHT+IEQ7DruLGehs/ZLd0ckcGcpkoaDEz+bC93ITgnQj5FokySt24rDt6DvkXQLfD9aazEpIi/gLaYlYbYNcHGA//U= X-Received: by 2002:a17:90b:3b48:b0:2ee:d433:7c50 with SMTP id 98e67ed59e1d1-30e7d5ac7ecmr27186141a91.23.1747845359689; Wed, 21 May 2025 09:35:59 -0700 (PDT) MIME-Version: 1.0 From: "Filip Kubicz via groups.io" Date: Wed, 21 May 2025 18:35:48 +0200 X-Gm-Features: AX0GCFvlOvZZaqISRySzXXwHaaI7_suXAU9zbi6W2QUyHxx8tzbknZ3epwOrnLA Message-ID: Subject: [edk2-devel] Read SD card in edk2 using Realtek card reader To: devel@edk2.groups.io Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 21 May 2025 10:00:28 -0700 Resent-From: filip.kubicz@toolsforhumanity.com Reply-To: devel@edk2.groups.io,filip.kubicz@toolsforhumanity.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: multipart/alternative; boundary="000000000000c976d00635a7f5c6" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=G4+mkltG; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --000000000000c976d00635a7f5c6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi! I=E2=80=99m creating a edk2 driver to be able to read the SD card conte= nts in UEFI stage, and eventually boot from this device. SD card contains Linux kernel, dtb and rootfs. In the design we have a Realtek RTS5264 SD card reader, which is attached to the Orin NX using PCIe. Since Orin doesn't have internal flash, the SD card is needed as a boot media, that's why edk2 driver is needed. I was able to add a Rts5264 DXE driver to edk2-nvidia: https://github.com/NVIDIA/edk2-nvidia I=E2=80=99m able to build the driver, and run it when the PCIe device match= ing Vendor ID and Product ID of this chip is enumerated in UEFI. Then it performs register writes to the RTS5264 chip to enable power for SD card, etc. See example log: ``` add-symbol-file /workspace/Build/Jetson/DEBUG_GCC5/AARCH64/Platform/NVIDIA/Jetson/Drivers/R= ts5264/Rts5264/DEBUG/Rts5264Dxe.dll 0x46A9FF000 Loading driver at 0x0046A9FE000 EntryPoint=3D0x0046AA0756C Rts5264Dxe.efi ListPciDevices: Segment: FF Bus: 0x00 Device: 0x00 Function: 0x00 Vendor ID: 0xFFFF Device ID:0x0000 ListPciDevices: Segment: 01 Bus: 0x00 Device: 0x00 Function: 0x00 Vendor ID: 0x10DE Device ID:0x229E ListPciDevices: Segment: 01 Bus: 0x01 Device: 0x00 Function: 0x00 Vendor ID: 0x10EC Device ID:0x5264 ListPciDevices: Segment: 04 Bus: 0x00 Device: 0x00 Function: 0x00 Vendor ID: 0x10DE Device ID:0x229C ListPciDevices: Segment: 04 Bus: 0x01 Device: 0x00 Function: 0x00 Vendor ID: 0x8086 Device ID:0x2723 ListPciDevices: Segment: 07 Bus: 0x00 Device: 0x00 Function: 0x00 Vendor ID: 0x10DE Device ID:0x229A ListPciDevices: Segment: 08 Bus: 0x00 Device: 0x00 Function: 0x00 Vendor ID: 0x10DE Device ID:0x229C ListPciDevices: Segment: 08 Bus: 0x01 Device: 0x00 Function: 0x00 Vendor ID: 0x10EC Device ID:0x8168 MnpSyncSendPacket: No network cable detected. RTS5264_START: Querying protocols on incoming ControllerHandle 46792BE98 RTS5264_START: ControllerHandle 46792BE98 HAS DevicePath: VenHw(1E5A432C-0466-4D31-B009-D4D9239271D3)/MemoryMapped(0xB,0x14100000,0x1= 411FFFF)/PciRoot(0x0)/Pci(0x0,0x0)/Pci(0x0,0x0) RTS5264_START: ControllerHandle 46792BE98 HAS PciIo Protocol (queried by HandleProtocol). RTS5264_START: Raw BAR1 value: 0x40000000 (Type: MmYsNRts5264: IC Version: 0x1 RTS5264: Powering on card... RTS5264: Setting initial clock... ``` However, I struggle with connecting this driver to the filesystem in edk2, to be able to read/write, and eventually boot from the SD card. Can you please outline the steps that should be taken, which protocols should I implement to be able to read the SD card via this driver? I'm new to edk2 so every piece of good advice will be useful. Thank you! Filip -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#121366): https://edk2.groups.io/g/devel/message/121366 Mute This Topic: https://groups.io/mt/113232867/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --000000000000c976d00635a7f5c6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi! I=E2=80=99m creating a edk2 driver to be able to read = the SD card contents in UEFI stage, and eventually boot from this device. S= D card contains Linux kernel, dtb and rootfs.

In the design we=C2= =A0have a Realtek RTS5264 SD card reader, which is attached to the Orin NX = using PCIe. Since Orin doesn't have internal flash, the SD card is need= ed as a boot media,=C2=A0that's=C2=A0why edk2 driver is needed.

= I was able to add a Rts5264 DXE driver to edk2-nvidia: https://github.com/NVIDIA/edk2-nvidia
= I=E2=80=99m able to build the driver, and run it when the PCIe device match= ing Vendor ID and Product ID of this chip is enumerated in UEFI. Then it pe= rforms register writes to the RTS5264 chip to enable power for SD card, etc= .
See example log:
```
add-symbol-file /workspace/Build/Jetson/DEB= UG_GCC5/AARCH64/Platform/NVIDIA/Jetson/Drivers/Rts5264/Rts5264/DEBUG/Rts526= 4Dxe.dll 0x46A9FF000
Loading driver at 0x0046A9FE000 EntryPoint=3D0x0046= AA0756C Rts5264Dxe.efi

ListPciDevices: Segment: FF =C2=A0 =C2=A0 =C2= =A0Bus: 0x00 =C2=A0 =C2=A0 =C2=A0 Device: 0x00 =C2=A0 =C2=A0Function: 0x00 = Vendor ID: 0xFFFF =C2=A0 =C2=A0 =C2=A0 Device ID:0x0000
ListPciDevices: = Segment: 01 =C2=A0 =C2=A0 =C2=A0Bus: 0x00 =C2=A0 =C2=A0 =C2=A0 Device: 0x00= =C2=A0 =C2=A0Function: 0x00 Vendor ID: 0x10DE =C2=A0 =C2=A0 =C2=A0 Device = ID:0x229E
ListPciDevices: Segment: 01 =C2=A0 =C2=A0 =C2=A0Bus: 0x01 =C2= =A0 =C2=A0 =C2=A0 Device: 0x00 =C2=A0 =C2=A0Function: 0x00 Vendor ID: 0x10E= C =C2=A0 =C2=A0 =C2=A0 Device ID:0x5264
ListPciDevices: Segment: 04 =C2= =A0 =C2=A0 =C2=A0Bus: 0x00 =C2=A0 =C2=A0 =C2=A0 Device: 0x00 =C2=A0 =C2=A0F= unction: 0x00 Vendor ID: 0x10DE =C2=A0 =C2=A0 =C2=A0 Device ID:0x229C
Li= stPciDevices: Segment: 04 =C2=A0 =C2=A0 =C2=A0Bus: 0x01 =C2=A0 =C2=A0 =C2= =A0 Device: 0x00 =C2=A0 =C2=A0Function: 0x00 Vendor ID: 0x8086 =C2=A0 =C2= =A0 =C2=A0 Device ID:0x2723
ListPciDevices: Segment: 07 =C2=A0 =C2=A0 = =C2=A0Bus: 0x00 =C2=A0 =C2=A0 =C2=A0 Device: 0x00 =C2=A0 =C2=A0Function: 0x= 00 Vendor ID: 0x10DE =C2=A0 =C2=A0 =C2=A0 Device ID:0x229A
ListPciDevice= s: Segment: 08 =C2=A0 =C2=A0 =C2=A0Bus: 0x00 =C2=A0 =C2=A0 =C2=A0 Device: 0= x00 =C2=A0 =C2=A0Function: 0x00 Vendor ID: 0x10DE =C2=A0 =C2=A0 =C2=A0 Devi= ce ID:0x229C
ListPciDevices: Segment: 08 =C2=A0 =C2=A0 =C2=A0Bus: 0x01 = =C2=A0 =C2=A0 =C2=A0 Device: 0x00 =C2=A0 =C2=A0Function: 0x00 Vendor ID: 0x= 10EC =C2=A0 =C2=A0 =C2=A0 Device ID:0x8168
MnpSyncSendPacket: No network= cable detected.
RTS5264_START: Querying protocols on incoming Controlle= rHandle 46792BE98
RTS5264_START: ControllerHandle 46792BE98 HAS DevicePa= th: VenHw(1E5A432C-0466-4D31-B009-D4D9239271D3)/MemoryMapped(0xB,0x14100000= ,0x1411FFFF)/PciRoot(0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)
RTS5264_START: Contr= ollerHandle 46792BE98 HAS PciIo Protocol (queried by HandleProtocol).
RT= S5264_START: Raw BAR1 value: 0x40000000 (Type: MmYsNRts5264: IC Version: 0x= 1
RTS5264: Powering on card...
RTS5264: Setting initial clock...
`= ``

However, I struggle with connecting this driver to the filesystem= in edk2, to be able to read/write, and eventually boot from the SD card.
Can you please outline the steps that should be taken, which protocol= s should I implement to be able to read the SD card via this driver?
I&#= 39;m new to edk2 so every piece of good advice will be useful.

Thank= you!
Filip
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#121366) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--000000000000c976d00635a7f5c6--