How wiznet-ionic/w55rp20-s2e works
Project type and overall purpose
• This is embedded firmware for the W55RP20 System-in-Package (RP2040 + W5500 + Flash).
• It implements a Serial-to-Ethernet gateway (S2E), hosts an HTTP server, speaks Modbus, and optionally connects to AWS IoT over TLS.
• There is a two-stage firmware flow: a small Bootloader (“main/Boot” + port/boot/... ) and the full Application (“main/App” + port/app/...).
File structure
• Top level:
– CMake scripts (pico_sdk_import, FreeRTOS_Kernel_import, project CMakeLists).
– libraries/ (third-party code: FreeRTOS, AWS IoT SDK, mbedtls, ioLibrary_Driver, pico‐sdk).
– main/Boot and main/App (bootloader and application entry points).
• port/boot/… and port/app/… hold the Hardware Abstraction Layer (HAL) / Board Support Package:
– board drivers, configuration parser, serial_to_ethernet, HTTP server modules, Modbus, timers, platform handlers, etc.
• main/App/App.c is where FreeRTOS is brought up, tasks are created, peripherals initialized.
Extract behavioral cues from the README
• The firmware runs under FreeRTOS on RP2040.
• W5500 Ethernet is accessed via SPI through the ioLibrary_Driver.
• Serial data (UART) is bridged to Ethernet (TCP/UDP) or Modbus-TCP.
• An HTTP server serves static pages from flash and provides a management interface.
• Optionally, AWS IoT Device SDK + mbedtls provides an MQTT over TLS client.
Sketch the high-level components (layered view)
a. Hardware block
– W55RP20 SiP: RP2040 MCU core + internal 2 MB flash + W5500 Ethernet controller.
– External interfaces: UART pins for data and debug, GPIO pins for status, SPI bus to W5500.
b. HAL / Port layer
– SPI driver (wiznet_spi.c, w5x00_gpio_irq.c)
– UART driver (uartHandler.c)
– Timer driver (timer.c)
– Flash configuration parser (ConfigData.c, segcp.c)
– GPIO, network, storage, DHCP/DNS callbacks (platform_handler/*.c)
c. Middleware / libraries
– ioLibrary_Driver (network socket API over W5500 SPI)
– HTTP server modules (httpParser.c, httpServer.c, httpUtil.c)
– Modbus library (mb*.c)
– AWS-IoT Device SDK (core_http, core_mqtt)
– mbedtls (SSLInterface.c, SSL_Random.c)
d. RTOS kernel
– FreeRTOS core (task scheduler, queues, semaphores)
e. Application modules (FreeRTOS tasks)
– Serial-to-Ethernet task
– HTTP-server task
– Modbus-TCP task
– MQTT/AWS-IoT task
– Configuration management task
– Maintenance/Bootloader fallback (in Bootloader stage)
f. External systems
– Ethernet LAN and remote clients (web browsers, Modbus-TCP masters)
– AWS IoT Core (MQTT broker)
– Serial host (RS-232/422/485 devices)
Relationships & data-flow
• Bootloader initializes clocks, board, Flash, then optionally jumps to Application.
• Application starts FreeRTOS, spins up tasks.
• Each task uses port layer (HAL) to access hardware.
• Network-related tasks call ioLibrary_Driver → SPI → W5500.
• TLS/MQTT tasks call mbedtls + AWS IoT SDK → ioLibrary_Driver.
• HTTP server reads Web_page.bin from flash (html_file) via storageHandler.
• Serial data enters via UART driver → serial_to_ethernet module → socket API (ioLibrary_Driver) → network.
• Configuration is stored/read in flash via ConfigData and segcp modules.
Architectural patterns & principles
• Layered architecture: Hardware → HAL → Drivers → Middleware → Application → External
• Clear separation: Boot vs. App
• Concurrency via RTOS tasks with well-defined interfaces (queues/callbacks)
• Hardware abstraction for portability (port_common.h, platform_handler)
• Reuse of open-source libraries (FreeRTOS, pico-sdk, AWS SDK, mbedtls)
Diagramming recommendations
– HAL / drivers (blue)
– Middleware libraries (green)
– RTOS kernel (purple)
– Application tasks/modules (orange)
– External systems (light purple)
– Task → HAL calls (downward)
– HAL → hardware (downward)
– Middleware → HAL (downward)
– Hardware interrupts → RTOS callbacks (upward)
– Network flows → external cloud/clients
• That Flash memory holds both firmware (Boot/App) and static web pages (Web_page.bin).