jaredmcneill / quartz64_uefi

EDK2 UEFI for Rockchip RK3566 and RK3568 based SBCs.
158 stars 60 forks source link

Feature Request: Port for NanoPi R5S #40

Open NN708 opened 2 years ago

NN708 commented 2 years ago

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

S199pWa1k9r commented 1 year ago

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…

NN708 commented 1 year ago

@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?

S199pWa1k9r commented 1 year ago

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.

NN708 commented 1 year ago

What operating system are you using on the R5S?

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

amazingfate commented 1 year ago

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

DeepCoreDK commented 1 year ago

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).

darkgeek commented 1 year ago

@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.

spikerguy commented 1 year ago

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.

precurse commented 1 year ago

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!

darkgeek commented 1 year ago

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

precurse commented 1 year ago

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 :)

jaredmcneill commented 1 year ago

It's in the README 😄

precurse commented 1 year ago

@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!

jwinarske commented 1 year ago

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.

S199pWa1k9r commented 1 year ago

@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.

jwinarske commented 1 year ago

@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).

S199pWa1k9r commented 1 year ago

@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

jwinarske commented 1 year ago

@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 commented 1 year ago

@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

S199pWa1k9r commented 1 year ago

@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

jwinarske commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

S199pWa1k9r commented 1 year ago

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

jwinarske commented 1 year ago

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

jwinarske commented 1 year ago

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.

precurse commented 1 year ago

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

darkgeek commented 1 year ago

@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 commented 1 year ago

@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😄.

S199pWa1k9r commented 1 year ago

@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.

jaredmcneill commented 11 months ago

@S199pWa1k9r do you plan on submitting your changes to this branch?

S199pWa1k9r commented 11 months ago

@jaredmcneill Yes,

But PCie2.0 and PCie3.0 will not work at the same time. Should I leave it in the correct PCIe2 or PCIe3 state? I prefer PCIe3.0. I am ready to send a request if there is no objection. I know that you do not have this board.

Will this cause any inconvenience?

NN708 commented 11 months ago

Maybe we should merge the changes to PCI in #51 first?

S199pWa1k9r commented 11 months ago

I looked at this code. Yes, it will probably work. But I would also like to analyze the code for RK3588. Maybe there are a lot of similarities there. I planned to spend the next week at home and have more free time. I suggest discussing and finding the best solution. I think we can make a drastic improvement

THMonster commented 9 months ago

@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

Hi, I flashed this uefi firmware to my R5C, and it seems work good, both hdmi and usb work. I flashed a uefi armbian to my usb stick. It does boot to the armbian grub. image But it stuck at I/TC: Secondary CPU 3 switching to normal world boot after grub. image How can I fix that?

raydoom commented 4 months ago

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…

My device is R5S, I flash the img to sdcard, but the internal NVME SDD did not show up in boot manage, how can i fix it, I want to install OS to internal NVME SDD.