Skip to main content
If you are designing your own VESC-compatible board or adapting the firmware to non-standard hardware, you can add a custom hardware configuration without modifying any existing files.

How config files are structured

A typical hardware target consists of two files:
  • A header file (.h) that defines all pin assignments, ADC indexes, hardware property flags, and electrical limits.
  • A source file (.c) that implements hw_init_gpio() and any hardware-specific initialization.
For boards with multiple hardware revisions sharing the same schematic, the convention is to split the definitions into a hw_<name>_core.h / hw_<name>_core.c pair and have thin revision headers that select the revision before including the core:
This pattern keeps revision-specific overrides (voltage limits, shunt values, etc.) out of the shared core while keeping the GPIO and peripheral definitions in one place.

Required defines

The following defines are required in every hardware header. The build will fail with a descriptive error if they are missing.

Identity

Hardware property flags

Declare which gate driver and current measurement topology the board uses:

Gate control macros

ADC configuration

Define the number of ADC conversions per cycle and map each channel to its signal:

Voltage divider and current scaling

Temperature sensing

Hardware limits

Limits define the allowable range for configuration parameters. They are enforced in VESC Tool and at runtime.

Peripheral pins

Define the peripheral assignments for UART, I2C, SPI, hall/encoder, and servo decoding. See hwconf/example/hw_example_core.h for the full set of required peripheral pin defines.

Source file

The .c file must implement hw_init_gpio(). This function configures GPIO pads and initializes the gate driver at startup:
Each gate driver (HW_HAS_DRV8301, HW_HAS_DRV8320S, etc.) requires calling its own _init() function at the end of hw_init_gpio().

Using the example config as a template

The hwconf/example/ directory contains a complete reference implementation:
1

Copy the example files

Copy all three source files to a new directory inside hwconf/:
2

Update include guards and names

Replace every occurrence of HW_EXAMPLE with HW_MYBOARD and hw_example with hw_myboard in all three files.
3

Set HW_NAME

In the core header, set HW_NAME to a unique string for your board:
4

Adjust pin assignments

Update all GPIO, ADC, UART, SPI, I2C, and encoder pin definitions to match your schematic.
5

Set electrical limits

Update the HW_LIM_* defines to match your hardware’s rated voltage, current, and temperature ranges.
6

Build with fw_custom

Build the firmware without adding your board to the main Makefile:
The built binary appears at build/custom/custom.bin.

Registering the target in the build system

To have your board appear as a named target (for example fw_myboard), place the header file in a location where the Makefile can discover it. The Makefile scans all hwconf/**/*.h files (excluding *_core.h) to generate targets:
A file named hwconf/myboard/hw_myboard.h automatically produces the target myboard, letting you use:
No other Makefile changes are needed.
If your board has multiple revisions, follow the core.h / core.c pattern used by Trampa boards. The core files hold the shared implementation; each revision header just defines a flag and includes the core. The Makefile discovers only the non-core headers as build targets.
Setting HW_LIM_VIN higher than the hardware supports can cause overvoltage damage. Always set limits conservatively and test thoroughly before deploying custom firmware.