If you want to build the RP2040 targets and get a 'Filename too long' error on Windows, please refer to [the Platformio documentation for this toolchain](https://arduino-pico.readthedocs.io/en/latest/platformio.html#important-steps-for-windows-users-before-installing)
1. Open the newly cloned folder in [Visual Studio Code](https://code.visualstudio.com). If you do this for the first time, this can take quite some while as PlatformIO will download all the necessary tooling and libraries. Also if platformio is not installed, VSCode will ask you to install it, probably requiring a restart of the program.
2. To select the device you you wish to build, open your [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette):
4. To build the firmware, simply run `PlatformIO: Build` from your command palette.
5. Finally, flash the firmware to your device by running `PlatformIO: Upload`
## Adding Custom Hardware
The build system is modular. Adding a new board variant for an already supported architecture is straightforward.
### Build with Custom Hardware
1. Go to the `variants` folder in the firmware source code and make a new directory for your hardware, let's call it `m5stack_atom` and copy an existing configuration you wanna modify:
```shell
cd variants; mkdir m5stack_atom
cp heltec_v1/* m5stack_atom
cd m5stack_atom
```
2. Modify the `platformio.ini`_in this subdirectory_ from the canonical define of the hardware variant (`HELTEC_V1` in this case) to `PRIVATE_HW` and make the `-I` on the `build_flags` point to the newly created dir.
3. Edit the `variant.h` file _in this subdirectory_ to reflect the defines and configurations for your board. The example is very well commented.
4. Build, run and debug until you are satisfied with the result.
### Distribute / Publish Custom Builds
1. Perform all of the steps [building with custom hardware](#build-with-custom-hardware) until your hardware runs fine.
2. [Send a proposal](https://github.com/meshtastic/firmware/issues/new?assignees=&labels=enhancement%2Ctriage&template=New+Board.yml&title=%5BBoard%5D%3A+) to add a new board.
3. If approved, go to [https://github.com/meshtastic/protobufs](https://github.com/meshtastic/protobufs) and send a Pull Request for the `mesh.proto` file, adding your board to the `HardwareModel` Enum.
Gitpod offers an alternative method for compiling the firmware without installing Visual Studio Code. It is a web browser-based online IDE that can be used with a GitHub account. Gitpod provides a free tier suitable for light use, such as compiling custom firmware.