BPI-R64 current u-boot support

Hi guys, could someone please explain how to run u-boot 64 bits on bpi-r64 ? I built frank-w branch 2020-04-bpi-all like this: changed build.conf board=bpi-r64 arch=arm64

./build.sh defconfig
./build.sh build
./build.sh install

I used an empty SD and flashed u-boot-mkt.bin at offset 768 thanks to last command.

I then got ATF BPI-R64 current u-boot support and flashed it as said here: BPI-R64 current u-boot support at offset 512.

Boot serial log:

F0: 102B 0000    
F6: 3800 00A0    
F3: 4000 0036    
F5: 4801 0000    
F5: 480A 0031    
00: 1005 0000    
F6: 3800 00A0    
F3: 4000 0036    
F5: 480A 0031    
F5: 480A 0031    
01: 102A 0001    
02: 1005 0000    
BP: 0000 00C0 [0001]    
T0: 0000 035E [000F]    
System halt!    

I also have a clearfog gt-8k that runs u-boot 64bits without issue but the build process wraps u-boot with atf so Iā€™m not sure I can apply this approach to this board. (see https://developer.solid-run.com/knowledge-base/armada-8040-machiatobin-u-boot-and-atf/) Thanks for help.

I realized I was missing the preloader. I dded the first 512k of the official 4.19 image and added them just before ATF, looks like it worked:

[BLDR] Others, jump to ATF    

[BLDR] jump to 0x41E00000    
[BLDR] <0x41E00000>=0x1400000A    
[BLDR] <0x41E00004>=0xD503201F    


U-Boot 2020.04-rc2-bpi-all-10605-g0542be266c-dirty (May 01 2020 - 21:12:17 +0200)    

CPU:   MediaTek MT7622    
Model: mt7622-rfb    
DRAM:  256 MiB    
WDT:   Started with servicing (60s timeout)    
MMC:   mmc@11230000: 0, mmc@11240000: 1    
In:    serial@11002000    
Out:   serial@11002000    
Err:   serial@11002000    
Net:   error: unsupported switch    
No ethernet found.    

MT7622>    

But I have the issue about RAM and switch so Iā€™ll dig the patches. Thanks.

The ram issue is caused by memory-node in ref-board dtsā€¦take a look to the bpi-r64 dts i used for 32bit mode to change it

For 64bit-mode you need a different atf like this: BPI-R64 current u-boot support preloader is same and you need to change arch in build.conf (i guess you already did). And you can use the 2020-04-bpi tree that should include some more patches (bpi-all was afair test-tree i uploaded accidentially) also switch-driver

xhci-driver itself is on the way to be merged but has no support for r2/r64 yetā€¦support is reported to get added after base driver is merged

for r2 i know that driver in current state does not support xhci version below 1 (r2 has 0.96). for r64 i have a probe-error where i do not know where it happen (can be ssusbsys,xhci itselfā€¦checked both, but seem to happen anywhere else)

hi sam, there is a Patch for pwm command in uboot mainlinglistā€¦is this compatible to mtk pwm-driver?

ā€œcmd: Add a pwm commandā€

btw. have you seen ATF-issue (mmc not recognized on reboot) i wrote you via PM?

Did you ever get USB to work in U-Boot? I get the driver to load and probe ports, but never detect any storage devices (in Linux works fine).

I got usb working on r2 and r64 with the patches i send upstream. But have not tested recent versions again

Should be these patches: https://github.com/frank-w/u-boot/commits/2020-10-upstream

To get uboot to work there were additional patches from chunfeng yun needed to add xhci 0.96 support. See the bpi branch

Output of tests in my wiki

https://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/uboot#usb

https://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r64/uboot#usb

And here in forum

Iā€™ve updated the U-Boot build for MediaTek targets in OpenWrt to U-Boot 2021.04-rc3 with patches from MediaTek on top. Iā€™ve checked and the USB patches you mentioned, both yours and Chunfengā€™s, have already been merged and made it into that version. Yet USB still doesnā€™t detect any devices. I suspect that switching to build for 64-bit may have broken thingsā€¦ Apart from that it now works great, @hackpascal had to help me to fix MMC a bit, but now itā€™s even fast :slight_smile:

1 Like

Yes they are already merged (imho 2020-10 only misses the xhci 0.96 patches,my dts were already in)

I had not tested it after changing to new bootchainā€¦my tests were done with 32bit version. Maybe dts needs to be changed for 64bit-mode?

What problems do you have with mmc? Which patch fixes mmc?

edit made a quick test for USB on my R64 v1.1:

NOTICE:  BL2: v2.4(release):v2.4-15-g54397dca8
NOTICE:  BL2: Built : 19:09:59, Jan 15 2021
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.4(release):v2.4-15-g54397dca8
NOTICE:  BL31: Built : 19:10:01, Jan 15 2021
                                                                                
                                                                                
U-Boot 2021.01-bpi (Jan 13 2021 - 19:46:11 +0100)                               
                                                                                
CPU:   MediaTek MT7622                                                          
Model: mt7622-bpi-r64                                                           
DRAM:  1 GiB                                                                    
WDT:   Started with servicing (60s timeout)                                     
MMC:   mmc@11230000: 0, mmc@11240000: 1                                         
In:    serial@11002000                                                          
Out:   serial@11002000                                                          
Err:   serial@11002000                                                          
Net:                                                                            
Warning: ethernet@1b100000 (eth0) using random MAC address - aa:ae:96:0b:a1:f7  
eth0: ethernet@1b100000                                                         
Hit any key to stop autoboot:  0                                                
switch to partitions #0, OK                                                     
mmc1 is current device                                                          
Boot from SD                                                                    
2bd17853-102b-4500-aa1a-8a21d4d7984d                                            
success!                                                                        
362 bytes read in 3 ms (117.2 KiB/s)                                            


  *** U-Boot Boot Menu ***

     1. Enter kernel-name to boot from SD/EMMC.
     2. Boot kernel from TFTP.
     3. Boot from SD/EMMC.
     U-Boot console


  Press UP/DOWN to move, ENTER to select

BPI-R64> usb start
starting USB...
Bus usb@1a0c0000: xhci-mtk usb@1a0c0000: hcd: 0x000000001a0c0000, ippc: 0x000000
xhci-mtk usb@1a0c0000: u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 0.96
scanning bus usb@1a0c0000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
BPI-R64> ls usb 0:1
            efi/
  1023582   ramdisk.img
  1365903   initrd.img
  2956137   install.img
 456908800   system.sfs
  4767728   kernel

5 file(s), 1 dir(s)

BPI-R64> 

as you can see USB is workingā€¦maybe you miss only a config-option for mass storage devices (see last option)

I got all the config options selected in the OpenWrt-build as well, see the defconfigs I create for eMMC and SD Card boot variants:

@hackpascal figured out that MMC was broken recently by

So Iā€™m reverting that. So also get SD Card back to work I always had to lower the max. clock to 12MHz as otherwise (at least with the no-name card I got here) things wouldnā€™t work. See the DTS changes Iā€™m using for the Bananapi BPi-R64 with U-Boot:

Limiting the max. clock frequency of the MMC bus used for the SD Card, however, was no longer possible after commit

So I had to fix that and made a patch

So that now all works. Just USB still doesnā€™t. As all that is part of OpenWrt, it should be easy for everyone to build everything from source themselves and (hopefully) help improving and fixing things where ever needed.

What I still miss in U-Boot right how:

  • USB edit: 2.0 working well enough to allow UEFI USB boot by default (for MemTest86 and such, already works fine on MMC). USB controller is detected, but USB 2.0 devices are not detected:
MT7622> usb start
starting USB...
Bus usb@1a0c0000: xhci-mtk usb@1a0c0000: hcd: 0x000000001a0c0000, ippc: 0x000000001a0c4700
xhci-mtk usb@1a0c0000: ports disabled mask: u3p-0x0, u2p-0x0
xhci-mtk usb@1a0c0000: u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 0.96
scanning bus usb@1a0c0000 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

(that 1 USB Device which is found is the root hub and is always there, no matter if an actual USB device is plugged in or not)

  • PSTORE (formally/also known as ramoops) working with Linux and U-Boot. As hard reset through SoC reset controller also re-initializes the DDR controller, RAM content gets corrupted by crash/oops/reboot. Implementing reset through ATF pcsc for Linux to use rather than triggering register may be a good work-around.

Maybe you can try 2021-01 for usb. I guess something in 2021-04 breaks itā€¦as you see in my log usb works with my 2021-01

Do you actually try with a USB 3.0 device? Because that also works for me, just non-USB-3.0 devices donā€™t (they do work in Linux, of course)

I used an usb2.0 stick for testing

I got it working. Was some other CONFIG option missing, I enabled everything which could remotely make sense and now it all works:

I wonder why usb3 was not working but usb2 beforeā€¦the only related youā€™ve added should be tphy (also sata depends on it) and CONFIG_TARGET_MT7622

Great. Will you post those fixups to mainline uboot?

Yes, I suspect either TPHY or DM_GPIO being the cause, I was too tired to isolate it at the point I got it working.

The only fix relevant for upstream makes changes on top of https://github.com/mtk-openwrt/u-boot , hence itā€™d be great if @hackpascal would squash that one into his series:

Iā€™m not sure whether just reverting is an option for upstream or if we have to find a better fix for

(ie. introducing uint64_t log_msg_ret64(char *, uint64_t) would be the proper fix, I guess)

Regarding DTS for BPi-R64 (outdated in U-Boot tree) and default config (missing), @frank-w had been working on that before and Iā€™m not sure what their plans are, if there is going to be a re-spin with fixes for upcoming U-Boot 2021.04:

upstream DTS should be same as mine except the mmc-change

Iā€™m not sure using 64bit function/pointer here as this is used for 32 bit too (clk core)

Do you got a (silent) crash without revert? I do not fully understand macro

https://elixir.bootlin.com/u-boot/latest/source/include/log.h#L305

It should return the ret passed to it,i guess itā€™s the last line (_ret without anything else)

Iā€™ve added LEDs and buttons, had to lower MMC frequency to make SD Card work reliable (at least for the card I got here) and added the ethernet0 alias to make U-Boot pass down ethaddr to Linux. Should I send a patch for that you reckon?