---
title: "tvserver"
url: "https://maker.wiznet.io/TheoIm/projects/tvserver/"
markdown_url: "https://maker.wiznet.io/TheoIm/projects/tvserver/md"
type: "UCC: User Created Content"
author: "lindsaymeek"
author_url: "https://github.com/lindsaymeek/TVServer"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "lindsaymeek"
original_url: "https://github.com/lindsaymeek/TVServer"
published: "2026-03-13"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 430
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# 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

Original author: lindsaymeek (source: https://github.com/lindsaymeek/TVServer)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

## 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:

```plaintext
USB Mass Storage protocol
↔
AoE / ATAOE raw Ethernet sector protocol
```

The 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.

![](https://maker.wiznet.io/upload/ckeditor5/369175111%5F1773399054%2Epng)

**Generated By Gemini**

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:

```plaintext
SCSI READ10
```

Handled by the USB Mass Storage stack.

---

#### Step 2 — Virtual storage driver

The USB stack calls the custom LUN driver.

Source:

```plaintext
app_device_msd.c
```

Key functions:

```plaintext
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:

```plaintext
FILEIO_NET_SectorRead()
```

calls:

```plaintext
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:

```plaintext
app_device_msd.c
```

Socket configuration:

```plaintext
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:

```plaintext
FF:FF:FF:FF:FF:FF
```

Source:

```plaintext
app_device_msd.c
```

Fields used:

```plaintext
major = 0xFFFF
minor = 0xFF
cmd = AOE_CMD_CONFIG
```

If a server responds, the firmware stores:

```plaintext
server_mac
server_major
server_minor
```

This establishes the AoE target.

---

## 6️⃣ Sector Read Mechanism

The system reads **two sectors at a time**.

Request:

```plaintext
ATA READ (0x20)
sectors = 2
```

Flow:

```plaintext
TV sector read
→ AoE request sent
→ Linux server generates FAT32 sector
→ response returned via Ethernet
```

---

## 7️⃣ 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:

```plaintext
socket 0 RX buffer = 16KB
socket 0 TX buffer = 2KB
```

When two sectors arrive:

```plaintext
Sector 1 → copied to USB buffer
Sector 2 → cached in W5500 RX memory
```

Next sequential request:

```plaintext
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:

```plaintext
read sector N
→ return sector N
→ cache sector N+1
→ request sectors N+2 and N+3
```

This keeps the network server continuously streaming data.

---

## 9️⃣ Linux Server Role

The server receives raw AoE frames using a **PF_PACKET socket**.

Source:

```plaintext
confuse.c
```

Example:

```plaintext
socket(PF_PACKET, SOCK_RAW, htons(AOE_TYPE));
```

Server tasks:

```plaintext
Receive AoE request
→ Parse LBA
→ Generate FAT32 sector
→ Send AoE response
```

The actual data source is not a disk.

Instead it comes from:

```plaintext
DLNA / UPnP media server
```

The 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:

```plaintext
16KB RX FIFO
```

This 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

---

Source: https://maker.wiznet.io/TheoIm/projects/tvserver/
