Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. bootloader

bootloader

Scheduled Pinned Locked Moved Development
bootloaderfirmwareotg
23 Posts 8 Posters 15.5k Views 10 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tekkaT tekka

    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 :)

    D Offline
    D Offline
    Dheeraj
    Plugin Developer
    wrote on last edited by
    #10

    @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.

    tekkaT 1 Reply Last reply
    0
    • D Dheeraj

      @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.

      tekkaT Offline
      tekkaT Offline
      tekka
      Admin
      wrote on last edited by
      #11

      @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()

      1 Reply Last reply
      0
      • tekkaT tekka

        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 :)

        M Offline
        M Offline
        MarkV
        wrote on last edited by MarkV
        #12

        @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.

        tekkaT 1 Reply Last reply
        0
        • M MarkV

          @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.

          tekkaT Offline
          tekkaT Offline
          tekka
          Admin
          wrote on last edited by
          #13

          @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.

          M 1 Reply Last reply
          0
          • tekkaT tekka

            @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.

            M Offline
            M Offline
            MarkV
            wrote on last edited by
            #14

            @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?

            1 Reply Last reply
            0
            • dynamiteD Offline
              dynamiteD Offline
              dynamite
              wrote on last edited by dynamite
              #15

              @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.

              M 1 Reply Last reply
              0
              • dynamiteD dynamite

                @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.

                M Offline
                M Offline
                MarkV
                wrote on last edited by MarkV
                #16

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

                dynamiteD 1 Reply Last reply
                0
                • M MarkV

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

                  dynamiteD Offline
                  dynamiteD Offline
                  dynamite
                  wrote on last edited by
                  #17

                  @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.

                  M 1 Reply Last reply
                  0
                  • dynamiteD dynamite

                    @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.

                    M Offline
                    M Offline
                    MarkV
                    wrote on last edited by
                    #18

                    @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?

                    dynamiteD 1 Reply Last reply
                    0
                    • M MarkV

                      @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?

                      dynamiteD Offline
                      dynamiteD Offline
                      dynamite
                      wrote on last edited by
                      #19

                      @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)

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        MarkV
                        wrote on last edited by
                        #20

                        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...

                        1 Reply Last reply
                        0
                        • Mayank RaichuraM Offline
                          Mayank RaichuraM Offline
                          Mayank Raichura
                          wrote on last edited by
                          #21

                          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

                          RedferneR 1 Reply Last reply
                          0
                          • Mayank RaichuraM Mayank Raichura

                            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

                            RedferneR Offline
                            RedferneR Offline
                            Redferne
                            wrote on last edited by
                            #22

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

                            Mayank RaichuraM 1 Reply Last reply
                            0
                            • RedferneR Redferne

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

                              Mayank RaichuraM Offline
                              Mayank RaichuraM Offline
                              Mayank Raichura
                              wrote on last edited by
                              #23

                              @Redferne Thanks. I'll check it out.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              13

                              Online

                              11.7k

                              Users

                              11.2k

                              Topics

                              113.1k

                              Posts


                              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • MySensors
                              • OpenHardware.io
                              • Categories
                              • Recent
                              • Tags
                              • Popular