Updated Create your own Firmware Build without IDE (markdown)

Jason2866 2019-10-28 09:38:50 +01:00
parent ee491561cc
commit ee3619ac41
1 changed files with 36 additions and 43 deletions

@ -1,7 +1,7 @@
PlatformIO is not just an IDE.
In fact, all its features are accessible from the command line, and the IDE is a convenience wrapper layer around it.
Thus, we can build Sonoff-Tasmota using only this PlatformIO-Core, which may come handy for automated builds, or for those who (like me :)) feel more comfortable with the command line than with the IDE.
Thus, we can build Tasmota using only this PlatformIO-Core, which may come handy for automated builds, or for those who feel more comfortable with the command line than with the IDE.
The steps are surprisingly simple and straightforward:
@ -11,12 +11,12 @@ At least if you want to work in a cloud environment, but you may also choose to
PlatformIO is based on python, so if we use `python-virtualenv`, then all the dependent packages will be confined to a separate folder, so it won't even taint the OS installation.
As all of `python` (2.7), `python-virtualenv` and `python-pip` are available in most of the recent distros, you may pick your favourite one.
As all of `python`, `python-virtualenv` and `python-pip` are available in most of the recent distros, you may pick your favourite one.
## Install python and tools
Install `python` (2.7) and `python-virtualenv`, and `python-pip`, because we don't want to mess up the python ecosystem of the distro.
Install `python` and `python-virtualenv`, and `python-pip`, because we don't want to mess up the python ecosystem of the distro.
Update pip by `pip install --upgrade pip`, and this was the last step done as root, the rest goes as a plain user.
@ -114,13 +114,13 @@ Installing collected packages: pip
Successfully installed pip-18.1
```
## Fetch the Sonoff-Tasmota sources
## Fetch the Tasmota sources
If you want only to build, then the original repo will do, but if you want to contribute as well, then fork an own copy of the repo and clone out that one.
```
(platformio-core) [tasmota_builder@jtest platformio-core]$ git clone https://github.com/arendst/Sonoff-Tasmota.git
Cloning into 'Sonoff-Tasmota'...
(platformio-core) [tasmota_builder@jtest platformio-core]$ git clone https://github.com/arendst/Tasmota.git
Cloning into 'Tasmota'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (5/5), done.
@ -132,28 +132,26 @@ Resolving deltas: 100% (11426/11426), done.
After changing to the working copy, we are ready to go:
```
(platformio-core) [tasmota_builder@jtest platformio-core]$ cd Sonoff-Tasmota/
(platformio-core) [tasmota_builder@jtest Sonoff-Tasmota]$
(platformio-core) [tasmota_builder@jtest platformio-core]$ cd Tasmota/
(platformio-core) [tasmota_builder@jtest Tasmota]$
```
## Configure the sources
Now you may want to configure the sources for your needs, as described at [Upload](https://github.com/arendst/Sonoff-Tasmota/wiki/Upload)
Now you may want to configure the sources for your needs, as described at [Upload](https://github.com/arendst/Tasmota/wiki/Upload)
Actually, the sources do build fine right out-of-the box, only it'll be a full build, including all the language localisation and all the build flavours as well, while you are usually interested only in one language and one build flavour only.
The speed ratio is around 1:27 now, so during development it's worth the effort.
In `platformio.ini` choose the environment (or flavour, if you like) you want to build.
In `sonoff/user_config_override.h` fine tune the default values for the module, the wifi, the MQTT server, and so on. Refer to the Tasmota Wiki for details.
In `tasmota/user_config_override.h` fine tune the default values for the module, the wifi, the MQTT server, and so on. Refer to the Tasmota Wiki for details.
## Build the firmware
The build command itself is `pio run`, but as it emits quite a lot of messages (including errors if you're developing), so you may want to redirect a copy of the standard output and error to a file, so it'll be `pio run 2>&1 | tee build.log`.
```
(platformio-core) [tasmota_builder@jtest Sonoff-Tasmota]$ time pio run 2>&1 | tee build.log
(platformio-core) [tasmota_builder@jtest Tasmota]$ time pio run 2>&1 | tee build.log
************************************************************************************************************************************************************************
If you like PlatformIO, please:
- follow us on Twitter to stay up-to-date on the latest project news > https://twitter.com/PlatformIO_Org
@ -162,7 +160,7 @@ If you like PlatformIO, please:
- support us with PlatformIO Plus > https://pioplus.com
************************************************************************************************************************************************************************
Processing sonoff (framework: arduino; platform: espressif8266@1.8.0; board: esp01_1m)
Processing tasmota (framework: arduino; platform: espressif8266@1.8.0; board: esp01_1m)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PlatformManager: Installing espressif8266 @ 1.8.0
Downloading
@ -182,43 +180,38 @@ The result will be here: `./.pioenvs/<build-flavour>/firmware.bin`
```
(platformio-core) [tasmota_builder@jtest Sonoff-Tasmota]$ find .pioenvs -name '*.bin'
.pioenvs/sonoff-FR/firmware.bin
.pioenvs/sonoff-GR/firmware.bin
.pioenvs/sonoff-HE/firmware.bin
.pioenvs/sonoff-HU/firmware.bin
.pioenvs/sonoff-IT/firmware.bin
.pioenvs/sonoff-NL/firmware.bin
.pioenvs/sonoff-PL/firmware.bin
.pioenvs/sonoff-PT/firmware.bin
.pioenvs/sonoff-RU/firmware.bin
.pioenvs/sonoff-SE/firmware.bin
.pioenvs/sonoff-SK/firmware.bin
.pioenvs/sonoff-TR/firmware.bin
.pioenvs/sonoff-TW/firmware.bin
.pioenvs/sonoff-UK/firmware.bin
.pioenvs/sonoff/firmware.bin
.pioenvs/sonoff-minimal/firmware.bin
.pioenvs/sonoff-basic/firmware.bin
.pioenvs/sonoff-classic/firmware.bin
.pioenvs/tasmota-FR/firmware.bin
.pioenvs/tasmota-GR/firmware.bin
.pioenvs/tasmota-HE/firmware.bin
.pioenvs/tasmota-HU/firmware.bin
.pioenvs/tasmota-IT/firmware.bin
.pioenvs/tasmota-NL/firmware.bin
.pioenvs/tasmota-PL/firmware.bin
.pioenvs/tasmota-PT/firmware.bin
.pioenvs/tasmota-RU/firmware.bin
.pioenvs/tasmota-SE/firmware.bin
.pioenvs/tasmota-SK/firmware.bin
.pioenvs/tasmota-TR/firmware.bin
.pioenvs/tasmota-TW/firmware.bin
.pioenvs/tasmota-UK/firmware.bin
.pioenvs/tasmota/firmware.bin
.pioenvs/tasmota-minimal/firmware.bin
.pioenvs/tasmota-basic/firmware.bin
.pioenvs/sonoff-knx/firmware.bin
.pioenvs/sonoff-sensors/firmware.bin
.pioenvs/tasmota-sensors/firmware.bin
.pioenvs/sonoff-display/firmware.bin
.pioenvs/sonoff-BG/firmware.bin
.pioenvs/sonoff-BR/firmware.bin
.pioenvs/sonoff-CN/firmware.bin
.pioenvs/sonoff-CZ/firmware.bin
.pioenvs/sonoff-DE/firmware.bin
.pioenvs/sonoff-ES/firmware.bin
.pioenvs/tasmota-BG/firmware.bin
.pioenvs/tasmota-BR/firmware.bin
.pioenvs/tasmota-CN/firmware.bin
.pioenvs/tasmota-CZ/firmware.bin
.pioenvs/tasmota-DE/firmware.bin
.pioenvs/tasmota-ES/firmware.bin
```
## About build times
The recent versions of PlatformIO-Core seem to parallelise quite well.
On a Google Compute node with 1 CPU the **full** build time was 57 minutes, with 2 cores it dropped to 24 mins, with 4 cores to 13 mins.
When building just one flavour (e.g. only `sonoff`) from scratch, it's about 1:27 of the full build, so with 2 cores it's around 1 minute, with 4 cores around half of it.
When you've changed only a few files, not everything needs to be recompiled (though the image must still be re-packed), so that minute-like build time is the maximum, usually it'll be less.