Forrest OS
Forrest OS is the operating system of the Forrest Phone — a lightweight,
smartphone-style firmware for a custom handheld built on the "Cheap Yellow
Display" (CYD, board ESP32-2432S028R): an ESP32 with a built-in 320×240
ILI9341 touchscreen (XPT2046 resistive touch controller) and a microSD slot.
A FAT32-formatted SD card is the Forrest Phone's primary storage (see
section 5); without one it falls back to internal flash automatically.
Apps included: Weather (Open-Meteo), Browser (plain-text), Clock
(with alarm), Calculator, and Settings — launched from a tiled home
screen with a pin-from-browser flow for adding your own web tiles.
The device is the Forrest Phone. The software it runs is Forrest OS.
Those names appear on the boot screen, the About screen, and throughout the UI.
1. Dependencies (exact Arduino Library Manager names)
| Library |
Version |
Library Manager name |
| TFT_eSPI |
2.5.x |
TFT_eSPI |
| ArduinoJson |
6.21.5 (v6 — pin it!) |
ArduinoJson |
Plus the esp32 board package (esp32:esp32, tested with core 3.2.0 —
the code uses the core-3 LEDC API and will not compile on core 2.x).
No touch or SD libraries are needed: SD/FAT support ships with the board
package, and Forrest OS bit-bangs the XPT2046 touch controller directly —
the ESP32's two hardware SPI buses are taken by the display and the SD card.
Install everything from the command line (section 3).
Important: an unpinned arduino-cli lib install ArduinoJson installs v7;
Forrest OS is written against the v6 API, so install ArduinoJson@6.21.5.
2. TFT_eSPI configuration for the CYD
TFT_eSPI is configured at compile time. Two equivalent routes — use ONE:
Route A (recommended): no library edits — build flags
The compile command in section 3 passes every define below via
--build-property, so the TFT_eSPI library folder stays untouched.
Route B: edit User_Setup.h in the TFT_eSPI library folder
Replace the contents of ~/Documents/Arduino/libraries/TFT_eSPI/User_Setup.h
with exactly:
#define USER_SETUP_INFO "Forrest Phone (CYD)"
#define ILI9341_2_DRIVER // if colours look inverted, try ILI9341_DRIVER
#define TFT_WIDTH 240
#define TFT_HEIGHT 320
#define USE_HSPI_PORT // REQUIRED: touch owns the other SPI bus
#define TFT_MISO 12
#define TFT_MOSI 13
#define TFT_SCLK 14
#define TFT_CS 15
#define TFT_DC 2
#define TFT_RST -1
// Deliberately NOT set: TFT_BL and TOUCH_CS.
// Forrest OS drives the backlight (GPIO 21) itself via PWM for the
// brightness slider, and bit-bangs the XPT2046 touch controller on its
// own pins (CLK 25 / CS 33 / MOSI 32 / MISO 39) — the second hardware
// SPI bus belongs to the SD card slot.
#define LOAD_GLCD
#define LOAD_FONT2
#define LOAD_FONT4
#define LOAD_FONT6
#define LOAD_FONT7
#define LOAD_FONT8
#define LOAD_GFXFF
#define SMOOTH_FONT
#define SPI_FREQUENCY 55000000
#define SPI_READ_FREQUENCY 20000000
Forrest Phone pin map (for reference)
| Function |
GPIO |
| TFT MISO / MOSI / SCLK / CS / DC / RST |
12 / 13 / 14 / 15 / 2 / − |
| Backlight (PWM, brightness slider) |
21 |
| Touch CLK / CS / MOSI / MISO / IRQ (bit-banged) |
25 / 33 / 32 / 39 / 36 |
| SD card CS / SCK / MISO / MOSI (native VSPI) |
5 / 18 / 19 / 23 |
| GPS module (P1 connector = UART0) |
TX0=1, RX0=3, VIN, GND |
Speaker amp (optional alarm tone, HAS_BUZZER in src/clock_app.cpp) |
26 |
| RGB LED (active LOW, turned off at boot) |
4 / 16 / 17 |
3. Build & flash with arduino-cli (no Arduino IDE needed)
Install the toolchain
# macOS
brew install arduino-cli
# (Linux/Windows: https://arduino.github.io/arduino-cli/latest/installation/)
arduino-cli config init
arduino-cli core update-index
arduino-cli core install esp32:esp32
arduino-cli lib install TFT_eSPI
arduino-cli lib install "ArduinoJson@6.21.5"
Compile
From the directory that contains this README (the sketch folder). The
min_spiffs partition scheme is required — the firmware (Wi-Fi + TLS +
fonts) is too large for the default 1.25 MB app slot, and Forrest OS only
needs a few KB of SPIFFS:
arduino-cli compile --fqbn esp32:esp32:esp32:PartitionScheme=min_spiffs \
--build-property "compiler.cpp.extra_flags=-DUSER_SETUP_LOADED=1 -DILI9341_2_DRIVER=1 -DTFT_WIDTH=240 -DTFT_HEIGHT=320 -DUSE_HSPI_PORT=1 -DTFT_MISO=12 -DTFT_MOSI=13 -DTFT_SCLK=14 -DTFT_CS=15 -DTFT_DC=2 -DTFT_RST=-1 -DLOAD_GLCD=1 -DLOAD_FONT2=1 -DLOAD_FONT4=1 -DLOAD_FONT6=1 -DLOAD_FONT7=1 -DLOAD_FONT8=1 -DLOAD_GFXFF=1 -DSMOOTH_FONT=1 -DSPI_FREQUENCY=55000000 -DSPI_READ_FREQUENCY=20000000" \
.
(If you configured User_Setup.h via Route B instead, drop the whole
--build-property line.)
Flash
arduino-cli upload -p <PORT> --fqbn esp32:esp32:esp32:PartitionScheme=min_spiffs .
Watch the boot log (optional — logs run at the GPS baud rate, 9600,
because the GPS module shares the USB serial line):
arduino-cli monitor -p <PORT> -c baudrate=9600
If the upload stalls at Connecting..., hold the BOOT button while the
upload starts, and/or add --board-options UploadSpeed=115200 — some CYD
units dislike the default upload speed.
With a GPS module on P1: unplug its lead before uploading. The module's
TX line drives the same RX pin the USB-serial chip uses, and the two fight
during flashing. Replug after the upload finishes.
4. Finding the serial port
The CYD uses a CH340 USB-serial chip.
- macOS — plug the Forrest Phone in, then:
ls /dev/cu.* and look for
/dev/cu.usbserial-XXXX or /dev/cu.wchusbserial-XXXX (recent macOS has
the CH340 driver built in).
- Windows — Device Manager → Ports (COM & LPT) →
USB-SERIAL CH340 (COMn);
use COMn. If the device is missing, install the WCH CH340 driver
(wch-ic.com → CH341SER.EXE).
- Linux —
ls /dev/ttyUSB* (usually /dev/ttyUSB0). Give yourself port
permission once: sudo usermod -a -G dialout $USER, then log out and in.
arduino-cli board list also shows every detected serial device.
5. SD card (primary storage)
Forrest OS keeps everything — settings, home tiles, browser cache and tile
icons — on a microSD card under /forrestos/,
and falls back to internal flash silently when no card is inserted
(Settings → Storage and the serial log show which one is active). Settings,
tiles, alarm and bookmarks already on internal flash are migrated to a
freshly inserted card automatically, so nothing is lost by upgrading.
Preparing the card (must be FAT32 — not exFAT)
The ESP32 SD library cannot read exFAT, and 64 GB+ cards ship exFAT from
the factory, so reformat once:
- macOS — Disk Utility → select the card (the device, not the volume)
→ Erase → Format: MS-DOS (FAT), Scheme: Master Boot Record.
- Windows — the built-in Format dialog refuses FAT32 above 32 GB. Use
Ridgecrop's guiformat.exe (search "FAT32 Format Ridgecrop"): pick the
drive, leave 32 KB allocation units, tick Quick Format.
- Linux —
sudo mkfs.vfat -F 32 /dev/sdX1 (triple-check the device).
Insert the card and reboot; Forrest OS builds this tree on first mount:
/forrestos/
config.json apps.json alarm.json bookmarks.json
cache/ browser page cache (hashed filenames, 1-hour freshness)
icons/ 32x32 BMP tile icons (drop yours here)
notes/ reserved for future use
checkins/ reserved for future use
Sports API token
The Sports app reads Premier League and Champions League data from
football-data.org, which needs a free API
token. None ships with the source, so the app will sit empty until you supply
one: register for a free-tier account, then save the token as a single line
(no quotes, no trailing spaces) in
/forrestos/football_token.txt
Reboot and Sports will pick it up. Every other networked app — Weather, Air
Quality, Currency, Transit, Sunrise — uses a keyless API and needs no setup.
Custom tile icons
Pinned web tiles can show a real icon instead of their letter glyph: save a
32×32, 24-bit uncompressed BMP named exactly like the tile (a tile
called "News" looks for News.bmp) into /forrestos/icons/ from your
computer. The home screen picks it up on its next redraw.
Storage settings
Settings → Storage shows what the Forrest Phone is running on
("SD - 58.3 GB free" or "Internal flash (no SD)") and offers
Clear browser cache.
6. GPS module
The Forrest Phone takes any standard serial NMEA GPS receiver (u-blox NEO
clones, ATGM336H, GT-U7, combined GPS/charger boards, ...) on the P1
connector — the 4-pin socket beside the USB ports:
| P1 pin |
GPS module pin |
| VIN (5 V) |
VCC |
| TX |
RX |
| RX |
TX |
| GND |
GND |
The baud rate is detected automatically (9600 / 38400 / 115200 / 4800).
What uses the GPS once it has a fix:
- Weather fetches the forecast for where the Phone actually is.
- The clock sets itself from GPS time when there's no Wi-Fi — alarms
work fully off-grid.
- Settings → GPS is a live panel: status, position, satellites, link.
Practical notes:
- The antenna needs a view of the sky — a cold first fix can take several
minutes; indoors it may never arrive (the panel will show satellites
rising and falling as it tries).
- P1 shares the UART with USB: unplug the GPS lead when flashing, and
serial logs now run at 9600 baud.
- Battery/switch boards (a charger board feeding the Phone with a slide
switch in the power path) are invisible to software by design — the
switch just cuts power. Charging happens through that board's own USB
port. Battery percentage would need one extra sense wire to an ADC pin
(GPIO 35 on P3) — ask for the battery feature if you wire it.
- Boot loops on battery power are almost always the battery sagging
under the Wi-Fi radio's start-up load (brownout). Forrest OS boots at
reduced backlight, caps radio power, and reports "power dipped" after a
brownout restart — but a tired or under-specced battery/wiring is a
hardware fix: charge it, or thicken the power leads.
7. First boot
- The boot screen shows Forrest Phone / Forrest OS with a loading
bar (the very first boot takes a couple of seconds longer while the
storage partition is formatted). With no SD card the Forrest Phone runs
from internal flash, no questions asked.
- The home screen opens with tiles for Weather, Browser, Clock, Calculator
and Settings.
- Open Settings → Wi-Fi, pick your network from the scan, type the
password on the on-screen keyboard (the
^ key is shift, ?123 switches
to symbols). The clock in the status bar syncs automatically once
connected.
- Set Settings → Timezone (UTC offset) and Location (latitude /
longitude — used by Weather; defaults to London).
- Weather fetches on open and every 10 minutes; if the network drops it
keeps the last data with an Offline badge.
- In the Browser, Pin as App adds the current page to a free home
tile (long-press Pin as App for bookmarks). Long-press a home tile to
remove tiles; removed built-in apps can be added back any time from
Settings → Apps.
8. Troubleshooting
- White/blank screen → TFT_eSPI flags missing
USE_HSPI_PORT, or you
defined TOUCH_CS/TFT_BL (don't — see section 2).
- Colours inverted / washed out → your panel is the other ILI9341
variant: swap
ILI9341_2_DRIVER for ILI9341_DRIVER (or add
TFT_INVERSION_ON/OFF).
- Touch lands offset → tweak the raw calibration window at the top of
src/ui_utils.cpp (TOUCH_RAW_*).
- Sketch too big → you compiled without
PartitionScheme=min_spiffs.
ledcSetup compile errors → your esp32 core is 2.x; Forrest OS needs
core 3.x (arduino-cli core install esp32:esp32 to update).
- SD card not detected → it must be FAT32 (exFAT won't mount — see
section 5). Reseat the card and reboot; Forrest OS already retries at a
slower bus clock before giving up.
- Tile icon doesn't appear → the file must be a 32×32, 24-bit
uncompressed BMP in
/forrestos/icons/, named exactly like the tile —
and only pinned web tiles use BMP icons.
- GPS shows "Not detected" at first → if the P1 lead is wired
straight-through (TX→TX) instead of crossed, Forrest OS notices within
~20 s, re-routes its UART to listen on the other pin and remembers the
result (Settings → GPS then shows "swapped lead"). Trade-off: serial
logging is dark while swapped. For clean wiring and logs, swap the two
middle wires at one end of the JST lead.
- GPS stuck on "Searching" → wiring is fine; the antenna just can't see
satellites. Move it near a window or outside and give a cold start a few
minutes.
- Upload fails while the GPS is plugged in → expected; unplug the P1
lead, flash, replug (section 3).
Forrest OS v1.0 — firmware of the Forrest Phone.