> ## Content Index
> Fetch the complete content index at: https://articles.akadata.co.uk/llms.txt
> Use this file to discover other available public pages before exploring further.

# Enabling 8 GB RAM on Banana Pi BPI‑R4
- URL: https://articles.akadata.co.uk/enabling-8-gb-ram-on-banana-pi-bpi-r4/
- Published: 2025-07-04T06:27:25.000Z
- Updated: 2025-07-04T06:31:16.000Z
- Author: AKADATA

*Work in Progress – testing ongoing* 
*Director: AKADATA LIMITED*

> **Source thread:** [https://forum.banana-pi.org/t/bpi-r4-frank-w-bpi-r4-u-boot-build-flash-nand/23112](https://forum.banana-pi.org/t/bpi-r4-frank-w-bpi-r4-u-boot-build-flash-nand/23112?ref=articles.akadata.co.uk)  
> Frank Wunderlich’s repositories supply the base code and build scripts referenced below.

---

## Status

- Verification currently under way on two production boards.
- Once both units pass cold‑boot and 24‑hour memory‑stress, pre‑built images, checksums, and a one‑line installer will be published here.
- Feedback from additional testers is welcomed in the forum thread above.

---

## Prerequisites

| Item             | Notes                                                                                         |
| ---------------- | --------------------------------------------------------------------------------------------- |
| Linux build host | Ubuntu 22.04 LTS or newer, 10 GB free disk, 4 GB RAM                                          |
| Toolchains       | gcc-aarch64-linux-gnu, build-essential, device-tree-compiler, vim                             |
| Two Git trees    | u-boot-r4 and mtk-atf-2025 (both from Frank Wonderlich)                                       |
| Serial console   | **Mandatory** — boards have no built‑in display; serial output is the only diagnostic channel |

---

## 1 Clone sources

```bash
# All paths are relative to $HOME/bpir4-wip
mkdir -p $HOME/bpir4-wip && cd $_
# Frank's current branches
git clone https://github.com/frank-w/u-boot -b 2025-04-bpi u-boot-r4   # U‑Boot
git clone https://github.com/frank-w/u-boot -b mtk-atf-2025 mtk-atf-2025   # ATF/BL2

```

Inline comments clarify each command.  
Lines beginning with `#` are safe to copy; bash ignores them.

---

## 2 Prepare configuration files

### 2.1 `build.conf` for both trees

```bash
cat > build.conf <<'EOF'
board=bpi-r4
device=spi-nand
extraflags=DDR4_4BG_MODE=1   # enables 8 GB training
EOF

```

*The same three‑line file lives in the root of *each* repository.*

### 2.2 Add 8 GB size to ATF’s DRAM list

```bash
vim mtk-atf-2025/plat/mediatek/mt7988/drivers/dram/dram-configs.mk

```

Inside `dram-configs.mk` locate:

```make
AVAIL_DRAM_SIZE := 1024 2048

```

…and extend it to:

```make
AVAIL_DRAM_SIZE := 1024 2048 4096   # 4096 MB × 2 ranks = 8 GB

```

> Removing `DRAM_USE_COMB=1` (if present) avoids detection stalls.

---

## 3 Build artefacts

### 3.1 U‑Boot

```bash
cd u-boot-r4
./build.sh importconfig       # loads board defaults
./build.sh build              # ~3 min on Ryzen 5
./build.sh rename             # creates u-boot-r4_2025.04-arm64-spi-nand.bin

```

### 3.2 ATF / BL2

```bash
cd ../mtk-atf-2025
./build.sh build              # outputs bl2.img and fip.bin

```

---

## 4 Flash BL2 & FIP to SPI‑NAND

> **Important:** This step changes the boot ROM hand‑off; keep a serial cable attached.

```bash
# At the U‑Boot prompt; USB stick on port 0 holds the new binaries
usb start                                # initialise storage
mtd erase spi-nand0                      # full wipe
load usb 0:5 ${loadaddr} bl2.img         # BL2 at offset 0x0
mtd write spi-nand0 ${loadaddr} 0x0 0x100000
load usb 0:5 ${loadaddr} fip.bin         # FIP at offset 0x580000
mtd write spi-nand0 ${loadaddr} 0x580000 0x200000
reset

```

Inline offsets follow Frank’s original layout; adjust when booting from eMMC.

---

## 5 Confirm 8 GB detection

During the early BL2 log the UART should display:

```
NOTICE:  EMI: DDR4 4BG mode
NOTICE:  EMI: Detected DRAM size: 8192 MB

```

Linux, once started, reports approximately 7.7 GiB:

```bash
free -h
              total        used        free      shared  buff/cache   available
Mem:          7.7Gi       76Mi       7.4Gi       16Mi      132Mi       7.4Gi
Swap:            0B         0B         0B

```

Absence of the `8192 MB` line indicates the size flag or DRAM list is still missing.

---

## 6 Rollback procedure

```bash
setenv skip_bl2 1   # ignore BL2 on next boot
saveenv
reset

```

The board falls back to the previous loader stored in on‑chip ROM.  
Use this only for recovery; remove `skip_bl2` once the fix is applied.

---

## 7 Next steps

- **Automation:** A single `install-8g.sh` is being drafted to wrap steps 2‑5.
- **Binary releases:** Pre‑built `bl2.img` and `fip.bin` will be hosted in the same forum thread with SHA‑256 sums.
- **Documentation merge:** After double‑confirmation, this article’s commands will enter the mainline BPI‑R4 wiki.

Community collaboration is appreciated. Questions and test reports belong in the forum link cited above.

---

### Changelog

| Date (UTC) | Change                                                     |
| ---------- | ---------------------------------------------------------- |
| 2025‑07‑04 | Initial public draft – testing on units *Alpha* and *Beta* |
| t.b.d.     | Add eMMC offsets, integrate automation script              |

---

*End of document — work in progress.*