Warning
Work in progress!
Writing a web server for the nRF52840 microcontroller to learn complex embedded systems programming and for fun. Built using FreeRTOS.
git clone --recurse-submodules https://github.com/codetit4n/nrf52840-webserver# Build the firmware - Creates the firmware binary in the build/ directory
make
# Flash the firmware to the nRF52840
make flash
# Or, directly use nrfjprog
nrfjprog --program build/webserver.elf --chiperase --verify --reset
# Clean the build artifacts
make clean
# Monitor the serial output from the nRF52840 for debugging - 1M baud rate
minicom -D /dev/ttyACM0 -b 1000000- UARTE driver
- Ring-buffer logger
- Generic SPI master driver
- FreeRTOS mutex-protected bus
- Multi-device configuration
- Blocking TX/RX with timeout
- EasyDMA-safe buffer handling
- W5500 ioLibrary port
- Minimal networking module
- Static IP configuration
- Hardcoded HTTP response
- Re-enable W5500 alongside SD card
- Serve files from SD card over HTTP
- Add basic static-file support
- HTML
- CSS
- JavaScript
- MIME types
- 404 responses
- Basic path sanitization
-
SDHC/SDXC initialization in SPI mode
- CMD0
- CMD8
- CMD55 + ACMD41
- CMD58
- SDHC/SDXC detection
-
Read CSD using CMD9
- Keep CS asserted for the complete data transaction
- Wait for the
0xFEdata token - Read 16-byte CSD
- Read and discard CRC bytes
-
Decode card block count from CSD v2
-
Read a single 512-byte block using CMD17
- Build the CMD17 argument from the requested block number
- Send the block number in big-endian wire order
- Wait for the
0xFEdata token - Read 512 data bytes
- Read and discard CRC bytes
-
Verify block 0 against a PC-side sector dump
-
Verify repeated raw reads are stable
-
Verify a non-zero block against a PC-side sector dump
-
Add CRC16 validation for received data blocks
-
Create a clean read-only block-device API
- Add
sd_status_t - Return specific errors instead of
-1 - Add initialization-state tracking
- Add block-range validation
- Keep command helpers private to the SD implementation
- Define command transaction ownership rules
- Expose only
sd_init()andsd_read_block()publicly
- Add
-
Verify SD and W5500 operation on the shared SPI bus
Current limitation: only SDHC and SDXC cards are supported. SDSC and SD v1 cards are intentionally rejected.
- Integrate FatFs in read-only mode
- Implement FatFs disk I/O bridge
- Mount the SD card
- Open and read
/index.html - Print file contents over UART
- Add write support later, if needed
- Re-enable networking with SD card active
- Serve
/index.htmlfrom SD - Stream files in chunks instead of loading them fully into RAM
- Test repeated HTTP requests
- Add socket and SD timeout recovery
- Architecture diagram
- Wiring table
- Build log
- README cleanup
- Demo video
- Tag a v1.0 release