Thanh Le / bench notes
EMBEDDED · BOARD HUB · IN PROGRESS

NanoPi 2 Fire (S5P4418): bare metal to face detection

An old quad Cortex-A9 board from FriendlyELEC, taken from the boot ROM up to a FreeRTOS webcam that finds faces

Last change2026-11-22: hub page and six STAR write-ups

NanoPi 2 Fire

My bench: the NanoPi 2 Fire, a 16-LED ring, the webcam and the HDMI screen

The NanoPi 2 Fire is a 75 × 40 mm board from FriendlyELEC (FriendlyARM back then), from around 2016. It has a Samsung S5P4418: four Cortex-A9 cores rated at 1.4 GHz, 1 GB of DDR3 on a 32-bit bus, Gigabit Ethernet, HDMI, a microSD slot, one micro-USB and a Raspberry-Pi-style 40-pin header. No eMMC, no Wi-Fi. The PMIC is an AXP228.

Why bother with a board this old? Two reasons. Its vendor software is only lightly maintained, so if I want something modern on it I have to build it myself. And the S5P4418 boot ROM falls back to USB when there’s no card, which means I can push code into SRAM from my PC and start from zero: no U-Boot, no Linux, just my own code and the Cortex-A9 manual.

I had just done a “USB webcam to HDMI” demo on my Allwinner D1 board, so the plan was the same here, but on bare metal and FreeRTOS. It went a lot further than that.

My own microSD card booting the board, 147 s: what sits in the first megabyte (loader in sectors 1–32, my table at 64, the app from 128), the boot ROM copying 16 KB into SRAM, RAM ready at 0.2 s, every image CRC-checked by 2.2 s, and the webcam on HDMI 3.4 s after reset. (Vietnamese on-screen text, music.)

What I got it to do

The USB boot ROM let me load my own code into SRAM, and from there I brought up the 1 GiB of DDR3 by hand. On top of that went FreeRTOS with a shell, first one kernel per core and then one kernel on all four. Then the USB webcam on HDMI, with the copy on DMA and the decode on the JPEG unit, and a microSD card that boots straight into it. On a different card I ran FriendlyELEC’s Android 7.1.2 and drove a WS2812 ring from it. The last big piece was person and face detection on the webcam stream, which went from 642 ms a run down to 27 ms.

The write-ups

Each one is written as Situation / Task / Action / Result, with the numbers I measured on the board.

#StoryResultStatus
1 USB boot ROM, a UART running 9 % slow, and 1 GiB of DDR3
From an empty SD slot to my own code in SRAM, then the DRAM controller brought up by hand
1 GiB DDR3 at 800 MHz, 0 errors over two full passes Done
2 FreeRTOS on four Cortex-A9 cores: AMP, SMP and one CPSIE too many
A FreeRTOS shell, then one kernel per core, then one kernel on all four, and the lock leak in between
SMP on 4 cores: 3.93× speed-up; AMP round trip 10 µs Done
3 USB webcam to HDMI on FreeRTOS, from 66 % CPU to 1.5 %
EHCI isochronous by hand, then the copy moved to DMA and the decode to the JPEG unit; the card boots straight into it
MJPEG to HDMI for 1.5–1.7 % CPU (was 66.5 %); reset to picture in 3.4 s Done
4 Face detection on four 2016 Cortex-A9 cores, no NPU, no Linux
FastestDet and YuNet hand-lowered to C + NEON inside the FreeRTOS webcam firmware, then made fast enough to follow a face
Person detection 642 ms → 184 ms (4 cores); faces 85 → 42 ms, same outputs bit for bit Done
5 A hang at 186 s, and a 512 KB L2 cache nobody had switched on
A watchdog black box that pointed at one bad MJPEG frame, then the PL310 L2 that hung the board until I read the vendor's sources
Hang fixed (417 s clean past the 186 s mark); L2 on: YuNet 42 → 27 ms Done
6 A WS2812 ring from Android 7 over spidev, and why it flickered
FriendlyELEC's Android on a card, a 16-LED ring on the 40-pin header, a root daemon and a 33 KB app built without Android Studio
16 LEDs, every effect smooth, readback 480/480 bytes clean; app APK 33 KB Done

Still open

Two things aren’t written up because there’s no result yet. Linux on cores 0–2 next to FreeRTOS on core 3 is built but has never booted on the board. And the Mali-400 GPU taking over part of the detector is only a plan, I haven’t started it.