Cornell University ECE4760
Access point and web server with FatFS
as Control Panel and HTML server
Pi Pico RP2350

Access point and web server with FatFS
This version builds on the dynamic control-page server previously built. The code brings up a stand-alone WIFI access point, with DHCP server, DNS server, and a small web server using FatFS to store pages. The previous code serves two pages with real-time controls to control an application, using VGA as the test app. This version adds the ability to serve the following filetypes (mime-types) from a FatFS file system on an SD card:

The files must each be small, currently less than 20 Kbytes. That may change as I get better with TCP/IP memory managment.
Remember that outside links from this server will not work because it is not connected to any other network.

This example is intended to show how to set up simple web pages for process control, and to serve system documentation, not to produce a general web server. Web pages are written in raw HTML. The pages may be embedded in the C code as strings, or placed into the file system.

For C-embedded pages, text has the usual formatting tags and can be modifed on the fly by the server for text-based output. The example has input interactors (HTML forms) for text input, number input, graphic sliders to set numerical values, and drop down select menus. HTML form input events oninput and onchange are used to produce better interaction. Output includes simple SVG graphics and a meter construct for ranges of numerical values.

Pages in the file system are static and not modifiable at run time, but support standard HTML constructs. This makes it easy to serve small graphics and javascript. You would typically edit the content files on a PC, then write them to a SDcard, which is plugged into a rp2350 SPI channel. There is support for HTML error 404 (missing file), 413 (file too big), and 415 (unsupported media type). Supported types are text/html, JPEG, PNG, SVG, and the optional ICO icon type.

The web pages displayed correctly on Android Chrome, iPad Safari, and iPad Firefox. The application code running on the rp2040 was just a video thread running on core1 which displayed the status of the server and browser variables. LWIP is running on core0, along with a serial thread for debugging and a thread to make a software 100 Hz PWM. My Android phone and iPad connected to the pico2W with no complaints. The code runs without a serial monitor or VGA attached, but obviously then you can only interact via browser.

Demo functionality:

An image of the introduction.html html source shows the structure. Note the embedded CSS in the header.
The displayed web page is below.
The page includes two jpg images and two png images.

CODE, ZIP of project


VGA driver and LWIP considerations
Both the VGA driver written by Hunter Adams and the LWIP supplied as part of the C SDK use significant hardware to accelerate operations. The VGA driver uses three DMA channels and three state machines in one PIO. The LWIP uses 2 DMA channels and two PIO state machines. LWIP defaults to PIO1 (see cyw43_bus_pio_spi.c), so the VGA must use PIO0. The LWIP uses the claim mechanism to grab DMA channels. This means that any unused channel may be grabbed. The VGA driver was modified to use the claim system so that it does not step on the channels used by LWIP. Once this small change was made, the two libraries played nicely together. Siunce all threee PIO state machines must be on one PIO, the VGA hard-claims all three. Therefore, the VGA must be initialized before LWIP.


Copyright Cornell University September 19, 2025