Working Realtek SoC RTL8196E 97D 97F in last master

I have ported the RTL8196E RTL8197D and RTL8197F SoC from Realtek to the last master of Openwrt (as of today).

This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins or for reporting issues. We will continue to accept Pull Request...

The port have the necessary code for those SoCs. I used the @hackpascal initial port as a start and have ported RLX4181 and RLX5281 Lexra processors. Those are easier to port, as they have the unaligned instructions. Musl is working in lexra now...
RTL8197F uses a full 24k mips processor, so, no modification is needed in the toolchain...

For the SoCs:
All the SoC drivers are implemented and tested (gpio, pci, irq, timers, etc), for the three SoCs. One can port a router to openwrt just creating a DTS file for it (and changing the Makefiles, as any normal port for openwrt).

The problem is with network and wireless. RTL8196E based routers can use the RTL8192EE open source wifi driver from mac80211 package. Most routers that use RTL8197D SoC also use RTL8192EE for 2.4 and RTL8812 for 5... Both drivers are open source on linux kernel...

TODO:

  • Network and switch driver: hackpascal has started the port for RE865X driver. Need rework for new SoCs....
  • RTL8197F 2.4Ghz wireless driver: This SoC uses an internal wifi, but can be ported to the new RTW88 driver, as they use the same structs (8192EE uses this structs too, but is implemented in the old driver... May a port of 8192EE to the new driver can help too :slight_smile: )
  • Performace: The main focus right now is compatibility... We need to improve for performace....

Use the ramdisk for now... As we dont have the network driver right now, we must use the serial port to bootup... The cvimg boot can be used, but is now of much use right now...

Any help and feedback are welcome :slight_smile:

5 Likes

Bootlog for RTL8192E

[    0.000000] Linux version 4.14.187 (gaspare@gaspare-MacBookAir) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r14023-1deaf695ec)) #0 T0
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 0000cd01 (Lexra LX4380 / RLX4181)
[    0.000000] MIPS: machine is Multilaser RE172 V1
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 02000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] BOOTSTRAP = 8196e001 2 100218 b08
[    0.000000] Primary instruction cache 16kB, linesize 16 bytes.
[    0.000000] Primary write-back data cache 8kB, linesize 16 bytes.
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x9c/0x4e0 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 8120
[    0.000000] Kernel command line: console=ttyS0,38400
[    0.000000] PID hash table entries: 128 (order: -3, 512 bytes)
[    0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Memory: 19248K/32768K available (4442K kernel code, 159K rwdata, 832K rodata, 7488K init, 204K bss, 13520K reserve)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 128
[    0.000000] clocksource: RTL819X counter: mask: 0xfffffff max_cycles: 0xfffffff, max_idle_ns: 4778151100 ns
[    0.000034] sched_clock: 28 bits at 25MHz, resolution 40ns, wraps every 5368709100ns
[    0.025522] timer-controller: running - mult: 107374182, shift: 32, IRQ: 7, CLK: 25.000MHz
[    0.052958] Calibrating delay loop... 397.82 BogoMIPS (lpj=795648)
[    0.105601] pid_max: default: 32768 minimum: 301
[    0.121964] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.143697] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.184820] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.216906] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.239084] NET: Registered protocol family 16
[    1.001167] PCI host bridge to bus 0000:00
[    1.014647] pci_bus 0000:00: root bus resource [mem 0x19000000-0x19ffffff]
[    1.037216] pci_bus 0000:00: root bus resource [io  0x18c00000-0x18dfffff]
[    1.059810] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    1.082111] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    1.109647] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    1.138528] pci 0000:00:00.0: BAR 8: assigned [mem 0x19000000-0x190fffff]
[    1.160894] pci 0000:00:00.0: BAR 7: assigned [io  0x18c00000-0x18c00fff]
[    1.183247] pci 0000:01:00.0: BAR 2: assigned [mem 0x19000000-0x19003fff 64bit]
[    1.207328] pci 0000:01:00.0: BAR 0: assigned [io  0x18c00000-0x18c000ff]
[    1.229645] pci 0000:00:00.0: PCI bridge to [bus 01]
[    1.245948] pci 0000:00:00.0:   bridge window [io  0x18c00000-0x18c00fff]
[    1.268256] pci 0000:00:00.0:   bridge window [mem 0x19000000-0x190fffff]
[    1.293361] clocksource: Switched to clocksource RTL819X counter
[    1.319464] NET: Registered protocol family 2
[    1.336443] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    1.359429] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    1.380334] TCP: Hash tables configured (established 1024 bind 1024)
[    1.401946] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    1.421214] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    1.443012] NET: Registered protocol family 1
[    1.573510] random: fast init done
[    2.296471] Crashlog allocated RAM at address 0x1f00000
[    2.323211] workingset: timestamp_bits=14 max_order=13 bucket_order=0
[    2.381620] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    2.400799] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    2.568508] io scheduler noop registered
[    2.581500] io scheduler deadline registered (default)
[    2.600128] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[    2.623840] console [ttyS0] disabled
[    2.635794] 18002000.serial: ttyS0 at MMIO 0x18002000 (irq = 28, base_baud = 12500000) is a 16550A
[    2.665498] console [ttyS0] enabled
[    2.665498] console [ttyS0] enabled
[    2.688503] bootconsole [early0] disabled
[    2.688503] bootconsole [early0] disabled
[    2.743549] m25p80 spi0.0: gd25q32 (4096 Kbytes)
[    2.824635] 2 fixed-partitions partitions found on MTD device spi0.0
[    2.845952] Creating 2 MTD partitions on "spi0.0":
[    2.862089] 0x000000000000-0x000000010000 : "boot"
[    2.882633] 0x000000010000-0x000000400000 : "firmware"
[    2.909620] NET: Registered protocol family 10
[    2.947927] Segment Routing with IPv6
[    2.960656] NET: Registered protocol family 17
[    2.975928] 8021q: 802.1Q VLAN Support v1.8
[    3.035923] Freeing unused kernel memory: 7488K
[    3.051177] This architecture does not have kernel memory protection.
[    3.131238] init: Console is alive
[    3.211875] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    3.246387] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    3.282665] init: - preinit -

[    4.734676] random: jshn: uninitialized urandom read (4 bytes read)
[    5.069736] random: jshn: uninitialized urandom read (4 bytes read)
[    5.998420] random: jshn: uninitialized urandom read (4 bytes read)
[    6.217717] random: jshn: uninitialized urandom read (4 bytes read)
[    6.755500] random: jshn: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   10.816134] procd: - early -
[   11.505577] procd: - ubus -
[   11.542893] random: ubusd: uninitialized urandom read (4 bytes read)
[   11.569277] random: ubusd: uninitialized urandom read (4 bytes read)
[   11.592857] random: ubusd: uninitialized urandom read (4 bytes read)
[   11.623301] procd: - init -
Please press Enter to activate this console.
[   13.865007] kmodloader: loading kernel modules from /etc/modules.d/*
[   13.951095] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   14.056952] Loading modules backported from Linux version v5.8-rc2-0-g48778464bb7d
[   14.082325] Backport generated by backports.git v5.8-rc2-1-0-g7a69429b
[   14.145792] urngd: v1.0.2 started.
[   14.171293] ip_tables: (C) 2000-2006 Netfilter Core Team
[   14.255706] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[   14.688222] xt_time: kernel timezone is -0000
[   14.872751] random: crng init done
[   14.884328] random: 2 urandom warning(s) missed due to ratelimiting
[   15.077787] PPP generic driver version 2.4.2
[   15.128741] NET: Registered protocol family 24
[   15.308137] PCI: Enabling device 0000:00:00.0 (0000 -> 0003)
[   15.361707] rtl8192ee: Using firmware rtlwifi/rtl8192eefw.bin
[   15.396009] rtlwifi: rtlwifi: wireless switch is on
[   15.542723] kmodloader: done loading kernel modules from /etc/modules.d/*



BusyBox v1.31.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r14023+1-1deaf695ec
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@(none):/# 

3 Likes

Excellent work done here, porting into dts system is a godsend. I also started something earlier but I was alone and couldn't forward much. @gaspare





Can you help me build the firmware for a RTL8197D router with 8mb flash and 32mb ram? I attempted to build on my machine but encountered an "dependency on 'libpcre' " error that I was not able to resolve. I am trying to unbrick my router locked in miniweb server after firmware update.

Good day,
I have tried to compile this tree for some device on rtl8196e SoC. But usb, wifi (rtl8192er) and ethernet not working. May be need to enable any driver in kernel? Also, there are no any usb/eth items in dts files.
I need help.

Wifi needs the open firmware for 8192er (open firmware only have the 8192ee)... Actually, ee and er are very similar...
For switch driver, I'm working on converting the patch for kernel 5.4 to use the DSA switch api... I don't have plan (time) to support usb right now...

Wow. Nice!

I recently purchased the Lidl home automation gateway, which turns out to use the RTL8194E-CG SoC.

It is actually a rebranded Tuya TYGWZ1 board

the flash chip is a 25Q127CSIG - which means 16MB of flash?
And 32MB of RAM?
Anyway the zigbee dongle is a TYZS4 and seems to be connected to one of the uarts.

So the only thing missing is networking.
Also, i dont fully undestand what the J1 pins are. is this the other uart or a jtag?

1 Like

This post was flagged by the community and is temporarily hidden.

I have connected a 3.3V serial port to the Lidl Zigbee GW, (RTL8194E-CG SoC, Tuya TYGWZ1):

Some interesting lines from boot-up log:

---RealTek(RTL8196E)at 2020.04.28-13:58+0800 v3.4T-pre2 [16bit](400MHz)
Linux version 3.10.90 (dingsl@dingsl-pc) (gcc version 4.6.4 (Realtek RSDK-4.6.4 Build 2080) ) #10 Tue Apr 28 14:03:14 CST 2020
serial8250: ttyS0 at MMIO 0x18002000 (irq = 9) is a 16550A
serial8250: ttyS1 at MMIO 0x18002100 (irq = 13) is a 16550A
5 rtkxxpart partitions found on MTD device flash_bank_1
Creating 5 MTD partitions on "flash_bank_1":
0x000000000000-0x000000020000 : "boot+cfg"
0x000000020000-0x000000200000 : "linux"
0x000000200000-0x000000400000 : "rootfs"
0x000000400000-0x000000420000 : "tuya-label"
0x000000420000-0x000001000000 : "jffs2-fs"
eth0 added. vid=9 Member port 0x10f...
eth1 added. vid=8 Member port 0x10...
[peth0] added, mapping to [eth1]...
VFS: Mounted root (squashfs filesystem) readonly on device 31:2.
Freeing unused kernel memory: 192K (802f0000 - 80320000)
init started: BusyBox v1.13.4 (2020-04-28 13:57:36 CST)
Please press Enter to activate this console. Tuya Gateway Application Normal Srart /tuya/tuya_start.sh UserAppRunDir:
tuya-linux login:

Port speed is 38400, On 3 of the J1 Pins, or on the underside of the PCB are labelled pads.