Skip to content

Instantly share code, notes, and snippets.

@KunYi
Last active December 5, 2024 05:03
Show Gist options
  • Save KunYi/4dcff34cf870808be855c48356736213 to your computer and use it in GitHub Desktop.
Save KunYi/4dcff34cf870808be855c48356736213 to your computer and use it in GitHub Desktop.
build meshtastic firmware for heltec LoRa 32 v2.0

Build meshtastic firmware (2.5.16.c3d60342) for Heltec LoRAa 32 v2

$ mkdir -p /tmp/pio
$ cd /tmp/pio
$ virtualenv .
$ source bin/activate
$ pip install -U platformio
$ git clone https://github.com/meshtastic/firmware.git --recurse-submodules # pull source code
$ cd firmware
$ pio run -e heltec-v2_0 # kick-off build process

...
Building in release mode
Using meshtastic platformio-custom.py, firmware version 2.5.16.c3d60342 on heltec-v2_0
Using flags:
-DAPP_VERSION=2.5.16.c3d60342
-DAPP_VERSION_SHORT=2.5.16
-DAPP_ENV=heltec-v2_0
-DUSERPREFS_TZ_STRING=\"tzplaceholder                              
...
Processing heltec-v2_0 (board: heltec_wifi_lora_32_V2; platform: platformio/[email protected]; framework: arduino)
Indexing .pio/build/heltec-v2_0/libFrameworkArduino.a
Linking .pio/build/heltec-v2_0/firmware.elf
.pio/libdeps/heltec-v2_0/Crypto/AESEsp32.cpp:33:5: warning: type of 'esp_aes_setkey' does not match original declaration [-Wlto-type-mismatch]
 int esp_aes_setkey(unsigned char *ctx, const unsigned char *key,
     ^
/home/kunyi/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/mbedtls/include/mbedtls/aes.h:184:5: note: 'esp_aes_setkey' was previously declared here
 int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
     ^
/home/kunyi/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/mbedtls/mbedtls/include/mbedtls/aes.h:184:5: note: code may be misoptimized unless -fno-strict-aliasing is used
Retrieving maximum program size .pio/build/heltec-v2_0/firmware.elf
Checking size .pio/build/heltec-v2_0/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  29.7% (used 97252 bytes from 327680 bytes)
Flash: [========  ]  84.5% (used 2048017 bytes from 2424832 bytes)
Building .pio/build/heltec-v2_0/firmware.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 27 ELF sections
Successfully created esp32 image.
esp32_create_combined_bin([".pio/build/heltec-v2_0/firmware.bin"], [".pio/build/heltec-v2_0/firmware.elf"])
Generating combined binary for serial flashing
    Offset | File
 -  0x1000 | /tmp/pio/firmware/.pio/build/heltec-v2_0/bootloader.bin
 -  0x8000 | /tmp/pio/firmware/.pio/build/heltec-v2_0/partitions.bin
 -  0xe000 | /home/kunyi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin
 - 0x10000 | /tmp/pio/firmware/.pio/build/heltec-v2_0/firmware.bin
Using esptool.py arguments: --chip esp32 merge_bin -o /tmp/pio/firmware/.pio/build/heltec-v2_0/firmware.factory.bin --flash_mode dio --flash_freq 40m --flash_size 8MB 0x1000 /tmp/pio/firmware/.pio/build/heltec-v2_0/bootloader.bin 0x8000 /tmp/pio/firmware/.pio/build/heltec-v2_0/partitions.bin 0xe000 /home/kunyi/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 /tmp/pio/firmware/.pio/build/heltec-v2_0/firmware.bin
esptool.py v4.5.1
Wrote 0x205a50 bytes to file /tmp/pio/firmware/.pio/build/heltec-v2_0/firmware.factory.bin, ready to flash to offset 0x0

$ cd .pio/build/heltec-v2_0
$ esptool.py --port /dev/ttyUSB0 --chip esp32 --baud 460800 write_flash 0x0 firmware.factory.bin # download into device flash

or to edit /variants/heltec_v2/platformio.ini and add the below context into the file

monitor_speed = 115200
upload_protocol = esptool
;upload_port = /dev/ttyUSB0
upload_speed = 460800

than run the below command

$ pio run -e heltec-v2_0 --upload-port /dev/ttyUSB0 --monitor-port /dev/ttyUSB0 --target upload # need add 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment