README.md

# Nerves System - Khadas VIM3 (Amlogic A311D)

[![Hex version](https://img.shields.io/hexpm/v/nerves_system_vim3.svg "Hex version")](https://hex.pm/packages/nerves_system_vim3)

This is the base Nerves System configuration for the [Khadas VIM3](https://www.khadas.com/vim3) single-board computer featuring the Amlogic A311D SoC.

## Hardware Features

- **SoC**: Amlogic A311D (4x Cortex-A73 @ 2.2GHz + 2x Cortex-A53 @ 1.8GHz)
- **GPU**: ARM Mali-G52 MP4
- **NPU**: 5 TOPS Neural Processing Unit
- **RAM**: 2GB/4GB LPDDR4
- **Storage**: SD card boot support
- **Networking**: Gigabit Ethernet, WiFi, Bluetooth
- **USB**: USB 3.0, USB 2.0, USB-C

## Installation

Add `nerves_system_vim3` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:nerves_system_vim3, "~> 0.1.0", runtime: false, targets: :vim3}
  ]
end
```

## Building

To generate the built artifact to reference in other projects, run:

```bash
MIX_TARGET=vim3 mix deps.get && mix compile && mix nerves.artifact
```

## Important: First Time Setup - Clearing Vendor eMMC

**NOTE**: This may no longer be required now that U-Boot is being correctly written to the SD card, triple press of the 'F' button should force sdcard boot.

Khadas VIM3 boards ship with vendor U-Boot 2015 on the eMMC that boots with higher priority than the SD card. This prevents booting Nerves firmware from SD card.

**You must zero the eMMC boot partitions before the first SD card boot:**

1. Power on the VIM3 with the vendor firmware
2. Press any key at boot to stop autoboot and get to the `kvim3#` U-Boot prompt
3. Run the following commands to erase the eMMC boot areas:

```
mmc dev 1 1
mmc erase 0 0x400
mmc dev 1 2
mmc erase 0 0x400
mmc dev 1 0
mmc erase 0 0x10000
reset
```

After this one-time setup, the VIM3 will boot from SD card. You only need to do this once per board (unless you re-flash vendor firmware to eMMC).

## Licensing and Proprietary Components

### Source Code License

The source code for this Nerves system (configuration files, build scripts, overlays, and documentation) is licensed under the **Apache License 2.0**. See the [LICENSE](LICENSE) file for details.

### Proprietary Firmware Components

**Important**: While the source code is open-source, the build process downloads and includes proprietary firmware components that are required for the Amlogic A311D hardware to function:

- **Amlogic Boot Firmware Image Package (FIP)**: Contains proprietary bootloader components including:
  - BL2 (Second-stage bootloader)
  - BL30 (System Control Processor firmware)
  - BL31 (ARM Trusted Firmware)
  - DDR firmware fixes
  - Other SoC-specific initialization code

These proprietary components are:
- Downloaded during the build process from the [LibreELEC/amlogic-boot-fip](https://github.com/LibreELEC/amlogic-boot-fip) repository
- Subject to Amlogic's proprietary license terms
- Not redistributable as standalone components
- Included in the final built firmware images

### Distribution

- **Source code** (this repository): Apache-2.0, freely redistributable
- **Pre-built firmware images**: Contain both open-source and proprietary components
- Building this Nerves target will automatically download the required proprietary components during compilation

## License

Apache License 2.0 - See [LICENSE](LICENSE) file for details.