"Dual Boot" firmware for running Meshcore and Meshtastic on a single Ep32 based device without re-flashing.
This project pulls Meshtastic and Meshcore source code and patches it to be able to coexist. It then writes them along with needed file systems and a loader to swap between at boot. Each time the Esp32 boots it will first boot to the loader program. If there is no interaction for 2 seconds the loader will boot the last booted firmware if the button is pressed the other firmware will boot.
- heltec_v4
- heltec_v3
Adding a config for your device is very easy so long as it has enough flash (~8MB+).
-
Download the latest firmware for your device from releases.
-
Flash the firmware to address
0x0000. I recommend using esptool:
esptool write-flash 0x0000 <firmware name>.binIf you prefer a web flasher use a generic one like EspConnect or EspWebTool not the meshcore/meshtastic web flasher.
- Clone the repo recursively to get submodules.
git clone --recursive <URL>- Install needed dependencies automatically with nix or manually.
nix develop- Set your variant:
export VARIANT=heltec_v4- Run targets form the Makefile. To build a merged binary:
make mergedTo flash the merged binary:
make flash-mergedYou need to add a new loader variant to loader/variants and loader/boards. I recommend copying the config for your variant from meshcore and then removing parts that are not needed.
Create a new .mk file based on variants/heltec_v4.mk. This file needs to have the same name as the .patch file which must be the same as the variant name.
if a size/layout that will work for your flash does not exist you may create one in partitions.
This step should be avoided unless necessary. It should be possible to only use already present patches.
- Make your device-specific modifications to the module directly to the meshtastic/meshcore source code.
- Generate the patch file:.
cd modules/<module name> && git add . && git diff --cached > ../../patches/<module_name>/<variant_name>.patch- Confirm the patch was successfully generated, then restore the module:
cd modules/<module name> && git reset --hard HEADTest with:
VARIANT=<variant name> make flash-mergedThen make a PR others can benefit.
This directory (partitions/) contains partition table configurations crucial for defining how the ESP32's flash memory is divided among different firmware components.
Each subdirectory within partitions/ (e.g., 16mb_default/) represents a specific partition layout configuration.
Each layout directory must contain these four files:
addresses.mk: Defines memory addresses for each partition, loaded by the main Makefile.partitions.csv: Specifies the real flash layout used when combining all firmware into a single merged binary.partitions-meshcore.csv: The build-time partition table specifically for Meshcore.partitions-meshtastic.csv: The build-time partition table specifically for Meshtastic.
This works by using Over-the-Air partitions meant for uploading firmware in deployment. The Esp32 chooses a partition to boot into, but the firmware in each partition never mark themselves as valid forcing a rollback to the loader partition on boot.
There are three patches:
- Loader patches to make the esp32 not mark partitions as valid.
- File system patches to make the firmwares not conflict.
- Bluetooth patch to offset the Meshcore MAC address for easier connecting.
- Much less flash for a file system.
- Does not work with OTA updates.
- ~2 seconds slower boot.