# Milk-V Meles: coreboot + OpenSBI + EDK2 Flashing Guide

> **Warning: A cooling fan or heat dissipation device is required.**
> Default frequency is 1.84 GHz.
> Risk of hardware damage; proceed with caution.

This guide installs the normal firmware into the Meles SPI NOR flash
using a temporary RAM recovery firmware. It replaces the existing SPI
boot firmware. These images are for **Milk-V Meles**, not Lichee Pi 4A.

## Required files and equipment

Obtain these files from the matching firmware package:

- `meles-ram-recovery.bin`: 1 MiB BootROM RAM recovery image.
- `meles-spi.bin`: 2 MiB normal SPI firmware image.
- `SHA256SUMS`: checksums for these two images, included in this Gist.

The firmware binaries are distributed separately from this Gist.
Use a USB data cable between the Meles USB-C port and your computer,
a stable power supply, suitable cooling, and an installed `fastboot` tool.
Serial access is optional: 115200 baud, 8N1, no flow control.

## 1. Verify the firmware files

Open a terminal in the directory containing the downloaded files:

```sh
sha256sum -c SHA256SUMS
```

Both firmware images must report `OK`.

## 2. Enter BootROM Download mode

Connect the board's USB-C port to your computer. Hold **BOOT**, press
and release **RESET**, then release **BOOT**.

Check that the board appears:

```sh
fastboot devices
```

On Linux, the BootROM USB device has VID:PID `2345:7654`.
This is the hardware Download mode; the normal firmware's F9 Fastboot
menu is a different entry point.

## 3. Load and start RAM recovery

```sh
fastboot -S 0 flash ram meles-ram-recovery.bin
fastboot reboot
```

The recovery image initializes DDR and starts EDK2 USB Fastboot.
Wait for the device to reconnect, then confirm its identity:

```sh
fastboot devices
fastboot -s meles-recovery getvar product
```

The product must be `meles-recovery` before proceeding.

## 4. Flash the normal SPI firmware

```sh
fastboot -s meles-recovery -S 0 flash spi meles-spi.bin
```

The tested 2 MiB image takes approximately **28 seconds** to write and
verify. Wait for `OKAY` and successful completion before rebooting.
Keep power and the USB cable connected throughout the operation.

```sh
fastboot -s meles-recovery reboot
```

The board now boots the normal firmware from SPI.

This procedure preserves the reserved variable region at the end of
SPI flash. It does not write the eMMC user area or eMMC boot partitions.

## Boot keys

The normal firmware has a default boot timeout of **10 seconds**:

- **F2**: firmware setup.
- **F9**: USB Fastboot.
- **F12**: boot menu.

These keys also work through a serial terminal that forwards the
corresponding function-key sequences.

## Validation

Release: `meles-20260924-183137`, tested on a Meles with 16 GiB RAM.

- BootROM RAM download, DDR training and memory bank sample checks passed.
- AON initialization and the configured CPU operating point passed.
- Recovery Fastboot reported SPI and both eMMC boot-partition capacities.
- RAM recovery flashed the normal SPI image with readback verification.
- SPI reboot reached Linux; the saved variable and MAC were retained.
- All ten 1472-byte ping tests passed.

No eMMC data was written during this validation.
