FEL boot: mainline U-Boot from USB, RAM only
Status (2026-11-09): working. Mainline U-Boot 2027.01-rc1 boots on the S1 Plus from FEL to a
=> prompt with full eMMC access. It is loaded over USB and runs from RAM, so nothing is written
to the panel. U-Boot then starts USB fastboot on the USB-C port by itself, so a host can
flash partitions with only the PCB button and a cable, no UART needed.
U-Boot 2027.01-rc1 ... Allwinner Technology
CPU: Allwinner A133 (SUN50I)
Model: Aqara Panel Hub S1 Plus
DRAM: 2 GiB
Core: 42 devices, 17 uclasses, devicetree: separate
MMC: mmc@4022000: 1 (8-bit, 52 MHz, 7.3 GiB, GPT with the Android partitions)
=>
Usage
- Build:
UBOOT_SRC=~/src/u-boot BL31=<bl31.bin> frames/aqara-s1-plus/tools/fel/build-uboot.sh. This appliesframes/aqara-s1-plus/tools/fel/uboot/patches/*.patchonce. - Enter FEL: hold the PCB button (photo) while plugging in USB-C, keep holding for about 10 s. The screen stays black.
- Boot:
NO_BL31=1 SUNXI_FEL=sunxi-fel frames/aqara-s1-plus/tools/fel/fel-boot.sh ~/src/u-boot/build-s1. Watch the console on the debug UART at 115200 8N1. After 2 s, U-Boot runsfastboot usb 0. Press a key on the UART during the countdown to get a prompt instead. - On the host:
fastboot devices, thenfastboot getvar partition-size:boot. Partitions are addressed by their GPT names (boot,vbmeta,super, ...). The download buffer is 512 MiB. - Reading partitions:
frames/aqara-s1-plus/tools/install/fb-read-partition.sh <partition> <file>copies a partition to the host, up to the 512 MiB buffer. It runsoem run(part start/size,mmc readinto the buffer,setexpr fastboot_upload_size) and thenfastboot get_staged, using theuploadcommand from patch 0002. It reads about 20 MB/s. - Unplug and replug without the button to get back to Android.
What had to be fixed
1. DRAM controller setup, the real bug: patches/0001-….
- Symptom. Mainline's A133 DDR4 driver brings up 2 GiB that passes every write-then-read test.
Real code still crashes at random:
- TF-A hits "undefined instruction" faults on valid instructions;
- U-Boot hangs in
memcpy; - crash dumps come out garbled.
- Where it showed up. A copy loop (load one address, store another) corrupted about 300 64-bit words per MiB. So the failure is on read→write bus turnarounds.
- How it was found. The controller registers were diffed two ways:
- as programmed by our SPL, read over FEL;
- as programmed by stock boot0, read from Android via
/sys/class/sunxi_dump/dump.
- The differences:
| Register | mainline | stock boot0 | |
|---|---|---|---|
MR0 (INIT3 + MRS) |
0x840 |
0x520 |
CAS latency / WR. The controller timings (DRAMTMG2 etc.) match stock, so the RAM ran a different CL than the controller assumed. |
MSTR bit 0 |
geardown on | off | The RAM's MR3 has geardown off |
INIT7 (MR6) |
0x826 |
0x862 |
Typo; the MRS write already used 0x862 |
DRAMTMG6 |
0x00000005 |
0x02020005 |
0x20 << 16 was truncated to 0 |
ADDRMAP1 BA2, ADDRMAP8 BG1 |
0x1f |
0x3f |
"Disabled" in the 6-bit fields |
SCHED[3:0] |
0x1 |
0x5 |
With all of these matched to stock, everything boots.
- Which one is the fix: MR0. A bisect on the panel (2026-11-10) built each variant fresh from
FEL, then copied 16 MiB of random data with
cp.qto four places three times and through a three-hop chain, and checked each copy withcmp.q:
| Build | Result |
|---|---|
| mainline, unpatched | hangs before reaching fastboot |
| the other five changes, without MR0 | hangs the same way |
| MR0 only | boots; 12/12 copies and the chain match |
| all six | boots; 12/12 copies and the chain match |
So MR0 alone is necessary and sufficient. The other five only match what boot0 programs, and made no difference to stability. Our patch 0001 still carries all six, because that is the build the installer ships and has been tested with. The sunxi-fel-only SRAM burst test does not catch this bug at all, not even on unpatched code: it needs U-Boot running from DRAM.
2. CPU clock. The board's PMIC (AXP806 on R_I2C) has no SPL driver, so SUNXI_NO_PMIC
applies. Mainline would then clock the CPU to 1008 MHz at the power-on core voltage. The defconfig
pins SYS_CLK_FREQ=408000000 instead.
3. USB uploads. At 408 MHz the boot ROM's CPU-driven USB is too slow for the large bulk
transfers sunxi-fel uboot uses, and they hit its 10 s timeout. fel-boot.sh uploads in 64 KiB
chunks and starts the CPU itself with reset64.
4. No TF-A for now. U-Boot runs directly at EL3. That is enough for fastboot and eMMC work; PSCI is only needed to boot Linux SMP. The BL31 crashes were the DRAM bug above, so TF-A should work again with patch 0001. That is untested.
Verified (all from FEL, RAM only)
- DRAM:
- Full 2 GiB, no aliasing; holds data for 60 s.
- 32/64/128-bit accesses and 8-word bursts.
- 860 M instructions executed from DRAM.
- The copy-pattern test fails without patch 0001, and passes with only its MR0 change.
- U-Boot reaches the prompt;
mmc infoandmmc partwork (read-only).
Next
- Upstream: the MR0 fix goes to the U-Boot list as a single patch. It probably affects every A133
DDR4 board. Once it is in U-Boot
main, rebase onto it and drop the MR0 change from patch 0001. - Retest TF-A BL31 with the DRAM fix.
ENV_IS_NOWHEREis set, sosaveenvcan never write to the panel's Androidenvpartition.- Build the installer flow on top of fastboot (persistent root / boot image), behind explicit backups.