# Autostart module for EVBox G2/G3 chargers

Written 2026 by Maarten Tromp <maarten@geekabit.nl>

Website: <https://www.geekabit.nl/projects/evbox-charger-autostart-module/>


## Overview

EVBox G2 and G3 chargers (produced 2013 - 2021) use a modem to talk to the
EVBox backend, which decides when the charger is allowed to charge. Since the
backend went offline, these chargers no longer work.

The autostart module is a drop-in replacement for the modem. It talks to the
charger over the internal RS-485 bus and pretends to be the backend, so the
charger can work stand-alone again. Only the bare minimum is implemented:
features such as metering, remote control and card authentication are not
supported.

## Hardware

- ATtiny402 (4 kB flash, 256 B RAM), running at 8 MHz
- ADM3485 RS-485 transceiver, 38400 baud, 8N1, half-duplex
- Powered from the charger's 12 V rail

| Pin | Function |
|-----|----------|
| PA0 | RS-485 driver enable (XDIR), also UPDI |
| PA6 | UART TXD/RXD, single wire, the USART switches direction |
| PA2 | Current limit LSB, input with pull-up |
| PA3 | Current limit MSB, input with pull-up |


## Current limit

PA2 and PA3 select the current limit. Pull a pin to GND to change it. The pins
are read every time the charger asks for the current limit, so a change takes
effect without a reboot.

| PA3  | PA2  | Limit |
|------|------|-------|
| high | high | Full current |
| low  | high | 25 A |
| high | low  | 20 A |
| low  | low  | 16 A |


## Directory layout

| Path | Contents |
|------|----------|
| `src/core/` | Protocol handling, hardware independent (also used by the tests) |
| `src/hw/` | ATtiny402 specific code: clock, UART, timer, pins, interrupts |
| `tests/` | Unit tests, run on the build machine |
| `unity` | Symlink to `Unity-2.7.0/`, the unit test framework |


## Building

Requirements (Debian/Ubuntu package names):

- `make`
- `gcc-avr`, `binutils-avr` and `avr-libc`, with ATtiny402 support
  (tested with avr-gcc 14.2)
- `avrdude`, with serialupdi support (for programming)
- `gcc` (for the unit tests)
- `zip` (for the source archive)

Unity 2.7.0 is included in the source archive. When building from git, get it
from <https://github.com/ThrowTheSwitch/Unity/releases>, unpack it and point the `unity` symlink to it.

Make targets, run from the project root:

| Command | Action |
|---------|--------|
| `make` | Build the firmware: `build/avr-gcc/firmware.elf` |
| `make test` | Build and run the unit tests |
| `make prog` | Program flash and fuses |
| `make zip` | Create the source archive: `build/src.zip` |
| `make clean` | Remove build output |

`make prog` uses a USB-to-serial adapter as UPDI programmer on `/dev/ttyUSB0`.
Use a different port with `make prog PROGRAMMER=/dev/ttyUSB1`.


## Programming and fuses

`make prog` writes the fuses together with the flash:

| Fuse | Value | Setting |
|------|-------|---------|
| WDTCFG | `0x08` | Watchdog enabled, ~1 s timeout |
| BODCFG | `0x45` | Brown-out detection enabled, 2.6 V |
| OSCCFG | `0x01` | 16 MHz internal oscillator (divided by 2 in firmware) |
| SYSCFG0 | `0xf2` | PA0 as GPIO (UPDI disabled), no CRC check |
| SYSCFG1 | `0x07` | 64 ms start-up time |
| LOCK | `0xc5` | No locks |

> **Warning:** SYSCFG0 turns PA0 into a GPIO pin, as it is needed to drive the
> transceiver. After the first `make prog`, regular UPDI programming no longer
> works and a high-voltage (12 V) UPDI programmer is needed to reprogram the
> chip. Hardware v1.1 and later have a series resistor and a diode on PA0 to
> make that possible.


## Test firmware

Uncomment `CFLAGS += -DTEST_FIRMWARE` in `src/hw/Makefile` to build a test
version. It adds command `0xFF`, which reports the free stack space (stack
high-water mark) in place of the serial number in a broadcast `0x11` frame.


## License

CC0 1.0 Universal (Public Domain Dedication)

The author has dedicated this work to the public domain by waiving all rights
to the work worldwide under copyright law, including all related and
neighbouring rights, to the extent allowed by law.

You may copy, modify, distribute, and use this work, even for commercial
purposes, without permission.

<https://creativecommons.org/publicdomain/zero/1.0/>
