Tried to follow the docs on uploading firmware updates OTA using PlatformIO on Visual Studio Code from my windows PC. Created a filename_env.ini file with the following lines in the file:
When I click upload at the bottom of the screen I get this response after the build:
Successfully created esp32 image.
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port…
Error: Please specify upload_port for environment or use global --upload-port option.
For some development platforms it can be a USB flash drive (i.e. /media//)
*** [upload] Explicit exit, status 1
The upload failes and appear to have not switched to espota from esptool based on the response??? Any suggestions??? I am very new to this and have searched the web but that was not helpful…
If I just click build it seems to build successfully…
Have a look at this thread as to how to make sure you are actually trying to upload the desired environment. Like which environment is indicated at the bottom to the right of the upload button, or by using the PlatfomIO PROJECT TASKS.
Created a filename_env.ini file with the following lines in the file
And just adding these lines to a portable config file is not enough to define a custom environment. You need to extend an existing environment or create one completely, by using pre-defined environments as a template. Also your environment needs to have its own unique environemnt name.
I suppose you want to create a portable config file for all your 10 OMG gateways
How do they get their IP addresses, do you have static assignments in your router’s DHCP setup or do you use the OMG’s NetworkAdvancedSetup functiuonality?
But I still get the same failure. For my network addresses I have static IPs set in my router based on the devices MAC addresses. I did also include this in the file as I assumed it was needed to find the device to upload to??
The default is upper case OTAPASSWORD
unless you have changed and set it already before.
For most modern router you could probably also use the mDNS entry, e.g.
upload_port = OMG_09.local
And this still has the non-OTA environment indicated as the build and upload target.
Have you tried the PROJECT TASKS under the PlatformIO alien head on the left side of VSC, there you should see the esp32-m5atom-lite-gateway09-ota environment with its upload option when expanded. Alternatively you will have to add an additional
default_envs = esp32-m5atom-lite-gateway09-ota
at the top of your portable config filel, similar to how you must have done it for esp32-m5atom-lite-gateway09 and uncomment the appropriate one, until tyou see it at the botoom as the build and upload target. I still find the PROJECT TASK way a lot more comfortable than adding, commenting and uncommenting default_envs lines
So, figured this out and now managed to get this to build and to upload. These are the final lines of code that helped it upload:
[env:esp32-m5atom-lite-gateway09-ota]
extends = env:esp32-m5atom-lite-gateway09
upload_protocol = espota
upload_port = 192.168.0.219
upload_flags =
--auth=my actual device password inserted here
--port=8266
Since I am not sure how versioning is managed I was surprised to see this version number shown:
I assume this is because I downloaded the code and installed from my copy on my hard drive? If there is a way to show the actual version build code that would be great? for now I added this line to my env file and it at least shows the date:
‘-DOMG_VERSION=“2024.01.31”’
To your earlier question, all of this work in my custom _env.ini file totals about 30 lines of code and I would like to be able to push one build to do all my 10 gateways but not sure how to do that. All of my 10 gateways the same m5atom-lite. While I guess I could copy all 30 lines and tweak the code 9 times in this file if there is an easier way that woule be awesome? This is not really an OpenMQTTGateway question but really more of a PlatformIO question I assume so if you wanna point me somewhere or suggest I go look, I am OK with that. Never really did this before so it is all learning!
Would you mind sharing this one custom environment, obviously masking any confidential information?
My suggestion would be to create one single base environment which contains all the shared definitions, like the base lib_deps and build_flags like WiFi credentials, MQTT credentials etc. I would also suggest to use the above mentioned NetworkAdvancedSetup to really make this a truly portable config file. In case you ever change your router or have to swap one of the m5atom-lites for a new one, this saves you from having to redefine any static IP DHCP assignment in your new router/for your new m5atom-lite.
Then just create 10 environments after the base one with each one extending the base with the individual definitions like Gateway_Name, MinimumRSSI, NET_IP etc. and the OTA details.
If you then also comment out line 16 in platformio.ini like ; environments.ini
you will only have your own custom environments showing in the PROJECT TASKS list to build and upload via OTA.
Hope this makes sense. Maybe try with defining the base environment and creating one or two additional extends OMG_01, OMG_02 environments for testing.
I have no problem sharing anything I have done and am doing. Let me digest your note above and see what I can do to split the environments and move in that direction. Please understand this is the first time I have used Visual Studio Code to do anything other than edit some Yaml files in Home Assistant, and I have very little experience with Github so I am truly learning new things with every step I take. And you have been awesome!
Once I have played a bit with your suggestions I will circle back and I will see how I can share all I have done so maybe it can be of use to you or others!
I have attempted to do what you suggested however not sure I am clear on what to set as the Project Environment at the bottom of the Visual Studio Code window? With two extensions to the base called: esp32-m5atom-lite-gateway08-ota and esp32-m5atom-lite-gateway09-ota I can only select one Project Environment at the bottom. If I select esp32-m5atom-lite-gateway09-ota that builds fine, but if I select esp32-m5atom-lite-gateway08-ota I get an error? How do I select both, or eventually all 10?
Would you mind posting your portable config file, as it currently is?
And have you tried the PROJECT TASKS way at all on the left side of Visual Studio Code under the PlatformIO alien head icon? This would allow you to completely ignore the bottom indicator completely.
but if I select esp32-m5atom-lite-gateway08-ota I get an error?
How did you select esp32-m5atom-lite-gateway08-ota?
So I split the code up differently and created two lower environments got OMG_08 and OMG_09. The format for both of these is shown here as it is for OMG_09:
I have the option for the two enviroment on the left side now. Not sure how the new environment 08 got added. OMG_08 now builds from the side panel. So in inserted my prepared code for the other gateways and hit save but they do not show up in the left panel? THese environments are:
I’m still missing the esp32-m5atom-lite-gateway environment to see what it contains, and the whole file content including the default_envs definitions at the top.
My suggestion would be to start with
[platformio]
default_envs =
m5atom-lite-ble-OMG_01
m5atom-lite-ble-OMG_02
[env:m5atom-lite-ble-base]
;<Here with your base gateway definitions common to all your gateways, like WiFi and MQTT credentials, etc.>
[env:m5atom-lite-ble-OMG_01]
extends = env:m5atom-lite-ble-base
build_flags =
'-DNET_IP="192.168.0.211"'
'-DGateway_Name="OMG_01"
'-DMinimumRSSI=-75'
;<and any other definitions unique to each separate gateway>
upload_protocol = espota
upload_port = 192.168.0.211
upload_flags =
--auth=actual password
--port=8266
[env:m5atom-lite-ble-OMG_02]
extends = env:m5atom-lite-ble-base
build_flags =
'-DNET_IP="192.168.0.212"'
'-DGateway_Name="OMG_02"
'-DMinimumRSSI=-75'
;<and any other definitions unique to each separate gateway>
upload_protocol = espota
upload_port = 192.168.0.212
upload_flags =
--auth=actual password
--port=8266
With all of the gateways added like this and also adding them to the default_envs at the top, in PROJECT TASKS you can either expand an individual gateway to build and upload it, or just expand Default at the top and select Uplaod to build and upload all of them - given that you have commented out line 16 in platformio.ini ; environments.ini
you’ll only see your custom environments.
But selecting the same build and/or upload at the bottom should have the same effect with the above.
I’ve made the environment names a bit shorter for easier identification
Got it all working for now. All environments are now in the left column when I added them at the top. I will play with this a bit and add other parameters to config that I want to adjust as part of the upload.
Thanks again for all your help. As mentioned I would be glad to share all my code when I am done so you can let me know how to do that. I can post it at the end of this thread if you desire. May be a day or ttwo before I get that far!
I was able to update all of my OMG Gateways remotely today once I finalize the settings discussed earlier. I did though notice that the Extend functionality was not working quite how I expected it to. I inserted the ‘-DOMG_VERSION=“2024.01.31”’ into the base env expecting it to trickle down to each of the extended OTA env’s. However, it did not and left the version again as “version_tag” as it did in an earlier post. So I moved this to each of the OTA extended env areas and it uploaded fine. This had worked in the original file when I was only updating one OTA extended env so not sure what is different???
I also attempted to set the ‘-DMinimumRSSI=-75’ in each of the the OTA extended env sections and I do not believe this was uploaded. I am gonna play with some of the setting in the base and extended env sections to try and figure out what does work and what may not. Once I have doe this I will circle back with an update!
I found the “MinimumRSSI” option burried in the code somewhere but was just curious if there was a simple list of all the flags which can be set through the upload with their actually spelling? No worries if not as I can poke aroud some more.
I confirmed that no matter where I put the ‘-DMinimumRSSI=-75’ setting ( Base or Extended ENV) it does not update the Gateways? Did not get to check other flags as real life gets in the way, but this one does not appear to work at all…
I have not actually tried OMG_VERSION with any extends, but thanks for this observation.
One suggestion would be, and this is how I also do it, to have another separate section at the top of your portable config file, which contains all the vital details which are common to all further environments below, not just BLE ones as you have now by extending the base BLE environment, but also for possible future RF, IR etc. gateways, or even BLE gateways, which do not quite extend the current base one. Something like
which can then be added to any environment in the build_flags section with
${my-vital-configs.build_flags}
allowing for setting the OMG_VERSION just once, with the short hash of the most recent commit, or the date as you have done.
When you try this and add the above to the base environment, does it not transfer to all the other environments through the extend?
This has been mentioned before, but there is currently no implementation of having the config values listed separately. They are however in each config_XX.h file of the respective gateway implementation, i.e. for BT/Bluetooth it is config_BT.h, for an IR gateway in config_IR.h etc. usually with comments to describe their functionality.
This is very likely because you might have set the value before by MQTT command, along with other commands.
Can you send an
{“init”:true}
to the gateways, to make sure they load the directly OTA sent values, and not have some kept values through the startup process you might have sent and saved before when trying out these values?
By the way, if you want to load the default built-in configuration (on any board, not only ESP32), use the command:
How did you initially upload the environments to your gateways, by serial connection to the computer and with the custom environments, or were any pre-built binaries involved at some stage?
So you might actually need to erase these previously set, and stored in flash, settings to always load the OTA’d init settings at every restart - best test with one of your gateways initially.
I will attempt this and then try to set the minrssi again.
I did initally load via USD then made some changes sending Commands through MQTT Explorer with the save option. So I suspect that is the issue. I will try the reset of the flashed settings and try a again to load these OTS. Does the { “init”: true} command erase the old settings or is there another command to use?