tvserver
This project uses the WIZnet W5500 in MACRAW mode to build a USB-to-Ethernet storage bridge. A microcontroller appears as a USB flash drive to legacy TV
How Does a WIZnet W5500 Enable a USB-to-Ethernet AoE Storage Bridge?
(Turning a DLNA Media Server into a USB Drive for Legacy TVs)
Summary (40–60 words)
This project implements a USB-to-Ethernet storage bridge using the WIZnet W5500 Ethernet controller in MACRAW mode. A microcontroller presents itself as a USB Mass Storage device to a TV while translating sector read requests into AoE (ATA over Ethernet) frames. A Linux server converts DLNA media content into FAT32 sectors and returns them over Ethernet.
1️⃣ Project Concept
This system allows legacy devices that only support USB storage to access network media servers.
Instead of using TCP/IP networking, the system operates at Layer-2 Ethernet using AoE (ATA over Ethernet).
The embedded firmware acts as a protocol translator between:
USB Mass Storage protocol
↔
AoE / ATAOE raw Ethernet sector protocolThe result:
A DLNA media server appears as a USB flash drive to devices like old TVs or DVD players.
2️⃣ Overall System Architecture
The project consists of four main components.
Key idea:
The TV believes it is reading a USB flash drive, but the data actually comes from a network media server.
3️⃣ Firmware Data Flow
The firmware converts block storage operations into network requests.
Step 1 — USB storage request
The TV issues a storage command:
SCSI READ10Handled by the USB Mass Storage stack.
Step 2 — Virtual storage driver
The USB stack calls the custom LUN driver.
Source:
app_device_msd.cKey functions:
FILEIO_NET_SectorRead()
FILEIO_NET_SectorWrite()
FILEIO_NET_CapacityRead()
FILEIO_NET_MediaDetect()The firmware presents a network-backed block device.
Step 3 — Network sector request
When the TV reads a sector:
FILEIO_NET_SectorRead()calls:
read_net(lba, buffer)This converts the request into an AoE packet.
4️⃣ W5500 Ethernet Usage (MACRAW Mode)
Unlike typical embedded networking, the W5500 is not used for TCP/IP.
Instead it operates in MACRAW mode, allowing raw Ethernet frame access.
Source:
app_device_msd.cSocket configuration:
socket(AOE_SOCKET, Sn_MR_MACRAW, 0,
SF_ETHER_OWN | SF_IPv6_BLOCK | SF_MULTI_BLOCK);Meaning:
The W5500 behaves as a Layer-2 Ethernet engine that:
receives raw Ethernet frames
sends custom EtherType frames
bypasses IP/TCP/UDP stacks entirely
5️⃣ AoE Server Discovery
The firmware searches for a server by broadcasting an AoE CONFIG packet.
Destination:
FF:FF:FF:FF:FF:FFSource:
app_device_msd.cFields used:
major = 0xFFFF
minor = 0xFF
cmd = AOE_CMD_CONFIGIf a server responds, the firmware stores:
server_mac
server_major
server_minorThis establishes the AoE target.
6️⃣ Sector Read Mechanism
The system reads two sectors at a time.
Request:
ATA READ (0x20)
sectors = 2Flow:
TV sector read
→ AoE request sent
→ Linux server generates FAT32 sector
→ response returned via Ethernet7️⃣ W5500 Memory Optimization
One of the most interesting parts of the design is how the W5500 memory is used.
The controller provides internal RX buffers, which the firmware uses as a cache.
Configuration:
socket 0 RX buffer = 16KB
socket 0 TX buffer = 2KBWhen two sectors arrive:
Sector 1 → copied to USB buffer
Sector 2 → cached in W5500 RX memoryNext sequential request:
WIZCHIP_READ_BUF()The firmware reads the sector directly from the W5500 buffer without additional memory copying.
8️⃣ Read-Ahead Optimization
After returning the first sector, the firmware immediately requests the next two sectors.
This speculative read improves throughput.
Pseudo flow:
read sector N
→ return sector N
→ cache sector N+1
→ request sectors N+2 and N+3This keeps the network server continuously streaming data.
9️⃣ Linux Server Role
The server receives raw AoE frames using a PF_PACKET socket.
Source:
confuse.cExample:
socket(PF_PACKET, SOCK_RAW, htons(AOE_TYPE));Server tasks:
Receive AoE request
→ Parse LBA
→ Generate FAT32 sector
→ Send AoE responseThe actual data source is not a disk.
Instead it comes from:
DLNA / UPnP media serverThe server maps DLNA content into virtual FAT32 sectors.
🔟 Example User Scenario
Real operation looks like this:
1️⃣ User connects the device to a TV USB port
2️⃣ TV detects a USB flash drive
3️⃣ TV requests directory sectors
4️⃣ Linux server builds FAT32 directory entries from DLNA media
5️⃣ User selects a video
6️⃣ TV reads file sectors sequentially
7️⃣ Server streams DLNA data as FAT32 sectors
To the TV, everything looks like a normal USB disk.
1️⃣1️⃣ Why WIZnet W5500 Matters Here
The W5500 provides capabilities that make this design practical.
Raw Ethernet Engine
MACRAW mode enables direct Layer-2 frame access.
Hardware Ethernet Buffer
The controller offers:
16KB RX FIFOThis allows sector caching without external RAM.
SPI-Based Integration
The MCU interacts with Ethernet using a simple SPI interface.
Deterministic Frame Handling
The W5500 manages Ethernet packet buffering independently from the MCU.
1️⃣2️⃣ Key Source Files
Important components in the project:
| File | Role |
|---|---|
| main.c | firmware entry and initialization |
| app_device_msd.c | USB ↔ AoE bridge logic |
| ataoe.h | AoE protocol definitions |
| wizchip_conf.c | W5500 initialization |
| w5500.c | Ethernet buffer read/write |
| confuse.c | Linux AoE server |
1️⃣3️⃣ Use Cases
This architecture is particularly useful for:
Legacy media adapters
Provide network streaming to devices that only support USB storage.
Embedded storage bridges
Translate block storage protocols over Ethernet.
Lightweight NAS front-ends
Expose network storage as block devices.
Industrial device gateways
Allow USB-only equipment to access network storage.
FAQ
Why use W5500 MACRAW instead of TCP/IP?
MACRAW mode allows direct Ethernet frame access without implementing an IP stack, simplifying firmware and reducing CPU overhead.
What protocol is used between the device and the server?
The system uses ATA over Ethernet (AoE) with EtherType 0x88A2.
Does the device support writing data?
The design is primarily read-optimized and typically used for streaming or media playback.
What role does the Linux server play?
The server emulates FAT32 disk sectors and maps them to DLNA media content.
Why cache sectors in W5500 memory?
Caching reduces memory usage on the MCU and improves sequential read performance.
Tags
#W5500
#WIZnet
#MACRAW
#AoE
#ATA over Ethernet
#USB Mass Storage
#Embedded Networking
#DLNA

