---

To switch from OpenWrt to OPNsense, first boot into U-Boot by stopping autoboot (hit any key).

Configure a persistent OPNsense boot environment. This is required only once:

```
Hit any key to stop autoboot:  0
=> setenv opnsense "load mmc 0:1 ${kernel_addr_r} kernel.img; load mmc 0:1 ${fdt_addr_r} dtb/mono-gateway-dk.dtb; booti 0x82000000 - 0x88000000"
=> setenv bootcmd_bak ${bootcmd}
=> setenv bootcmd "run opnsense || run recovery"
=> saveenv
```

Erase the eMMC. This is required each time you flash a new image:

```
=> mmc erase 0 3b48000
```

Then boot into recovery:

```
=> run recovery
```

Once in recovery, enter `root` as the username (no password).

Download the OPNsense image and verify it as explained in the [official OPNsense docs](https://docs.opnsense.org/manual/install.html#download-and-verification).  
Then transfer it to Gateway using a USB flash drive (plug it into the center port):

```
# mount /dev/sda1 /media
# bzip2 -dck /media/OPNsense-26.1.*-arm-aarch64-GATEWAY.img.bz2 | dd of=/dev/mmcblk0 bs=1M
```

Once it's done flashing:

```
# reboot
```
