# RTL8153B  Gbit interface not loading FreeBSD 13.0 ALPHA2 installed RK3328 board



## alfa (Feb 6, 2021)

Hi, i have installed FreeBSD 13.0 ALPHA2 ROCK64 on Orange Pi R1 Plus but
RTL8153B is not loading. When i typed ifconfig there is only dwc0 interface(RTL8211E)
and also FreeBSD is recognizing double RTL8211 phy devices so that what is the my problem?
any help would be appreciated

```
root@generic:~ # dmesg | grep RTL
rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 0 on miibus0
rgephy1: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
```


```
root@generic:~ # dmesg | grep ure0
root@generic:~ #
```


```
root@generic:~ # uname -a
FreeBSD generic 13.0-ALPHA2 FreeBSD 13.0-ALPHA2 #0 c256201-g02611ef8ee9: Fri Jan 22 06:35:39 UTC 2021     [EMAIL]root@releng1.nyi.freebsd.org[/EMAIL]:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC  arm64
```
regards


----------



## alfa (Feb 6, 2021)

When i tried @ganbold 's FreeBSD image
here is the result:
this time FreeBSD recognized RTL8153b but attaching PHY is failed shown below from logs
so what can be the problem?


```
root@generic:~ # usbconfig
ugen0.1: <Synopsys XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.2: <Realtek USB 10/100/1000 LAN> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (72mA)

root@generic:~ # dmesg | grep ure0
ure0 on uhub3
ure0: <Realtek USB 10/100/1000 LAN, class 0/0, rev 3.00/31.00, addr 1> on usbus3
ure0: unknown version 0x0000
ure0: timeout waiting for chip autoload
ure0: timeout waiting for phy to stabilize
ure0: timeout waiting for phy to stabilize
ure0: timeout waiting for phy to stabilize
ure0: MAC assigned randomly
ure0: attaching PHYs failed

root@generic:~ # usbconfig -d ugen3.2 dump_device_desc
ugen3.2: <Realtek USB 10/100/1000 LAN> at usbus3, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (72mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0300
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0009
  idVendor = 0x0bda
  idProduct = 0x8153
  bcdDevice = 0x3100
  iManufacturer = 0x0001  <retrieving string failed>
  iProduct = 0x0002  <retrieving string failed>
  iSerialNumber = 0x0006  <retrieving string failed>
  bNumConfigurations = 0x0002

root@generic:~ # usbconfig -d ugen3.2 dump_all_config_desc | grep -i binterface
      bInterfaceNumber = 0x0000
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x00ff
      bInterfaceProtocol = 0x0000
```


----------



## guyyur (Apr 3, 2021)

Hi, I got an Orange Pi R1 Plus yesterday and encountered the same problem.
The driver tries to read the chip version and fails with USB_ERR_IOERROR.
I saw some linux posts about issues with the USB 3.0 controller (hangs, unreliable irqs, ...)

If I reset the device (appears as ugen4.2 for me), the chip version is read as 0x6010.
usbconfig -d ugen4.2 reset

This chip version is not supported in FreeBSD 13.0-RC5.
In OpenBSD it was added with this commit:








						Add support for RTL8153B after study of Linux r8152 driver. · openbsd/src@55929a1
					

Tested by myself, jcs@




					github.com
				




I saw there is bug report with a patch to add support for RTL8153B, RTL8156, RTL8156B:





						253374 – [if_ure] Add support for RTL8153B, RTL8156 and RTL8156B
					






					bugs.freebsd.org
				




I also attempted to port openbsd support for RTL8153B only:








						GitHub - guyyur/freebsd-src at ure_rtl8153b_from_openbsd
					

FreeBSD src tree (read-only mirror). Contribute to guyyur/freebsd-src development by creating an account on GitHub.




					github.com
				




When I run with my patch the card is detected after "usbconfig ... reset" but I get xhci resets when trying to transmit.
So there are more fixes needed (possibly in xhci controller or device tree).

xhci0: Resetting controller
uhub2: at usbus4, port 1, addr 1 (disconnected)
ugen4.2: <Realtek USB 10/100/1000 LAN> at usbus4 (disconnected)
ure0: at uhub2, port 2, addr 1 (disconnected)


----------



## alfa (Apr 4, 2021)

FreeBSD does not have RTL8153B yet . I moved on to Nanopi R4S . FreeBSD works on this device and Dual Gigabit PHY devices also works too .But second ethernet device based on Pci-e not using usb which is nice . it is re0 device and there is a weird thing mac adress has 00:00:00:00:00:00 all zeros. Also I did iperf3 and results are max 400Mb/s-500Mb/s i cannot understand why ?

__ https://twitter.com/i/web/status/1337971697748611072_View: https://twitter.com/g0mb0/status/1337971697748611072_


----------



## Szczepan (Apr 21, 2021)

guyyur said:


> Hi, I got an Orange Pi R1 Plus yesterday and encountered the same problem.
> The driver tries to read the chip version and fails with USB_ERR_IOERROR.
> I saw some linux posts about issues with the USB 3.0 controller (hangs, unreliable irqs, ...)
> 
> ...


Have you tried 13-RELEASE maybe?
Also which image did you use (or you made one based on what)?


----------



## guyyur (Apr 22, 2021)

Szczepan said:


> Have you tried 13-RELEASE maybe?
> Also which image did you use (or you made one based on what)?


I built 13-RELEASE kernel from source with patches for ure driver to support RTL8153B and added r1plus dts files based on linux-orangepi.
I also used a local port based on u-boot-master but with patches for r1 plus based on u-boot-orangepi.

The USB3 controller is not working correctly so the RTL8153B nic is not working.
Either the device tree I used is missing something or the usb3 controller driver needs some changes.

Looks like RK3328 is not supported as well as RK3399,
there is no usb3 listed in rk3328.dtsi in mainline linux
and there is no dts file for the board in mainline u-boot nor in mainline linux tree.


----------



## Szczepan (Apr 28, 2021)

Hm, those two ethernet are supported under Linux OpenWrt, so dts must be present (at least for NanoPi R2S as I own this board), but the same thing under FreeBSD


----------



## alfa (Jun 27, 2021)

__ https://twitter.com/i/web/status/1400829158482223111_View: https://twitter.com/g0mb0/status/1400829158482223111?s=20_


----------



## SleepWalker (Jul 2, 2021)

Hello everybody!

I managed to create a custom U-boot for the Nano-Pi-R2S.
It allows FreeBSD 14.0-CURRENT to run on Nano-Pi-R2S.
I also have a custom build of FreeBSD 13.0-RELEASE with a fixed if_ure driver.
No dtb files required. FreeBSD gets dtb from U-boot via EFI.

The test image can be downloaded here.


			PersonalBSD.org » Downloads


----------



## alfa (Nov 13, 2021)

SleepWalker said:


> Hello everybody!
> 
> I managed to create a custom U-boot for the Nano-Pi-R2S.
> It allows FreeBSD 14.0-CURRENT to run on Nano-Pi-R2S.
> ...


Hi, are you able to install u-boot to SPI Flash?


----------



## SleepWalker (Nov 22, 2021)

alfa said:


> Hi, are you able to install u-boot to SPI Flash?


No, this u-boot is not meant to be written to SPI flash.
But if you write it to an SD card and insert it into a USB flash disk with FreeBSD, 
then the system will start from USB.


----------



## spikerguy (Jan 13, 2022)

alfa said:


> Hi, are you able to install u-boot to SPI Flash?


Have you tried the latest image on R2S ? 

I want to know how stable RTL8153B is for you.


----------



## alfa (Jan 15, 2022)

spikerguy said:


> Have you tried the latest image on R2S ?
> 
> I want to know how stable RTL8153B is for you.


No, moved on to R4S


----------



## alfa (Mar 12, 2022)

SleepWalker said:


> SleepWalker said:
> 
> 
> > Hello everybody!
> ...


Hi, i am turned back to test RTL8153B on Orange Pi R1 Plus (R2S clone) and tried to build new kernel with fixed if_ure driver. But its failed again i wanna ask for your help at this point
Here is my build configs:

```
used this image:
FreeBSD-13.0-RELEASE-arm64-aarch64-ROCK64.img.xz
src repo:
git clone https://git.freebsd.org/src.git /usr/src
git config --global http.sslVerify false
git clone -b releng/13.0 --depth 1 https://git.freebsd.org/src.git /usr/src
```


```
downloaded this patch:
https://bz-attachments.freebsd.org/attachment.cgi?id=222292

and renamed as ure.patch and apply it gives me error:
root@generic:/ # git apply ure.patch

ure.patch:166: trailing whitespace.
    
ure.patch:430: trailing whitespace.
    
ure.patch:571: trailing whitespace.
            anar | ANAR_PAUSE_ASYM | ANAR_FC); 
ure.patch:572: trailing whitespace.
        ure_ocp_reg_write(sc, URE_OCP_BASE_MII + MII_100T2CR * 2, gig); 
ure.patch:602: trailing whitespace.
                (status & URE_PHYSTATUS_2500MBPS)) 
error: patch failed: usr/src/sys/dev/usb/net/if_ure.c:96
error: usr/src/sys/dev/usb/net/if_ure.c: patch does not apply
error: patch failed: usr/src/sys/dev/usb/net/if_urereg.h:40
error: usr/src/sys/dev/usb/net/if_urereg.h: patch does not apply
root@generic:/ # 

git apply --reject --whitespace=fix ure.patch
error logs:
https://pastebin.com/UNDXGytp
```


```
kernel building:
added 
       device uhci
       device ohci
       device usb
       device miibus
       device uether
       device ure

to MYKERNEL conf

cd /usr/src/sys/arm64/conf
mkdir /root/kernels
cp GENERIC /root/kernels/MYKERNEL
ln -s /root/kernels/MYKERNEL
cd /usr/src/
make buildkernel KERNCONF=MYKERNEL -j 4
make installkernel KERNCONF=MYKERNEL
```

Thanks for any help...


----------



## alfa (Mar 21, 2022)

SleepWalker said:


> Hello everybody!
> 
> I managed to create a custom U-boot for the Nano-Pi-R2S.
> It allows FreeBSD 14.0-CURRENT to run on Nano-Pi-R2S.
> ...


SleepWalker  Your rk3328(R2S) image not worked on OpiR1Plus(R2S clone) even not booted . I installed other u-boot then it booted but this time usb ethernet not works

*usb ethernet problem >>*

```
root@nanopi-r2s:~ # ifconfig
dwc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8000b<RXCSUM,TXCSUM,VLAN_MTU,LINKSTATE>
        ether 56:f3:66:44:8f:ec
        media: Ethernet autoselect (none)
        status: no carrier
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
root@nanopi-r2s:~ #
```

*U-Boot problem >>*


```
U-Boot 2020.07 (Oct 28 2021 - 10:28:25 +0300)

Model: FriendlyElec NanoPi R2S
DRAM:  1022 MiB
PMIC:  RK8050 (on=0x40, off=0x00)

U-Boot TPL 2020.07 (Oct 28 2021 - 10:28:25)
DDR4, 333MHz
BW=32 Col=10 Bk=4 BG=2 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.07 (Oct 28 2021 - 10:28:25 +0300)
Trying to boot from MMC1
NOTICE:  BL31: v2.4(release):
NOTICE:  BL31: Built : 17:49:21, Sep  2 2021
NOTICE:  BL31:Rockchip release version: v1.2
```


----------



## SleepWalker (Mar 21, 2022)

alfa 
Try the standard FreeeBSD 14.0-CURRENT, post the full dmesg.
I do not have this equipment, I need to look for a solution ....


----------



## alfa (Mar 22, 2022)

SleepWalker said:


> alfa
> Try the standard FreeeBSD 14.0-CURRENT, post the full dmesg.
> I do not have this equipment, I need to look for a solution ....


Thanks, i installed FreeBSD 14.0 Current but not booted here is log:

```
## FreeBSD-14.0-CURRENT-arm64-aarch64-ROCK64-20220310-f1d450ddee6-253697.img.xz

U-Boot TPL 2021.07 (Mar 17 2022 - 05:26:49)
data training error
col error
data training error
LPDDR3, 800MHz
BW=16 Col=12 Bk=8 CS0 Row=16 CS=1 Die BW=8 Size=4096MB


### https://personalbsd.org/download/u-boot/u-boot-roc-rk3328-pc/u-boot-roc-rk3328-pc
<debug_uart>
U-Boot TPL 2020.07 (Oct 28 2021 - 10:32:12)
data training error
col error
data training error
DDR3, 333MHz
BW=16 Col=12 Bk=8 CS0 Row=16 CS=1 Die BW=8 Size=4096MB



### https://personalbsd.org/download/u-boot/u-boot-nanopi-r2s/

U-Boot 2020.07 (Oct 28 2021 - 10:28:25 +0300)

Model: FriendlyElec NanoPi R2S
DRAM:  1022 MiB
PMIC:  RK8050 (on=0x40, off=0x00)

U-Boot TPL 2020.07 (Oct 28 2021 - 10:28:25)
DDR4, 333MHz
BW=32 Col=10 Bk=4 BG=2 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2020.07 (Oct 28 2021 - 10:28:25 +0300)
Trying to boot from MMC1
NOTICE:  BL31: v2.4(release):
NOTICE:  BL31: Built : 17:49:21, Sep  2 2021
NOTICE:  BL31:Rockchip release version: v1.2


U-Boot 2020.07 (Oct 28 2021 - 10:28:25 +0300)

Model: FriendlyElec NanoPi R2S
DRAM:  1022 MiB
PMIC:  RK8050 (on=0x40, off=0x00)
```


----------

