meshtastic/docs/development/firmware/building.mdx

70 lines
3.7 KiB
Plaintext
Raw Normal View History

2022-11-07 20:53:52 -08:00
---
id: build
title: Building Meshtastic Firmware
sidebar_label: Building Firmware
Squashed commit of the following: commit 86bc3c93e5fac8dfb5eb023f1aa6d405bb9d9ffe Merge: 6cabd5fe cfec3e8e Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 18:48:14 2024 -0700 Merge pull request #1301 from rcarteraz/1200bps-reset-button Add mention of 1200bps reset button in web flasher commit cfec3e8eace1719736a5a6cd4f0093385f0bdad8 Merge: 59d71321 6cabd5fe Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:59:09 2024 -0700 Merge branch 'master' into 1200bps-reset-button commit 6cabd5fe955461798f90dc7cebd98928c5d6578e Merge: f6a97b28 6c40c2e5 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:58:54 2024 -0700 Merge pull request #1295 from geeksville/pr-nrf52-guide Add basic nrf52 guide commit 6c40c2e5558b7270646319a91123843c8671edbc Merge: 9cbea09e f6a97b28 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:56:57 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit 59d71321e380836c75d5b32401e2a8647933dd43 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:52:06 2024 -0700 Add mention of 1200bps reset button in web flasher commit 9cbea09e5cb459853f9bcee2b8b206c19966d1f5 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Tue Jun 18 13:53:25 2024 -0700 formatting and minor changes commit fad3a940d142558d7cc9dd59553af0b83d8c5d7c Merge: f3523b72 f95a398c Author: rcarteraz <robert.l.carter2@gmail.com> Date: Tue Jun 18 13:01:01 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit f3523b72f5c24b338cc20acc2ba73b74dd73babb Merge: b2fcaa55 70638582 Author: geeksville <kevinh@geeksville.com> Date: Sun Jun 16 21:11:52 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit b2fcaa55300ad339bf8994f1c89c52cb1aedfc1a Author: geeksville <kevinh@geeksville.com> Date: Sun Jun 16 15:16:37 2024 -0700 Add basic nrf52 guide
2024-06-19 18:50:33 -07:00
sidebar_position: 2
2022-11-07 20:53:52 -08:00
---
Meshtastic uses [PlatformIO](https://platformio.org), a development environment that enables easy multi-platform development and centralized tooling.
## Setup the Build Environment
1. [Install PlatformIO](https://platformio.org/platformio-ide)
2. Clone the [Meshtastic Firmware](https://github.com/meshtastic/firmware) repository
2023-01-19 05:01:57 -08:00
```shell
2022-11-07 20:53:52 -08:00
git clone https://github.com/meshtastic/firmware.git
```
3. Update the repository's [submodules](https://github.com/meshtastic/firmware/blob/master/.gitmodules)
```shell
2023-03-28 12:55:56 -07:00
cd firmware && git submodule update --init
2022-11-07 20:53:52 -08:00
```
Squashed commit of the following: commit 86bc3c93e5fac8dfb5eb023f1aa6d405bb9d9ffe Merge: 6cabd5fe cfec3e8e Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 18:48:14 2024 -0700 Merge pull request #1301 from rcarteraz/1200bps-reset-button Add mention of 1200bps reset button in web flasher commit cfec3e8eace1719736a5a6cd4f0093385f0bdad8 Merge: 59d71321 6cabd5fe Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:59:09 2024 -0700 Merge branch 'master' into 1200bps-reset-button commit 6cabd5fe955461798f90dc7cebd98928c5d6578e Merge: f6a97b28 6c40c2e5 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:58:54 2024 -0700 Merge pull request #1295 from geeksville/pr-nrf52-guide Add basic nrf52 guide commit 6c40c2e5558b7270646319a91123843c8671edbc Merge: 9cbea09e f6a97b28 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:56:57 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit 59d71321e380836c75d5b32401e2a8647933dd43 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Wed Jun 19 17:52:06 2024 -0700 Add mention of 1200bps reset button in web flasher commit 9cbea09e5cb459853f9bcee2b8b206c19966d1f5 Author: rcarteraz <robert.l.carter2@gmail.com> Date: Tue Jun 18 13:53:25 2024 -0700 formatting and minor changes commit fad3a940d142558d7cc9dd59553af0b83d8c5d7c Merge: f3523b72 f95a398c Author: rcarteraz <robert.l.carter2@gmail.com> Date: Tue Jun 18 13:01:01 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit f3523b72f5c24b338cc20acc2ba73b74dd73babb Merge: b2fcaa55 70638582 Author: geeksville <kevinh@geeksville.com> Date: Sun Jun 16 21:11:52 2024 -0700 Merge branch 'master' into pr-nrf52-guide commit b2fcaa55300ad339bf8994f1c89c52cb1aedfc1a Author: geeksville <kevinh@geeksville.com> Date: Sun Jun 16 15:16:37 2024 -0700 Add basic nrf52 guide
2024-06-19 18:50:33 -07:00
:::info
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)
:::
2022-11-07 20:53:52 -08:00
## Build
2023-03-28 12:55:56 -07:00
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.
2022-11-07 20:53:52 -08:00
2. To select the device you you wish to build, open your [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette):
- Windows: `Ctrl + Shift + P`
- Mac: `command + Shift + P`
3. Enter: `PlatformIO: Pick Project Environment` and select your target.
2022-11-07 20:53:52 -08:00
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.
```shell
[env:m5stack-atom]
extends = esp32_base
board = m5stack-atom
monitor_filters = esp32_exception_decoder
build_flags =
${esp32_base.build_flags} -D PRIVATE_HW -I variants/m5stack_atom
lib_deps =
${esp32_base.lib_deps}
```
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) and send a Pull Request for the `mesh.proto` file, adding your board to the `HardwareModel` Enum.
4. Change your define in `platformio.ini` from `PRIVATE_HW` to `YOUR_BOARD`. Adjust any macro guards in the code you need to support your board.
2023-09-17 08:21:11 -07:00
5. Add your board identifier to `architecture.h` on the firmware repo in the folder of the platform you are using, and send in that Pull Request too.
2022-11-07 20:53:52 -08:00
6. Wait for the Pulls to be merged back into Master.
7. Profit :-)