FOTA/MYSBootloader - Documentation enhacement - Make it clear that you must program only the MYSBootloader, without sketch



  • Hi all,
    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:

    • After programming the MYSBootloader I loose the ability to do upload sketches via FTDI (with both pro-mini, nano's and barebones 328P)
    • With MySController I could not upload any new FW, even a simple reboot command make the arduino to lock hard and it had to be powered down.

    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.

    MySetup

    • Controller: HomeAssistant
    • GW:MQTT GW using ESP8266
    • Portainer from the HomeAssistan AddOns
    • MQTT from the HomeAssistan AddOns (mosquitto)
    • FW Controller - MYCONTROLLER.ORG using MQTT GW.
      Follow this post instructions
      I installed it with docker in the same machine as HA using Portainer and cdrocker's image
    • Platformio.org for building sketches and programming bootloaders
      Out of scope of this post, but way better than using Arduino. Totally worth the pain of learning it's basics.
    • A MQTT Gui to see what is happening between the node and the controller
      I'm using MQTT EXplorer
    • An Arduino UNO as an ISP
    • Sensors: A big mess of half working handmade boards, EasyPCB and SlimNode Sensors.

    Steps

    • 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

    • Program only the bootloader (and the fuses if necessary), for platformio:
    $ platformio -f -c vim run --target bootloader
    
    • Build the FW of your node, and copy the .hex somewhere on your PC. Again for platformio:
    $ platformio -f -c vim run --target run
    

    Look in .pio/build/<board>/

    • Add the FW to MyController.org following the product manual

    • 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.
      0462bc1d-25ea-4082-bb57-8ef155feebec-image.png

    • Check Mycontroller.org or HomeAssitant, the FW is uploaded and a new node just popup!
      Party mode

    Enjoy!


  • Hero Member

    @MatiasV said in FOTA/MYSBootloader - Documentation enhacement - Make it clear that you must program only the MYSBootloader, without sketch:

    Platformio.org for building sketches and programming bootloaders
    Out of scope of this post, but way better than using Arduino. Totally worth the pain of learning it's basics.

    I'd be interested in hearing the full extent of your thoughts as to why you think platformio.org is better. Feel free to start a different thread if that's what you prefer.



  • @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:

    • Every project is a self contained directory, even the boards configuration, bootloaders, libraries, code and build procedure
      I have a project template for mysensors (mainly a platform.ini) that I copy for each node that I create.
    • I can manage everything with my known tools (vim, make, git, etc)

    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.


Log in to reply
 

Suggested Topics

  • 198
  • 4
  • 13
  • 9
  • 7
  • 73

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts