I assumed that my desk was a kind of a mess... but now I realize it's just average!
I tried to get FOTA working two times before, and I was about to give up a third time as I had always the same problems:
I tried the oficial github firmwares , the ones from GuilleBot I played with fuses, boards.txt, platformio.ini setting, different GWs, etc, etc, etc....
Last night I found this issue in github that gave me the detail that was missing. Just do not upload a sketch to the board, only program the MYSBootloader and wait until it asks the FW to the controller!
Another source of confusion, at least for me, was that I did not knew what to expect of the whole process. What where the different steps and the expected duration of the upload. I will try to describe my setup and how I could finally get it working.
Get the correct MYSBootloader for your setup
Check GuilleBot repository if you are using another nfr24 channel or want to play with different radio power
Modify boards.txt or your platformio.ini to add the bootloader
In my case, for the nano:
[platformio] default_envs = MYSBootloaderNano [env] platform = atmelavr framework = arduino upload_protocol = stk500v1 upload_port = /dev/ttyACM0 upload_speed = 19200 upload_flags = -v -e -P$UPLOAD_PORT -b$UPLOAD_SPEED lib_deps = MySensors MySensors NodeManager [env:MYSBootloaderNano] board = nanoatmega328new board_bootloader.file = bootloader/MYSBootloader_16MHz.hex
The important bits, the upload_flags specially the -e to erase the memory and the board_bootloader.file
$ platformio -f -c vim run --target bootloader
$ platformio -f -c vim run --target run
Look in .pio/build/<board>/
Build your HW if needed, plug the radio, etc
Be sure to keep the MQTT Explorer and MyController.org to see some feedback of the whole process
Powerup the sensor
You will see a new node with ID 1 in MyController.org, if you look in "Status -> Resources logs" or in the MQTT Explorer you should see the node asking for a new FW.
In MyController.org assign the FW to the new node with ID 1 and upload it.
Check the manual if in doubt.
You will see in MQTT Explorer that the controller and the node get very chatty. The node will ask for each piece of the HEX in small batches.
You have some time now, get up and make yourself a cup of coffee and prepare a small celebration.
Check the MQTT Explorer, the FW is still uploading... go and get some confetti.
Check Mycontroller.org or HomeAssitant, the FW is uploaded and a new node just popup!
@NeverDie I can give my thoughts here, and we can move it later to another thread if necessary.
The bigger selling points, at least for me:
I like to play with arduino and electronics, but have other interests (Family, friends and 3 small kids...) so I usually have little time to spent in my hobbies. Platformio allows me to just have all the configuration in code and know 6 months ahead that I can do a "make clean && make upload" for a particular node without issues, even if I lost my PC, as everything is in my gitlab account.
Also the FW of my 3dprinter must be complied and uploaded with platformio (marlin 2.0) so I can have only one tool for both hobbies.