Add latest U-boot support for BPI R2 & BPI R64 (not yet)

resets are not found by ryders code…because they are deleted…i added them this way:

281         resets = <&hifsys HIFSYS_PCIE0_RST>,
282              <&hifsys HIFSYS_PCIE1_RST>,
283              <&hifsys HIFSYS_PCIE2_RST>;

but now nothing is printed on pci-enum (not the debug-messages i see before)

https://github.com/frank-w/u-boot/commits/sata_test_ryder

accidentaly removed my debug-messages by “git reset”

now i see much more, but resets still 0

DEBUG: Passed mtk_pcie_probe 247                                                                                                     
DEBUG: Passed mtk_pcie_probe 252                                                                                                     
DEBUG: Passed mtk_pcie_probe 258                                                                                                     
DEBUG: Passed mtk_pcie_probe 264                                                                                                     
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 269                                                                                                     
DEBUG: Passed mtk_pcie_probe 273                                                                                                     
DEBUG: Passed mtk_pcie_probe 278                                                                                                     
DEBUG: Passed mtk_pcie_parse_port 207                                                                                                
DEBUG: Passed mtk_pcie_parse_port 211                                                                                                
DEBUG: Passed mtk_pcie_parse_port 216                                                                                                
DEBUG: Passed mtk_pcie_parse_port 221 0,0,0                                                                                          
DEBUG: Passed mtk_pcie_parse_port 225                                                                                                
DEBUG: Passed mtk_pcie_parse_port 229                                                                                                
DEBUG: Passed mtk_pcie_parse_port 232                                                                                                
DEBUG: Passed mtk_pcie_parse_port 235                                                                                                
DEBUG: Passed mtk_pcie_probe 285                                                                                                     
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192                                                                                               
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192                                                                                               
DEBUG: Passed mtk_pcie_enable_port 172                                                                                               
DEBUG: Passed mtk_pcie_enable_port 184                                                                                               
DEBUG: Passed mtk_pcie_enable_port 192

ok let’s look at pinmux in dts…

should be this: https://github.com/frank-w/BPI-R2-4.14/blob/6a8cd4974ab40922aa8320f7eee1c8cc26b084de/arch/arm/boot/dts/mt7623.dtsi#L1469

seems dt-bindings for pinctrl are not there…

dt-bindings/pinctrl/mt7623-pinfunc.h

$ ls -1 ./arch/arm/dts/include/dt-bindings/pinctrl/
am33xx.h
am43xx.h
at91.h
bcm2835.h
dra.h
hisi.h
k3.h
omap.h
pads-imx8qm.h
pads-imx8qxp.h
pinctrl-snapdragon.h
pinctrl-tegra.h
pinctrl-tegra-xusb.h
pins-imx8mq.h
r7s72100-pinctrl.h
rockchip.h
stm32-pinfunc.h
sun4i-a10.h

because you lack of pinmux setting in dts and phy driver

and if i read the PCI core correctly - pci_uclass_pre_probe() in pci-uclass.c will parse range automatically.

--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -172,6 +172,13 @@
                };
        };

+       pcie_default: pcie-default {
+               mux {
+                       function = "pcie";
+                       groups =  "pcie0_0_perst", "pcie1_0_perst";
+               };
+       };
+
        uart0_pins_a: uart0-default {
                mux {
                        function = "uart";
@@ -201,6 +208,28 @@
        };
 };

+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_default>;
+       status = "okay";
+
+       [email protected],0 {
+               status = "okay";
+       };
+
+       [email protected],0 {
+               status = "okay";
+       };
+};
+
+&pcie0_phy {
+       status = "okay";
+};
+
+&pcie1_phy {
+       status = "okay";
+};

Just note that the form of uboot pinmux is different than linux mt7623 dts since we wrote a new pinctrl core after 4.19, and this new format is adopted by uboot 7623 at that time.

2 Likes

it’s time to copy complete DTS with all dependencies :slight_smile:

that brings nothing… i tried to copy relavant parts an hung on dt-bindings…

that was the point i hung :wink: maybe we should make a separate thread for pcie/ahci?

that was the point i hung :wink: maybe we should make a separate thread for pcie/ahci?

use the version i posted and add a phy driver

i have started new thread to outsource discussion about this

http://forum.banana-pi.org/t/bpi-r2-uboot-pcie-sata-ahaci/9613

Hi,there was released an mtk xhci driver for uboot and i need help to port dts-nodes for r2 and r64

https://patchwork.ozlabs.org/patch/1252654/

Linux:

My start on r2/mt7623:

https://github.com/frank-w/u-boot/commit/09a9b9dabf067ce71b46171bf0982cc4982ca47c

Compiles,but crashes on “usb start”

There are 2 main differences between linux and uboot driver:

  • uboot seems to use relative addresses for ports where linux uses absolute addresses
  • uboot uses ranges in phy where linux defines reg

Anyone can help?

1 Like

you can ask [email protected] for help.

Already done…r2 has xhci v0.96 which is not yet supported by driver,but dts works. On r64 my dts is still broken…don’t get the xhci version info

Please feel free to ask him for any xhci problems.

Chunfeng yun is currently busy because of debugging clock-issue for mt7629.

Any idea about emmc-issue on r64? I’ve wrote to weijie gao and chaotian jing,but no response yet

they’re all busy. Maybe loop this guys along with wenbin.mei and cc me

try this patch https://pastebin.com/QfrszyV2 then provide full uart log to me (email)

2 Likes

looks like your change to the mt7622_compat-struct fixes the problem, i do not get any error on mount. i only see some errors in log while booting mt7622_mmctest.log (29,8 KB)

[    1.367124] mtk-msdc 11230000.mmc: msdc_cmd_done: cmd=52 arg=00000C00; rsp 00000000; cmd_error=-110
[    1.376165] mtk-msdc 11230000.mmc: msdc_track_cmd_data: cmd=52 arg=00000C00; host->error=0x00000002

same for 11240000

#define ETIMEDOUT       110     /* Connection timed out */

so i guess the timeout happens here:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/mmc/host/mtk-sd.c?h=v5.4.42#n1096

Just to link original error-message: Bpi-r64 quick start (boot from eMMC)

The previous patch was workaround and this error is normal. We need to figure out the root cause, so can you apply this kernel patch to print more details https://pastebin.com/va8s8hr0

I need two full uart logs and email to me - (old uboot + kernel) and (upstream uboot + kernel)

looks like the new patch causes bootloop…booting now for 200s…maybe i need to include initrd? i guess reads from sdcard are also recorded…

boot with initrd (buildroot) takes 8 seconds :slight_smile: i need to revert the prior patch, is this right? or should leave the compat-struct values?

mt7622_mmctest.log (186,1 KB)

only apply this patch.

legacy uboot (uboot 2014 (not upstream version you’re using)) + kernel

upstream uboot + kernel

it looks like for the emmc-mount issue there is a working Patch: https://github.com/frank-w/BPI-R2-4.14/commit/1ab1bcdb71b2ba02dce30c826827cc015f4bb4f5 after rebasing (to split debug+dts) it becomes this: https://github.com/frank-w/BPI-R2-4.14/commit/f644b6766b28c72fb6ccef5832201032808dc2ca

basicly the patches are applied to this branch:

https://github.com/frank-w/BPI-R2-4.14/commits/5.4-mmctest

in my quick test i do not get a error on mounting, can anybody else test this too?

got a new patch which seems fine too and should be the final solution which will be posted to patchwork, added it to my 5.4-main branch to include it into kernel-images built by travis-ci in my repo

There is also an emmc-issue in linux caused by missing pullup/pulldown pinctrl-definitions. This seems to affect only v1.1 r2-boards…i cannot reproduce issue on my v1.0 board. Maybe it’s caused by different vendor of emmc-chip (v1.0 is samsung, v1.1 is possibly sec)

Just for reference…patch is posted to mailinglist waiting for acknowledge from mtk

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

on BPI-R2 we noticed, that pcie is not enumerable in uboot if no card is inserted in pcie-slot…so sata is also not recognized -reported to mtk they will look. I have also some patches for mt7622-pcie that seem to work,but i have not got sata working…i see an sata controller,but not drive connected

Edit: I got sata working for mt7622 based on pcie-patches i got from mtk. I hope they get posted to mainline soon, to post my ahci driver.

If anyone wants to try patches here is my tree:

https://github.com/frank-w/u-boot/commits/2020-07-bpi-r64-pciev2

Build it (bpi-r64,32bit mode) and install it or load via tftp (e.g. “run askubootnet”)

After bootup with sata drive connected, enter uboot console and enter

scsi scan

Your drive should be found and you can show content of it with

ls scsi 0:1

For first partition (1) if it is a partition with buildin filesystem-support.

BPI-R64> scsi scan
scanning bus for devices...
Target spinup took 0 ms.
AHCI 0001.0300 32 slots 1 ports 6 Gbps 0x1 impl SATA mode
flags: ncq stag pm clo only pmp pio slum part ccc apst
  Device 0: (0:0) Vendor: ATA Prod.: ST750LM022 HN-M7 Rev: 2AR1
            Type: Hard Disk
            Capacity: 715404.8 MB = 698.6 GB (1465149168 x 512)
BPI-R64> ls scsi 0:1
            EFI/
      512   BOOTSECT.BAK

1 file(s), 1 dir(s)

BPI-R64>

also added my current state of xHCI for both devices there (dts-nodes + missing clock-definitions). both devices reporting xHCI 0.96 which is currently not supported by driver (hope it will do in near future)

BPI-R64> usb start
starting USB...
Bus [email protected]: hcd: 0x1a0c0000, ippc: 0x1a0c4700
u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 0.96
scanning bus [email protected] for devices... 1 USB Device(s) found

BPI-R2> usb start
starting USB...
Bus [email protected]: hcd: 0x1a1c0000, ippc: 0x1a1c4700
u2p:1, u3p:1
Register 200010f NbrPorts 2
Starting the controller
USB XHCI 0.96
Bus [email protected]: hcd: 0x1a240000, ippc: 0x1a244700
u2p:1, u3p:1
Register 200010f NbrPorts 2
Starting the controller
USB XHCI 0.96
scanning bus [email protected] for devices... 1 USB Device(s) found
scanning bus [email protected] for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found

good news: USB is now also working on both devices R2&R64 :wink:

BPI-R2> usb start
starting USB...
Bus [email protected]: hcd: 0x1a1c0000, ippc: 0x1a1c4700
u2p:1, u3p:1
Register 200010f NbrPorts 2
Starting the controller
USB XHCI 0.96
Bus [email protected]: hcd: 0x1a240000, ippc: 0x1a244700
u2p:1, u3p:1
Register 200010f NbrPorts 2
Starting the controller
USB XHCI 0.96
scanning bus [email protected] for devices... 1 USB Device(s) found
scanning bus [email protected] for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
BPI-R2> usb tree
USB device tree:
1 Hub (5 Gb/s, 0mA)
U-Boot XHCI Host Controller

1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|
+-2 Mass Storage (480 Mb/s, 200mA)
USB Flash Disk 906B030002F4

BPI-R2> ls usb 0:1
efi/
4767728 kernel

1 file(s), 1 dir(s)

=========================================================

BPI-R64> usb start
starting USB...
Bus [email protected]: hcd: 0x1a0c0000, ippc: 0x1a0c4700
u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 0.96
scanning bus [email protected] for devices... 2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
BPI-R64> ls usb 0:1
91 mcurom.md5
System Volume Information/

1 file(s), 1 dir(s)

BPI-R64>

https://github.com/frank-w/u-boot/commits/2020-10-bpi

So at current state we only need to fix the pcie issue on r2 (watchdog reset if no card inserted).

Edit: latest patches for usb (except xhci 0.96 support) are now also applied to upstream

for r2 issue we have now a workaround…anybody who wants to use SATA on r2 without pcie-card inserted can disable pcie0 in dts (arch/arm/dts/mt7623n-bananapi-bpi-r2.dts)

--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -215,7 +215,7 @@
        status = "okay";
 
        [email protected],0 {
-               status = "okay";
+               status = "disabled";
        };
 
        [email protected],0 {

now there is no hang on enabling port0 and scsi scan can be used

pcie-issue on bananapi-r2 (hang if no card is inserted) is fixed. added it to my 2020-10-bpi branch.

Official patch was posted to mailinglist yesterday: https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/ maybe it goes into 2020-10

does anyone have an idea how to get hdmi working in uboot? just to display the bootmenu and console without debug-uart cable

@Ryder.Lee which code (from linux) is needed to get hdmi working? is there any driver i can look for the basic functions?

1 Like