bootloader



  • Hi
    I see in the git repo that there are 2 bootloaders:
    Bootloader
    MYSBootloader
    Do I need to burn one of them to use MySensors ?


  • Admin

    Yes, the MYSBootloader is smaller and has been tested more recently by @tekka.



  • @hek said:

    Yes, the MYSBootloader is smaller and has been tested more recently by @tekka.

    But in boards.txt I see its configured for 16mhz crystal , and I read here that to get maximum battery time one need to use 8mhz and configure the boards,txt accordingly.


  • Admin

    @Mickey Yes, however, the .hex file was compiled for 16Mhz, but you can also use it at 8Mhz. Ideally you re-compile the bootloader with your preferred frequency. I'm using the MYSBootloader at 1Mhz intRC for battery-powered sensors. You can test the OTA functionality with MYSController.



  • @tekka said:

    @Mickey Yes, however, the .hex file was compiled for 16Mhz, but you can also use it at 8Mhz. Ideally you re-compile the bootloader with your preferred frequency. I'm using the MYSBootloader at 1Mhz intRC for battery-powered sensors. You can test the OTA functionality with MYSController.

    OK Its keeps getting complicated...thanks for your answer but I really would like to clear things so I can start with Mysensors, I quite familiar with arduino+nrf24 but mainly with rf24network librery from MANIACBUG - http://iot.org.il/2014/04/06/iot-smart-home-2/
    So to make things straight:
    1.I start with MYSController on my pc.
    2.I put gw sketch on arduino nano with radio module ( does it also need customized bootloader - MYSBootloader?! ) .
    3. take arduino pro mini 3,3v (without regulator and leds) go to bootloader folder in the MYSController and flash it with the MYSBootloader.hex file with USBasp Programmer.
    do I need to change something in the boards.txt that came with the MYSController folder if I want to use the external 8mhz on the pro mini board? and if I want to use the internal one than what do I need to change in this file? is the 115200 rate will stand with the external 8mhz? If not to what do I need to change it? and if the internal one will be used what need to be change in the boards.txt ? and just wondering what is the fuses.txt file is for?
    4. after the bootloader flashed I put a sketch on the node and all will go automatic? including the id designation?(I used the motion sensor example).
    thanks for the answers and for the Patience and with the hope it will get me started and I could contribute too...


  • Admin

    @Mickey

    Sorry, I might have misinterpreted your initial question.

    The bootloader is NOT needed if you download sketch/node code from your computer.

    If you want to do over-the-air updates of your nodes you'll need it though.



  • @hek said:

    @Mickey

    Sorry, I might have misinterpreted your initial question.

    The bootloader is NOT needed if you download sketch/node code from your computer.

    If you want to do over-the-air updates of your nodes you'll need it though.

    OK I would like to do OTA, is what I wrote in the answer to tekka OK? to make brownout lower for 1.8-2.4 I will also need to burn new bootloader right?


  • Admin

    For completeness, here are the MYSBootloader instructions for OTA updates via MYSController:

    1. Load gw sketch and connect arduino either via serial or ethernet port. No special bootloader needed for that part (i.e. standard optiboot bootloader will do the job).

    2. Add these lines to the boards.txt file in your Arduino IDE installation folder (located somewhere like C:/Program Files/Arduino/hardware/arduino/avr)

      proMYSBL16.name=ATmega328 external 16Mhz with MYSBootloader
      proMYSBL16.upload.tool=avrdude
      proMYSBL16.upload.protocol=arduino
      proMYSBL16.upload.maximum_size=30720
      proMYSBL16.upload.maximum_data_size=2048
      proMYSBL16.upload.speed=115200
      proMYSBL16.bootloader.tool=avrdude
      proMYSBL16.bootloader.low_fuses=0xF7
      proMYSBL16.bootloader.high_fuses=0xDA
      proMYSBL16.bootloader.extended_fuses=0x06
      proMYSBL16.bootloader.unlock_bits=0x3F
      proMYSBL16.bootloader.lock_bits=0xFF
      proMYSBL16.bootloader.file=MySensors/MYSBootloader.hex
      proMYSBL16.build.mcu=atmega328p
      proMYSBL16.build.f_cpu=16000000L
      proMYSBL16.build.board=AVR_UNO
      proMYSBL16.build.core=arduino
      proMYSBL16.build.variant=standard

      ######## settings for 8Mhz internal clock

      proMYSBL8.name=ATmega328 internal 8Mhz with MYSBootloader
      proMYSBL8.upload.tool=avrdude
      proMYSBL8.upload.protocol=arduino
      proMYSBL8.upload.maximum_size=30720
      proMYSBL8.upload.maximum_data_size=2048
      proMYSBL8.upload.speed=57600
      proMYSBL8.bootloader.tool=avrdude
      proMYSBL8.bootloader.low_fuses=0xE2
      proMYSBL8.bootloader.high_fuses=0xDA
      proMYSBL8.bootloader.extended_fuses=0x06
      proMYSBL8.bootloader.unlock_bits=0x3F
      proMYSBL8.bootloader.lock_bits=0xFF
      proMYSBL8.bootloader.file=MySensors/MYSBootloader.hex
      proMYSBL8.build.mcu=atmega328p
      proMYSBL8.build.f_cpu=8000000L
      proMYSBL8.build.board=AVR_UNO
      proMYSBL8.build.core=arduino
      proMYSBL8.build.variant=standard

    3. Copy MYSBootloader.hex (from MYSController/Bootloader folder) to the Arduino IDE installation folder C:/Program Files/Arduino/hardware/arduino/avr/bootloaders/MySensors/

    4. Restart Arduino IDE, choose under Tools | Board | ATmega328 external 16Mhz with MYSBootloader or Tools | Board | ATmega328 internal 8Mhz with MYSBootloader depending on your settings

    5. Connect USBasp to sensor node and select Tools | Burn Bootloader

    6. If everything worked well until here, you now have the MYSBootloader with the fuse settings from above burnt to your sensor node (16Mhz extXTAL or 8Mhz intRC, BOOTSZ 1024W, BOD 1V8).

    7. Please use the AVR fuse calculator to retrieve the individual fuse settings. If you need to change frequency, BOD or other settings, change the fuse settings based on the fuse calculator.
      Important: The MYSBootloader.hex file was compiled for 16Mhz oscillators but it should also work at 8Mhz. If you intend to go below 8Mhz, I highly recommend to compile the bootloader with adjusted frequency settings.

    8. Start MYSController, hit config and adjust settings (COM-Port & baud or IP address:port)

    9. Hit connect: Connection to gateway should be established (gateway answers with gateway ready message), the node should appear and request an ID & FW.

    10. Right-mouse click on that node, select assign FW, choose for example **TimeReporter ** (demo firmware included in the MYSController/Firmware folder). Then click reboot and wait until FW is uploaded and node boots.

    11. TimeReporter firmware reports every few seconds some values such as time, millis, and voltage.

    12. Custom firmware: compile your sketch and retrieve the generated .hex file (activate verbose mode in the Arduino IDE to get compiler messages and output path).

    13. Copy .hex file to MYSController/Firmware folder and edit firmware_config.csv file according to the existing lines.

    14. Hit Refresh Repo in MYSController and the newly copied firmware should appear in the Assign FW dropdown list, ready to be uploaded.

    Have fun 🙂



  • Thanks a lot...
    I already create a MYSController and GW + 2 NODES but your explanation made things much clearer especially the OTA part.
    Do you plan to publish MYSController source?

    and again I really appreciate the detailed step by step guide.


  • Plugin Developer

    @tekka
    thanks for providing the steps to upload the MSYbootloader..
    any idea why i'm getting following error in linking phase

    "avr-gcc" -Os -nostartfiles -Wl,-s -Wl,-static -Wl,-Map=".map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mrelax -Wl,-section-start=.text=0x7800 -mmcu=atmega328p -o MYSBootloader.elf MYSBootloader.o -lm
    MYSBootloader.o: In function main': MYSBootloader.c:(.init9+0x288): undefined reference to __boot_page_erase_short'
    MYSBootloader.c:(.init9+0x2b8): undefined reference to __boot_page_fill_short' MYSBootloader.c:(.init9+0x2d6): undefined reference to __boot_page_write_short'
    MYSBootloader.c:(.init9+0x2e0): undefined reference to `__boot_rww_enable_short'
    collect2: error: ld returned 1 exit status
    make: *** [MYSBootloader.elf] Error 1

    not sure which library to include to resolve the issue.


  • Admin

    @Dheeraj These are the code and cycle-optimized versions of the standard boot.h library which can be found here.
    Alternatively, substitute these calls:

    __boot_page_erase_short() ==> boot_page_erase()

    __boot_page_fill_short() ==> boot_page_fill()

    __boot_rww_enable_short() ==> boot_rww_enable()



  • @tekka
    Goodmorning i've got a question:
    Isn't it possible to write a Boards.txt for al boards? or does someone have this allready.
    I tried to load the bootloader in a Arduino Uno (CH340 interface) but this didn't function.
    It would be nice to load it in:
    Arduino Mega 2560
    Arduino Uno (official)
    Arduino Uno (CH340) chinees clone
    Arduino mini
    Arduino nano
    Arduino micro
    etc.


  • Admin

    @MarkV I'm not sure I understand your question - bootloaders are programmed via the ISP interface (e.g. USBasp or ArduinoISP as programmer), not via serial/usb interface.



  • @tekka
    Thanks for the replay.
    I ment i trying to load the boatloader into a arduino pro mini (clone) through a Arduino (as ISP) Mega 2560.
    When i try to upload the boatloader i'm getting this error:

    avrdude: Yikes!  Invalid device signature.
             Double check connections and try again, or use -F to override
             this check.
    
    Fout bij het branden van de bootloader.
    

    What's wrong and what should i change?



  • @MarkV I had this message two days ago as well. I was programming with usbasp. I have solved it by powering my pro mini with a separate power supply. So please check the cables.



  • @dynamite
    Oh thanks, will do that. .
    But why does it giveel this message.. i wouldn't link this message to a failty powernapp supply..



  • @MarkV Dont't know, it helped in my case. Whether it was actually the power supply is the question. But if it helps in your case as well, than most probably yes. I think it has something to do with the communication and it reads a faulty or no signature.



  • @dynamite
    tryed it and got a other error report:

    avrdude: Expected signature for ATmega328P is 1E 95 0F
             Double check chip, or use -F to override this check.
    Verkeerde microcontroller gevonden. Hebt u het correcte board geselecteerd in het menu Hulpmiddelen > Board?
    

    What now?



  • @MarkV This is exactly the message I have received as well... Maybe check the other connection. Replace some cables? I the end I have been able to eliminate this message without changing anything in the software. In my case it was hardware related. (I was programming a pro mini and had it with two seperate mini's)



  • I've got it duss far.. Stupid me, i've forgot to change the reset pin from 10 to 53.
    After that it says ready with uploading the bootloader..
    Now i'm going to test it to see if it worked...



  • Hi,

    I'm trying to burn 16Mhz version but I get the following error at the end:

    avrdude: verification error, first mismatch at byte 0x0000
             0x3f != 0xff
    

    Programmer: Usbasp



  • @Mayank-Raichura I had the same problem with usbasp. The fix was to remove the -D flag (disable auto erase) when running avrdude.



  • @Redferne Thanks. I'll check it out.


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 3
  • 4
  • 6
  • 2

37
Online

11.4k
Users

11.1k
Topics

112.7k
Posts