Skip to content

Add wolfBoot HAL port for RealTek RTL8735B (AmebaPro2)#797

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

Add wolfBoot HAL port for RealTek RTL8735B (AmebaPro2)#797
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:rtl8735b_amebapro2

Conversation

@dgarske

@dgarske dgarske commented Jun 15, 2026

Copy link
Copy Markdown
Member

Adds wolfBoot support for the RealTek RTL8735B (Arm Cortex-M33) as used on the AmebaPro2 EVB. wolfBoot runs as a second-stage verified bootloader and A/B firmware-update engine on top of RealTek's secure-boot ROM -- the non-TrustZone "Model A" integration.

How it boots

RealTek ROM -> boot.bin -> wolfBoot (staged into SRAM via a RealTek RAM start-table) -> verifies the application in external SPI NOR (ECDSA P-256 / SHA-256), applies any pending A/B update, copies the verified image into DDR, and jumps. This reuses wolfBoot's existing RAMBOOT path (EXT_FLASH + NO_XIP, src/update_ram.c); no new boot assembly is required.

What's included

  • hal/rtl8735b.c / hal/rtl8735b.ld: single-file HAL -- HAL entry points, ext_flash_* over the RealTek SPI NOR, the RAM start-table + trampoline, cache maintenance, a self-contained DEBUG_UART console, and a reset-reason readout. Flash/UART/cache backend selected by HAL_BACKEND (sdk = default/working; bare = scaffold).
  • config/examples/rtl8735b.config and an arch.mk target block.
  • tools/scripts/rtl8735b_build.sh (compile + SDK-resolved final link) and tools/scripts/amebapro2_package.sh (wrap wolfboot.elf into a flashable flash_ntz.bin).
  • hal/rtl8735b/test-app/: a minimal DDR test application (also demonstrates servicing the vendor watchdog).
  • docs/Targets.md section (build, staging an app, A/B update, watchdog, status/roadmap) and hal/rtl8735b/README.

Verified on the AmebaPro2 EVB

  • DEBUG_UART console and signed boot of an application from the BOOT partition (verify -> copy to DDR -> jump).
  • A/B update (version-based selection), rollback / anti-downgrade fail-safe, and fault-tolerant fallback to a valid redundant image.
  • Reset-reason diagnostic and the vendor-watchdog handoff (the application services it).

Follow-ons (not in this PR)

See the "Status and roadmap" list in the docs/Targets.md section: device-bound encrypted updates bound to the Hardware Unique Key (wolfSSL PR #10677), TrustZone-M "Model B", the no-SDK "bare" backend, and measured boot / DICE.

@dgarske dgarske self-assigned this Jun 15, 2026
Copilot AI review requested due to automatic review settings June 15, 2026 22:42

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds initial wolfBoot HAL enablement for the RealTek RTL8735B (AmebaPro2) platform, including build integration and packaging support for producing a flashable image using the vendor SDK tooling.

Changes:

  • Introduces a new RTL8735B HAL implementation and linker script for SRAM-staged boot.
  • Adds an SDK shim header to avoid pulling FreeRTOS/CMSIS-OS into the wolfBoot build.
  • Adds build system wiring (arch.mk), example config, and a packaging script to generate flash_ntz.bin.

Reviewed changes

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

Show a summary per file
File Description
tools/scripts/amebapro2_package.sh Adds packaging flow to convert wolfboot.elf into a vendor-style flash image.
hal/rtl8735b/sdk-shim/cmsis_os.h Provides CMSIS-OS opaque typedefs to compile SDK headers without FreeRTOS.
hal/rtl8735b/README Documents the RTL8735B HAL design, backends, and SDK integration approach.
hal/rtl8735b.ld Defines SRAM layout, RAM start-table placement, and partition symbols.
hal/rtl8735b.c Implements RTL8735B HAL + RAM start-table/trampoline + SDK-backed ext flash/cache hooks.
config/examples/rtl8735b.config Provides an example configuration for RTL8735B builds and partition layout.
arch.mk Adds TARGET=rtl8735b build integration and SDK include/define wiring.

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

Comment thread tools/scripts/amebapro2_package.sh
Comment thread hal/rtl8735b.ld Outdated
Comment thread hal/rtl8735b.c
Comment thread hal/rtl8735b.c Outdated
Comment thread arch.mk Outdated
@dgarske dgarske force-pushed the rtl8735b_amebapro2 branch 3 times, most recently from 5301be9 to 833e5bb Compare June 16, 2026 23:05
@dgarske dgarske requested a review from Copilot June 16, 2026 23:05

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

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

Comment on lines +32 to +41
# Compile all objects. The default link of wolfboot.elf is expected to fail here
# (unresolved SDK/ROM symbols); capture the object list from its [LD] line.
make TARGET=rtl8735b 2>/tmp/rtl8735b_make_err.txt \
| grep -A1 '\[LD\] wolfboot.elf' | tail -1 > /tmp/rtl8735b_objs.txt || true
OBJS="$(cat /tmp/rtl8735b_objs.txt)"
if ! echo "$OBJS" | grep -q 'hal/rtl8735b.o'; then
echo "error: object compile failed (no hal/rtl8735b.o in link line). make stderr:" >&2
tail -8 /tmp/rtl8735b_make_err.txt >&2
exit 1
fi
Comment thread tools/scripts/rtl8735b_build.sh Outdated
Comment on lines +43 to +51
# Make the ROM symbol table visible to the linker.
grep -q 'romsym_is.so' config/target.ld || \
sed -i '1i INCLUDE "romsym_is.so"' config/target.ld

"$CC" -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=softfp \
-ffreestanding -nostartfiles --specs=nosys.specs \
-T config/target.ld \
-L "$SDKREL/ROM/GCC" -L "$SDKREL/application/output" \
$OBJS \
Comment on lines +12 to +21
# Override via environment:
# AMEBA_SDK RealTek ameba-rtos-pro2 checkout
# ASDK_PATH ASDK 10.3.0 toolchain bin dir
# OUTDIR work/output dir (default /tmp/wolfboot_amebapro2_pkg)
set -e

WOLFBOOT_ELF="${1:-wolfboot.elf}"
AMEBA_SDK="${AMEBA_SDK:-$HOME/GitHub/ameba-rtos-pro2}"
ASDK_PATH="${ASDK_PATH:-$HOME/ameba-pro2-workspace/asdk/asdk-10.3.0/linux/newlib/bin}"
OUTDIR="${OUTDIR:-/tmp/wolfboot_amebapro2_pkg}"
Comment thread docs/Targets.md Outdated
tools/scripts/amebapro2_package.sh wolfboot.elf
```

For the default `sdk` backend, `make TARGET=rtl8735b` compiles every wolfBoot object (including the RealTek SDK driver chain folded into `hal/rtl8735b.o`), but the final `wolfboot.elf` link must resolve the SDK SoC libraries (`liboutsrc.a`, `libsoc_ntz.a`) and the ROM symbol table (`romsym_is.so`), which live in the SDK build tree. `tools/scripts/rtl8735b_build.sh` runs that compile-then-SDK-resolved-link, and `tools/scripts/amebapro2_package.sh` then packages wolfBoot (in `PT_FW1`) with the RealTek partition table, boot, and certs via `elf2bin` into `flash_ntz.bin`. Both honor `AMEBA_SDK`/`ASDK_PATH`. See `hal/rtl8735b/README`.
@dgarske dgarske force-pushed the rtl8735b_amebapro2 branch from fcce147 to 0e6c1f1 Compare June 17, 2026 23:53
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