Micron Document
building meshtastic from git at the cli

I cloned the meshtastic repo a few weeks back but was still using the browser based flasher and the images they package. The instructions for building from the CLI seemed absent from the repository. Or at least I didn't see them.

What follows will be an explanation of how to do it.

The Process

• Clone
• Select Board
• Build
• Flash

Required Software

Platformio and whatever its dependencies are. On NixOS I just use the package. I assume it's the same for other distributions, but you know, following whatever that distribution does for installing. I did have a bit of a snag where it didn't want to use a virtual environment from T383838platformio when T383838platformio tried to pip install dependencies.

On Nix I used a temporary shell to do all of this instead of putting everything on my system.

nix-shell -p platformio esptool pkg-config \
python3Packages.pip python3Packages.protobuf \
python3Packages.grpcio python3Packages.grpcio-tools

All the other commands were done under this shell.

Clone

I cloned from here: https://github.com/meshtastic/firmware.git

git clone https://github.com/meshtastic/firmware.git

I forget if it used submodules, I'll confirm it later.

git submodules init

Select Board

Edit the T383838platformio.ini file your board by locating the T383838[platformio] section and setting the T383838.default_envs. I'm using the LilyGo T-Deck, so mine looks like this:

T282828
Tff7b72[platformio]
Te6edf3default_envs Tff7b72= Ta5d6fft-deck


Build

T282828
platformio run

This might take a while. It fetches dependencies and does the build. When it completes, one of the last things it will say is the path to the newly built firmware file, that's needed for the next step.

Wrote 0x1e66c0 bytes to file /home/stephen/firmware/.pio/build/t-deck/f
irmware.factory.bin, ready to flash to offset 0x0
==================== [SUCCESS] Took 192.52 seconds ====================

Environment Status Duration
------------- -------- ------------
t-deck SUCCESS 00:03:12.524
===================== 1 succeeded in 00:03:12.524 =====================

It looks like it went into T383838.pio/build/t-deck/firmware.factory.bin.

Flash

In order to flash, you must put the device into flash mode and you need to know the path to the device.

To put the device in flash mode, turn off the power, hold the track ball down (you should feel it click softly), turn the power back on, and wait about 8 seconds before releasing the track ball.

You can discover what the device is by listing them with the T383838device sub-command of T383838platformio:

T282828
Tff7b72[stephen@sasahi:~/firmwareTff7b72]$ platformio device list
/dev/ttySAC0
------------
Hardware ID: n/a
Description: n/a

/dev/ttyACM0
------------
Hardware ID: USB VID:PIDTff7b72=303A:1001 Te6edf3SERTff7b72=DCDA0C3A924C Te6edf3LOCATIONTff7b72=T79c0ff1-1:1.0
Description: Espressif Systems LilyGO T-Deck Tff7b72(T79c0ff16 MB FLASH, T79c0ff8 MB PSRAMTff7b72) -
TinyUSB CDC


I still don't know what T383838/dev/ttySAC0 is, but on my system, T383838/dev/ttyACM0 is the target.

To perform the flashing (from the firmware clone directory):

T282828
esptool.py write_flash 0x00 .pio/build/t-deck/firmware.factory.bin

If the flashing is successful, you will see:

[nix-shell:~/firmware]$ esptool.py write_flash 0x00 .pio/build/t-deck/firmware.factory.bin
esptool.py v4.7.0
Found 2 serial ports
Serial port /dev/ttySAC0
/dev/ttySAC0 failed to connect: Could not open /dev/ttySAC0, the port is busy or doesn't exist.
([Errno 13] could not open port /dev/ttySAC0: [Errno 13] Permission denied: '/dev/ttySAC0')

Hint: Try to add user into dialout group: sudo usermod -a -G dialout $USER

Serial port /dev/ttyACM0
Connecting...
Detecting chip type... ESP32-S3
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
Crystal is 40MHz
MAC: dc:da:0c:3a:92:4c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x001ecfff...
Compressed 2019280 bytes to 1247036...
Wrote 2019280 bytes (1247036 compressed) at 0x00000000 in 15.4 seconds (effective 1045.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

When it finishes flashing, you may still need to manually reboot the device.

Conclusion

That's it. It's built and flashed.

The original raw notes from exploring this can be found here:

Tags: index, cli, meshtastic

Tags
Navigation
Backlinks