Skip to content

snagrecover: th1520: Add T-Head TH1520 support - #110

Open
tprrt wants to merge 1 commit into
bootlin:mainfrom
tprrt:dev/tprrt/th1520-recovery
Open

tprrt wants to merge 1 commit into
bootlin:mainfrom
tprrt:dev/tprrt/th1520-recovery

Conversation

@tprrt

@tprrt tprrt commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The ROM code of the TH1520 exposes a Fastboot interface in USB download mode (2345:7654). Download the image holding SPL, OpenSBI and U-Boot to the "ram" pseudo-partition and start it with "reboot". SPL initializes the DRAM, so no other boot stage is needed.

Tested on a BeagleV-Ahead with the vendor U-Boot SPL.

snagrecover -s th1520 -f th1520-beaglev-ahead.yaml --loglevel debug
2026-10-15 15:51:37,510 [DEBUG] Searching for USB device paths matching 2345:7654...
2026-10-15 15:51:37,534 [DEBUG] recovery_config:{'soc_model': 'th1520', 'soc_family': 'th1520', 'usb_path': (9, (2, 3, 2, 5, 3)), 'firmware': {'u-boot': {'path': '/home/tperrot/Downloads/ahead-yocto-1.1.2-20230610/u-boot-with-spl.bin'}}, 'args': {'soc': 'th1520', 'firmware_file': ['th1520-beaglev-ahead.yaml'], 'firmware': None, 'uart': None, 'baudrate': 115200, 'netns': 'snagbootnet', 'loglevel': 'debug', 'logfile': 'board_recovery.log', 'rom_usb': None, 'usb_path': None, 'list_socs': False, 'version': False, 'template': None, 'udev': False, 'am335x_setup': False}}
2026-10-15 15:51:37,534 [INFO] Starting recovery of th1520 board
2026-10-15 15:51:37,538 [INFO] Installing firmware u-boot
2026-10-15 15:51:37,538 [INFO] Downloading file...
2026-10-15 15:51:37,541 [DEBUG] fastboot DATA length: 963760
2026-10-15 15:51:37,790 [INFO] fastboot OKAY
2026-10-15 15:51:37,791 [DEBUG] fastboot OKAY
2026-10-15 15:51:37,791 [INFO] Done
2026-10-15 15:51:37,792 [INFO] Starting firmware...
2026-10-15 15:51:37,793 [DEBUG] fastboot OKAY
2026-10-15 15:51:37,793 [INFO] Done
2026-10-15 15:51:37,793 [INFO] Done installing firmware u-boot
2026-10-15 15:51:37,794 [INFO] Done recovering th1520 board
2026-10-15 15:51:37,794 [INFO] Logs were appended to board_recovery.log
picocom /dev/ttyUSB0
brom_ver 7
[APP][E] protocol_connect failed, exit.
Starting download of 963760 bytes

downloading of 963760 bytes finished

U-Boot SPL 2020.01 (Jun 10 2023 - 20:19:32 +0000)
FM[1] lpddr4x singlerank freq=3733 64bit dbi_off=n sdram init
ddr initialized, jump to uboot
image has no header


U-Boot 2020.01 (Jun 10 2023 - 20:19:32 +0000)

CPU:   rv64imafdcvsu
Model: T-HEAD c910 light
DRAM:  4 GiB
C910 CPU FREQ: 750MHz
AHB2_CPUSYS_HCLK FREQ: 250MHz
AHB3_CPUSYS_PCLK FREQ: 125MHz
PERISYS_AHB_HCLK FREQ: 250MHz
PERISYS_APB_PCLK FREQ: 62MHz
GMAC PLL POSTDIV FREQ: 1000MHZ
DPU0 PLL POSTDIV FREQ: 1188MHZ
DPU1 PLL POSTDIV FREQ: 1188MHZ
MMC:   sdhci@ffe7080000: 0, sd@ffe7090000: 1
Loading Environment from MMC... OK
Error reading output register
Warning: cannot get lcd-en GPIO
LCD panel cannot be found : -121
splash screen startup cost 15 ms
In:    serial
Out:   serial
Err:   serial
## Resetting to default environment
env ethaddr not exist or invalid
env eth1addr not exist or invalid
Saving Environment to MMC... Writing to MMC(0)... OK
Writing GPT: success!
dwc3_gadget_start maximum_speed:5 revision:0x5533330b
dwc3_gadget_start DWC3_DCFG:0x80804
dwc3_gadget_conndone_interrupt speed:0 dwc3_dsts:0x20000
dwc3_gadget_conndone_interrupt speed:0 dwc3_dsts:0x3ec68
Net:
Warning: ethernet@ffe7070000 (eth0) using random MAC address - 2e:03:45:04:99:06
eth0: ethernet@ffe7070000ethernet@ffe7070000:0 is connected to ethernet@ffe7070000.  Reconnecting to ethernet@ffe7060000

Warning: ethernet@ffe7060000 (eth1) using random MAC address - d6:fe:c4:4d:ff:03
, eth1: ethernet@ffe7060000
Hit any key to stop autoboot:  0
C910 Light#
C910 Light#

@tprrt
tprrt requested a review from rgantois October 15, 2026 15:01
Comment thread src/snagrecover/firmware/firmware.py Resolved

@rgantois rgantois left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Thomas, thanks a lot for the PR! I have one small change requested, and there's also the question from Peter which needs to be addressed. Apart from that, all good for me.

Comment thread src/snagrecover/firmware/firmware.py Resolved
@tprrt
tprrt force-pushed the dev/tprrt/th1520-recovery branch from f5c9518 to a5f9c63 Compare November 19, 2026 13:41
Copilot AI balanced review requested due to automatic review settings November 19, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical issue swallows USB errors when writing reboot, allowing recovery to report success without starting the firmware; write failures must propagate and be covered by a test.

1 open issue
What changed in this PR

Adds TH1520 recovery to Snagrecover through the ROM’s USB Fastboot interface, with support tested on BeagleV-Ahead.

Changes:

  • Downloads a combined SPL, OpenSBI and U-Boot image to the ram pseudo-partition, then starts it with reboot.
  • Registers TH1520 device discovery, USB permissions and recovery dispatch.
  • Adds a board template, setup documentation and recovery-flow tests.
File Description
tests/​recovery_th1520.py Tests command sequencing and reboot/flash error handling.
src/​snagrecover/​utils.py Routes TH1520 recovery to the new implementation.
src/​snagrecover/​templates/​th1520-beaglev-ahead.yaml Provides the BeagleV-Ahead firmware configuration.
src/​snagrecover/​supported_socs.yaml Lists TH1520 as tested.
src/​snagrecover/​recoveries/​th1520.py Connects to the USB device and launches firmware recovery.
src/​snagrecover/​firmware/​firmware.py Implements the Fastboot download and startup sequence.
src/​snagrecover/​config.py Adds the TH1520 ROM USB identifier.
src/​snagrecover/​50-snagboot.rules Grants user access to the TH1520 USB device.
README.md Adds TH1520 to the supported SoC families.
docs/​snagrecover.md Documents USB download mode and firmware requirements.

Review effort: Balanced

Comment thread src/snagrecover/firmware/firmware.py Resolved
@tprrt
tprrt requested a review from rgantois November 19, 2026 13:47
The ROM code of the TH1520 exposes a Fastboot interface in USB download
mode (2345:7654). Download the image holding SPL, OpenSBI and U-Boot to
the "ram" pseudo-partition and start it with "reboot". SPL initializes
the DRAM, so no other boot stage is needed.

Tested on a BeagleV-Ahead with the vendor U-Boot SPL.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
@tprrt
tprrt force-pushed the dev/tprrt/th1520-recovery branch from a5f9c63 to af42ef0 Compare November 19, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants