Skip to content

Add wolfIP Ethernet port for RealTek RTL8735B (AmebaPro2)#141

Draft
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:rtl8735b_wolfip
Draft

Add wolfIP Ethernet port for RealTek RTL8735B (AmebaPro2)#141
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:rtl8735b_wolfip

Conversation

@dgarske

@dgarske dgarske commented Jul 8, 2026

Copy link
Copy Markdown
Member

Adds src/port/rtl8735b/: a wolfIP Ethernet port for the RTL8735B (AmebaPro2) EVB over the vendor FreeRTOS SDK mbed Ethernet HAL (native MAC + integrated FEPHY, no lwIP).

  • Thin poll/send driver glue; whole stack in one FreeRTOS task.
  • DHCP + TCP echo server demo.
  • wolfSSL TLS 1.2/1.3 client demo (-DWOLFIP_ENABLE_TLS=ON).
  • wolfip_eth.cmake SDK integration + wolfip_cycle.sh helper.

Also adds a WOLFIP_NO_SYS_HEADERS opt-out in wolfip.h.

Hardware-verified: DHCP lease, TCP echo, and a full TLS 1.3 handshake.

@dgarske dgarske self-assigned this Jul 8, 2026
Copilot AI review requested due to automatic review settings July 8, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new wolfIP Ethernet port/example for the RealTek RTL8735B (AmebaPro2) FreeRTOS SDK environment, including SDK build wiring, a DHCP+TCP echo demo, and an optional wolfSSL TLS client demo. Also introduces a WOLFIP_NO_SYS_HEADERS switch in wolfip.h to avoid conflicts with foreign <sys/socket.h> shims in some RTOS SDKs.

Changes:

  • Add WOLFIP_NO_SYS_HEADERS to bypass system socket header probing and rely on wolfIP’s internal POSIX-type fallbacks.
  • Introduce src/port/rtl8735b/ with MAC/PHY glue (poll/send), example app, and documentation.
  • Add RTL8735B SDK integration CMake and a build/flash/run helper script; optionally pulls in wolfSSL sources for the TLS demo.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wolfip.h Adds WOLFIP_NO_SYS_HEADERS opt-out to avoid conflicting RTOS socket headers.
src/port/rtl8735b/wolfip_rtl8735b.h Declares RTL8735B Ethernet init/link/maintain API for the port.
src/port/rtl8735b/wolfip_rtl8735b.c Implements the vendor HAL adapter (poll/send), TRNG-backed wolfIP_getrandom, and MAC init wiring.
src/port/rtl8735b/wolfip_eth.cmake SDK build integration; optionally pulls in wolfSSL and the TLS client demo.
src/port/rtl8735b/wolfip_cycle.sh Automates configure/build/flash/log tail for the SDK demo workflow.
src/port/rtl8735b/user_settings.h wolfSSL user settings for the RTL8735B TLS-client demo build.
src/port/rtl8735b/tls_client.h Declares the demo TLS client API.
src/port/rtl8735b/tls_client.c Implements the demo TLS client state machine using wolfIP sockets + wolfSSL I/O glue.
src/port/rtl8735b/README.md Port/demo documentation and run instructions for milestone 1/2.
src/port/rtl8735b/main.c FreeRTOS single-task demo: link/DHCP wait, TCP echo server, optional TLS client.
src/port/rtl8735b/config.h wolfIP stack configuration for the RTL8735B demo build (MTU, sockets, DHCP, static fallback).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +163 to +191
/* DMA packet buffers from the vendor DMA-capable heap. */
tx_pkt_buf = (uint8_t *)pvPortMallocExt(RTL8735B_TX_DESC_NO * ETH_PKT_BUF_SIZE, 1);
rx_pkt_buf = (uint8_t *)pvPortMallocExt(RTL8735B_RX_DESC_NO * ETH_PKT_BUF_SIZE, 1);
if (tx_pkt_buf == NULL || rx_pkt_buf == NULL)
return -2;

memset(tx_desc, 0, RTL8735B_TX_DESC_NO * ETH_TX_DESC_SIZE);
memset(rx_desc, 0, RTL8735B_RX_DESC_NO * ETH_RX_DESC_SIZE);
memset(tx_pkt_buf, 0, RTL8735B_TX_DESC_NO * ETH_PKT_BUF_SIZE);
memset(rx_pkt_buf, 0, RTL8735B_RX_DESC_NO * ETH_PKT_BUF_SIZE);

/* MAC: caller-supplied, else efuse, else locally-administered. */
if (mac == NULL) {
ethernet_address((char *)local_mac);
if ((local_mac[0] | local_mac[1] | local_mac[2] |
local_mac[3] | local_mac[4] | local_mac[5]) == 0) {
local_mac[0] = 0x02; local_mac[1] = 0xE0; local_mac[2] = 0x4C;
local_mac[3] = 0x87; local_mac[4] = 0x35; local_mac[5] = 0xB0;
}
mac = local_mac;
}

/* Hook link events, wire rings/buffers/MAC into the HAL, then start. */
ethernet_irq_hook(rtl8735b_eth_irq);
ethernet_set_descnum(RTL8735B_TX_DESC_NO, RTL8735B_RX_DESC_NO);
ethernet_trx_pre_setting(tx_desc, rx_desc, tx_pkt_buf, rx_pkt_buf);
ethernet_set_address((char *)mac);
if (ethernet_init() != 0)
return -3;
Comment on lines +79 to +83
memset(&client, 0, sizeof(client));
client.stack = stack;
client.debug_cb = debug;
client.fd = -1;
client.state = TLS_CLIENT_STATE_IDLE;
Comment on lines +136 to +137
/* Try to parse as IP address first */
client.server_ip = atoip4(host);
Comment on lines +36 to +37
L="/tmp/uart-monitor/latest/$LABEL.log"
FLASH="$HOME/.claude/skills/amebapro2-flash/amebapro2_flash.sh"
Comment on lines +13 to +17
# Env overrides (defaults shown):
# WOLFIP_ROOT=~/GitHub/wolfip WOLFSSL_ROOT=~/GitHub/wolfssl
# SDK=~/GitHub/ameba-rtos-pro2
# ASDK_BIN=~/ameba-pro2-workspace/asdk/asdk-10.3.0/linux/newlib/bin
# LABEL=GENERIC_UART_ttyUSB5 WATCH_SECS=40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants