quartz64_uefi icon indicating copy to clipboard operation
quartz64_uefi copied to clipboard

Feature Request: Port for NanoPi R5S

Open NN708 opened this issue 2 years ago • 36 comments

Friendly NanoPi R5S also uses a Rockchip RK3568B2 CPU. Is it possible to have prebuilt image for this board?

NN708 avatar Nov 28 '22 02:11 NN708

You can use this repo for now https://github.com/S199pWa1k9r/quartz64_uefi/tree/nanopi-r5s So far I haven't been able to properly initialize pcie. But it is quite possible to use…

S199pWa1k9r avatar Jan 14 '23 18:01 S199pWa1k9r

@S199pWa1k9r Thank you for your reply! Your code works very well for me (except PCIe 3.0).

I'm not familiar with EDK2, so may I ask how we can make PCIe work or where's the problem now?

NN708 avatar Jan 22 '23 11:01 NN708

Hi @NN708

I'm very glad I could help.

What operating system are you using on the R5S?

I don't have much experience with PCIe, I think we can look into this together and ask @jaredmcneill to advise us. You can contact me via telegram and we will discuss the action plan.

You can find my contacts on my website.

S199pWa1k9r avatar Jan 22 '23 12:01 S199pWa1k9r

What operating system are you using on the R5S?

I tried Debian 11, and I disabled DeviceTree while compiling to force it using ACPI.

NN708 avatar Jan 22 '23 12:01 NN708

This commit adds pcie3 support to rk3588: https://gitlab.com/rk3588_linux/rk/uefi-monorepo/-/commit/7609a76bd7d8f24fcd2e7642194a2155874443c0 Maybe we can learn something from it.

amazingfate avatar Mar 15 '23 06:03 amazingfate

Well, havn't written PCIe support code for EDK2, but I have added proper FDT support for the Pine64 Quarts64, FriendlyElec Nanopi R5S and the Firefly StationPC M2 and P2. With this FreeBSD current is fully supported (except SATA) with a kernel using the FDT handed over from EDK2 (not ACPI). You can always find the latest on https://people.freebsd.org/~sos/ARM64/ Just upgraded to the latest EDK2 from Jared with OHCI USB support (that is keyboard works in EDK2).

DeepCoreDK avatar Mar 26 '23 12:03 DeepCoreDK

@S199pWa1k9r Hi, thanks for your fork, I flashed on a sdcard and inserted it into my R5S, with NetBSD 10 rootfs on a USB drive. Everything works quite well, except that there's no graphic output through HDMI to display. HDMI used to be working when I booted vendor provided Linux directly from sdcard.

darkgeek avatar Apr 15 '23 08:04 darkgeek

Vendor provide image is completely different than what we're using here.

I think there should be HDMI support but maybe just not ready for R5S board.

spikerguy avatar Apr 15 '23 13:04 spikerguy

Out of curiosity, which image are you flashing from the quartz64_uefi/nanopi-r5s fork? I ran make sdcard, and none of the resulting images worked (QUARTZ64_EFI.img, ROC-RK3566-PC_EFI.img, or SOQUARTZ_EFI.img). I never saw any UART output.

I tried adding a build_uefi FriendlyElec NanoPi-R5S line to build.sh, but that just resulted in the following error:

Processing meta-data .
Architecture(s)  = AARCH64
Build target     = RELEASE
Toolchain        = GCC5

Active Platform          = /home/precurse/work/git/quartz64_uefi_s199pwa1k9r/edk2-rockchip/Platform/FriendlyElec/NanoPi-R5S/NanoPi-R5S.dsc


build.py...
 : error F001: Module /home/precurse/work/git/quartz64_uefi_s199pwa1k9r/edk2-rockchip/Silicon/Rockchip/Rk356x/Drivers/OhciDxe/OhciDxe.inf NOT found in DSC file; Is it really a binary module?

Thanks in advance!

precurse avatar Apr 17 '23 15:04 precurse

@precurse I use a pre-built image from the fork owner. You could find the link from this thread .

darkgeek avatar Apr 17 '23 15:04 darkgeek

Note to self: use a baud rate of 115200 when using this bootloader. I was still using 1500000, since that's what the stock FriendlyElec used for its bootloader, but that clearly didn't work for Quartz64_UEFI :)

precurse avatar Apr 19 '23 02:04 precurse

It's in the README 😄

jaredmcneill avatar Apr 19 '23 10:04 jaredmcneill

@S199pWa1k9r are you building your https://personalbsd.org/download/UEFI-RK356x/NANOPI-R5S_EFI.img image directly from your Github fork? I can't find any reference to NanoPi-R5S in the Makefile or build.sh. Just trying to understand how you're building the image :)

Thanks!

precurse avatar May 12 '23 16:05 precurse

I'm working with a NanoPi R5C, and I see TianoCore output on HDMI port running img file from:

make sdcard BOARDS=ROC-RK3568-PC

I need to run RedHat 9.x, so if any changes are required I will submit PR.

jwinarske avatar May 19 '23 20:05 jwinarske

@jwinarske

R5C and R5S have a lot in common.

I'm trying to get R5S to work and I have R5C too. The main problem is that the current implementation of PCIe does not provides simultaneous operation of pcie30 and pcie20.

Perhaps this can be fixed, but significant changes need to be made to the implementation of PCIe in UEFI. At the moment, it is possible to get either pice30 or pcie20 to work in UEFI and the operating system sees them.

If you build a UEFI with the correct DTB file and boot the OS in FDT mode, you won't see any difference compared to U-boot. For Linux you need to use grabaarch64.efi

There are reports of successful testing of running NetBSD, OpenBSD and FeeBSD on R5S in FDT mode. Just keep in mind that the MAC address on the RTL8125 will be zero.

Both of these devices have a maximum RAM size of 4Gb, and the VMware installer will not work on them. My fork contains working materials and cannot be taken as an unconditionally finished version.

I'll be happy to send a PR if @jaredmcneill agrees.

In my opinion, @jaredmcneill has neither R5S nor R5C in its hands. And only we ourselves can test the changes.

S199pWa1k9r avatar May 21 '23 04:05 S199pWa1k9r

@S199pWa1k9r Can you point me to your changes? I'm interested in a project mu implementation. Was going to look at that next. I worked at Surface on the ProX (aarh64).

jwinarske avatar May 21 '23 04:05 jwinarske

@jwinarske Okay, I'll try to make changes today. in my repo. Here are the necessary links to understand the proposed changes.

Schematic: https://wiki.friendlyelec.com/wiki/images/0/0f/NanoPi_R5S_2204_SCH.PDF https://wiki.friendlyelec.com/wiki/images/4/45/NanoPi_R5C_2209_SCH.PDF

DTS: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm64/boot/dts/rockchip?h=v6.3.3 https://github.com/pyavitz/debian-image-builder/blob/feature/patches/rockchip/rk356x/6.3/002-arm64-dts-rk3568-nanopi-5.patch

And this patch https://github.com/pyavitz/debian-image-builder/blob/feature/patches/rockchip/rk356x/6.3/013-arm64-rk3568-update-gicv3-its-and-pci-msi-map.patch

S199pWa1k9r avatar May 21 '23 05:05 S199pWa1k9r

@S199pWa1k9r Sounds good. The R5C has two 2.5GB Ethernet controllers. Also only the download USB port is active. Also the USB keyboard doesn't enable UEFI, only serial terminal, then USB keyboard works. Once I can boot RHEL I'll create a mu UEFI version with additional features.

jwinarske avatar May 21 '23 16:05 jwinarske

@S199pWa1k9r Technical Reference Manuals 1+2 https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part1%20V1.1-20210301.pdf https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part2%20V1.1-20210301.pdf

jwinarske avatar May 22 '23 16:05 jwinarske

@jwinarske

Latest test UEFI for NanoPi-R5C Fixed USB work. PCIe30 - working Correct DTB. UART console speed 115200. idblock.bin NANOPI-R5C_EFI.itb

Full UEFI image NANOPI-R5C_EFI.img

S199pWa1k9r avatar May 22 '23 19:05 S199pWa1k9r

I see the updated graphic, cool. USB works on both ports.

I was seeing a single 2.5GB Ethernet device prior, and am still only seeing a single controller:

Shell> pci
   Seg  Bus  Dev  Func
   ---  ---  ---  ----
    02   00   00    00 ==> Bridge Device - PCI/PCI bridge
             Vendor 1D87 Device 3566 Prog Interface 0
    02   01   00    00 ==> Network Controller - Ethernet controller
             Vendor 10EC Device 8125 Prog Interface 0
    02   01   1F    00 ==> Pre 2.0 device - All devices other than VGA
             Vendor 0000 Device 0000 Prog Interface 0

In the case of R5C, the M.2 card slot pin muxing needs to be setup for PCIe2.0. This is unlike the R5S. I think there are some more Board Init changes required.

This is what I currently see with your update:

Shell> devices
     T   D
     Y C I
     P F A
CTRL E G G #P #D #C  Device Name
==== = = = == == === =========================================================
  19 R - -  0  1   1 VenHw(D3987D4B-971A-435F-8CAF-4967EB627241)/Uart(115200,8,N
,1)
  2B R - -  0  2   3 MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)
  51 R - -  0  1   0 VenHw(3914AE34-B946-11EC-9D33-F42A7DCB925D,0000000000000000
00000000)
  52 R - -  0  1   0 VenHw(3914AE34-B946-11EC-9D33-F42A7DCB925D,0000000001000000
00000000)
  55 R - -  0  1   1 PcieRoot(0x0)
  62 D - -  2  0   0 Primary Console Input Device
  63 D - -  2  0   0 Primary Console Output Device
  64 D - -  2  0   0 Primary Standard Error Device
  68 R - -  0  5   2 VenHw(03234652-6F71-4A89-92EA-E84E04E36196)
  7C R - -  0  3   3 Edkii Sd/Mmc Host Controller
[ 7F B - -  1  2   9 ? 155A3 ??
[ 80 D - -  1  1   0 ? 155A3 ??
[ 81 D - -  1  1   0 ? 155A3 ??
  82 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(1,GPT,E582484A-9010-404A-899D-47BD16BA3FA8,0x4000,0x2
000)
  83 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(2,GPT,DC11277F-EB7F-42D9-8027-A83B14220E50,0x6000,0x2
000)
  84 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(3,GPT,295A726A-357D-4382-D5A6-E7E871DA99E0,0x8000,0x2
000)
  85 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(4,GPT,A26AD83C-802B-4321-AC9B-B7D356D112AF,0xA000,0x8
000)
  86 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(5,GPT,48C6A675-3744-45F6-D7FF-474449EEB98E,0x12000,0x
14000)
  87 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(6,GPT,47E71B31-0D6E-4C8C-A6D4-2EF63FC0366C,0x26000,0x
10000)
  88 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(7,GPT,B7CC853F-4829-4339-EBB8-5D343254DFF2,0x36000,0x
10000)
  89 D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(8,GPT,69791571-8D47-4E71-9FBA-AB487E4B4194,0x46000,0x
100000)
  8A D - -  1  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000031FE00000000
00)/eMMC(0x0)/Ctrl(0x0)/HD(9,GPT,532C020C-DB67-42D2-BAF3-F5540F79B4D4,0x146000,0
x3889FDF)
  90 R - -  0  3   0 eXtensible Host Controller (USB 3.0)
  91 R - -  0  3   5 eXtensible Host Controller (USB 3.0)
  92 R - -  0  3   0 Enhanced Host Controller (USB 2.0)
  93 R - -  0  3   0 Enhanced Host Controller (USB 2.0)
  94 R - -  0  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000081FD00000000
00)
  95 R - -  0  1   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000089FD00000000
00)
  96 B - -  1  5   3 Tty Terminal Serial Console
  9A D - -  1  1   0 MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(1,GPT,37462EB1-5
7FE-494B-B18E-D8A675D55247,0x40,0x3FC0)
  9B D - -  1  1   0 MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(2,GPT,E41AD33D-9
AC1-4FD8-81A1-1F4FC12C29AD,0x4000,0x4000)
  9C D - -  1  1   0 MemoryMapped(0xB,0xFE2B0000,0xFE2B0FFF)/HD(3,GPT,84DE44B2-0
913-4CC2-9D4F-061D2771F2EB,0x8000,0x8000)
  9D D - -  1  0   0 PcieRoot(0x0)/Pci(0x0,0x0)
  A3 D - -  1  0   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000000FD00000000
00)/USB(0x1,0x0)
  A4 D - -  1  0   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000000FD00000000
00)/USB(0x0,0x0)
  A5 B - -  1  3   1 Generic Usb Keyboard
  A6 D - -  1  0   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000000FD00000000
00)/USB(0x0,0x0)/USB(0x2,0x1)
  A7 D - -  1  0   0 VenHw(0D51905B-B77E-452A-A2C0-ECA0CC8D514A,000000FD00000000
00)/USB(0x0,0x0)/USB(0x3,0x0)

These look odd:

[ 7F B - -  1  2   9 ? 155A3 ??
[ 80 D - -  1  1   0 ? 155A3 ??
[ 81 D - -  1  1   0 ? 155A3 ??

I do see quite a few more blkdevices now (16), which is good. Three of which are the SD Card. That would indicate the eMMC has 13 partitions.

Seems the RT clock might have been affected, as I now see an error every time with timezone, date, or time cmds:

Shell> timezone
timezone: UEFI function 'gRT->GetTime' returned: Device Error

Exposing the eMMC via mass storage mode might be handy. I may have some code for that.

jwinarske avatar May 22 '23 20:05 jwinarske

@S199pWa1k9r I'm making progress. I have all PCIe Root devices enabled and responding on the R5C. Only issue I'm seeing is eMMC is generating errors and not always working. I'll share my fork soon.

Shell> pci
   Seg  Bus  Dev  Func
   ---  ---  ---  ----
    00   00   00    00 ==> Bridge Device - PCI/PCI bridge
             Vendor 1D87 Device 3566 Prog Interface 0
    00   01   00    00 ==> Network Controller - Other network controller
             Vendor 10EC Device C822 Prog Interface 0
    01   00   00    00 ==> Bridge Device - PCI/PCI bridge
             Vendor 1D87 Device 3566 Prog Interface 0
    01   01   00    00 ==> Network Controller - Ethernet controller
             Vendor 10EC Device 8125 Prog Interface 0
    01   01   1F    00 ==> Pre 2.0 device - All devices other than VGA
             Vendor 0000 Device 0000 Prog Interface 0
    02   00   00    00 ==> Bridge Device - PCI/PCI bridge
             Vendor 1D87 Device 3566 Prog Interface 0
    02   01   00    00 ==> Network Controller - Ethernet controller
             Vendor 10EC Device 8125 Prog Interface 0
    02   01   1F    00 ==> Pre 2.0 device - All devices other than VGA
             Vendor 0000 Device 0000 Prog Interface 0

jwinarske avatar May 24 '23 22:05 jwinarske

R5C WIP - https://github.com/jaredmcneill/quartz64_uefi/pull/51

jwinarske avatar May 24 '23 23:05 jwinarske

@jwinarske Congratulations, great. I'm very glad you came

S199pWa1k9r avatar May 24 '23 23:05 S199pWa1k9r

@S199pWa1k9r thanks! I just need a R5S now...

jwinarske avatar May 24 '23 23:05 jwinarske

I just figured out the RTC issue. If the low voltage bit is set, the first clock read always ends in error. I added clearing it in board init, if set. I think the only way to avoid the bit being set is to use a coin battery. Not sure why they didn't just use the PMIC RTC, but then again I haven't yet looked at any of the errata. It's pushed to my PR.

jwinarske avatar May 25 '23 00:05 jwinarske

Wow, this is awesome work guys! Thanks for all the effort :)

precurse avatar May 25 '23 13:05 precurse

@S199pWa1k9r Hi, thanks for your fork, I flashed on a sdcard and inserted it into my R5S, with NetBSD 10 rootfs on a USB drive. Everything works quite well, except that there's no graphic output through HDMI to display. HDMI used to be working when I booted vendor provided Linux directly from sdcard.

I found that HDMI works great after flashing the latest UEFI img here.

darkgeek avatar Aug 04 '23 19:08 darkgeek

@S199pWa1k9r Hi, thanks for your fork, I flashed on a sdcard and inserted it into my R5S, with NetBSD 10 rootfs on a USB drive. Everything works quite well, except that there's no graphic output through HDMI to display. HDMI used to be working when I booted vendor provided Linux directly from sdcard.

I found that HDMI works great after flashing the latest UEFI img here.

Anyone tried boot from PCIe M2 on NanoPi R5S? I can boot from USB drive with the help of this UEFI image, and now I'm considering to purchase a M2 ssd drive, but not sure if it works on R5S😄.

darkgeek avatar Oct 28 '23 04:10 darkgeek

@S199pWa1k9r Hi, thanks for your fork, I flashed on a sdcard and inserted it into my R5S, with NetBSD 10 rootfs on a USB drive. Everything works quite well, except that there's no graphic output through HDMI to display. HDMI used to be working when I booted vendor provided Linux directly from sdcard.

I found that HDMI works great after flashing the latest UEFI img here.

Anyone tried boot from PCIe M2 on NanoPi R5S? I can boot from USB drive with the help of this UEFI image, and now I'm considering to purchase a M2 ssd drive, but not sure if it works on R5S😄.

Not all operating systems operate the same in ACPI mode. If you can supply the correct DTB file for your version of Linux, and use FDT mode, then NVMe will most likely work. But there may be surprises.

S199pWa1k9r avatar Oct 31 '23 15:10 S199pWa1k9r