Arduino pro mini dead after flashing MYSbootloader.



  • After flashing node with MySensors bootloader i can still flash the node with ftdi but sketch no longer runs. Tried it with blink sketch. Does uploading the bootloader alter the fuses? I dont know whats going on ๐Ÿ˜“

    when plugged into my board the led on the arduino just stays on, when i pull the pro mini out of the board and reset (while connected to ftdi) it blinks in cycles of 3x slow and 4x fast. As soon as i insert it in the node it goes to steady on. I know the board is good because a board with factory bootloader runs the sketch just fine. Can someone shine a (led)light๐Ÿ˜‰ on this

    When i flash the original bootloader again everything works as expected. What am i missing here?


  • Mod

    @jimmy-loyens maybe the size of the bootloaders is different and therefore requires different bootloader area configuration?
    The size is defined by fuses btw.



  • @yveaux sorry but "huh?" ๐Ÿ˜ฒ

    This is my first time trying ota, before i knew about the existance of bootloaders but thats about it. Dont meen to offend you but could you elaborate a bit



  • @jimmy-loyens ok found this: https://forum.arduino.cc/index.php?topic=70208.0

    Now i only need to find out how big my bootloader is. I assume the size of the hex file.



  • @jimmy-loyens Ok problem,
    My bootloader hex is 6Kb = 6000b = 3000 words

    BOOTZ1|BOOTZ0
    11=>256words = 512b
    10=>512words = 1024b
    01=>1024words = 2048b
    00=>2048words = not enough๐Ÿ˜• ๐Ÿ˜”

    Am i understanding this correct?

    Choosing the largest bootzone combination (11) didn't help ๐Ÿ˜ž



  • I found this on the forum:
    "In the process of troubleshooting I found out that MYSBootloader needs to be compiled with the same channel settings as the gateway it connects to. "

    I think this is most likely the problem since i'm currently using a test-network with channel 5. I'll try changing the channel in the bootloader source and recompiling it.


  • Mod

    @jimmy-loyens said in Arduino pro mini dead after flashing MYSbootloader.:

    Dont meen to offend you but could you elaborate a bit

    Yes I could, but you found out by yourself ๐Ÿ‘
    Now you learned something new today ๐Ÿ˜‰



  • @yveaux do you know what development ide i have to use to compile the bootloader? i cant find anything with google on this. I allready found where to change the RF channel in the source but i have no idea how to compile it into a hex file. Tried vs code but i probably have to install another extention


  • Mod

    @jimmy-loyens if you get enough help from people to manage building the bootloader, it would be fantastic if you could take some notes and share so we can publish a first version of a guide. I am curious myself and would like to try, and I've seen some questions in the forum earlier so it seems more people are interested.

    I did a quick test, and it seems running make all is sufficient, provided that all tools are in the "right" place.
    This was the result I got:

    Micke @ Quasi ~/workspace/MySensorsBootloaderRF24 development
    $ make all
    rm *.o
    rm: cannot remove '*.o': No such file or directory
    make: [Makefile:44: clean] Error 1 (ignored)
    rm *.elf
    rm: cannot remove '*.elf': No such file or directory
    make: [Makefile:45: clean] Error 1 (ignored)
    rm *.hex
    rm: cannot remove '*.hex': No such file or directory
    make: [Makefile:46: clean] Error 1 (ignored)
    "/cygdrive/c/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc" -I"/cygdrive/c/Program Files (x86)/Arduino/hardware/tools/avr/avr/include/avr" -funsigned-char -funsigned-bitfields -DF_CPU=16000000L -DBAUD_RATE=115200 -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -Wall -Wextra -Wundef -pedantic -mmcu=atmega328p -c -std=gnu99 -MD -MP -MF "MYSBootloader.d" -MT"MYSBootloader.d" -MT"MYSBootloader.o"  MYSBootloader.c -o MYSBootloader.o
    In file included from Core.h:40:0,
                     from MYSBootloader.c:81:
    HW.h:51:4: warning: #warning is a GCC extension
       #warning BAUD_RATE error greater than 2%
        ^
    HW.h:51:4: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
    In file included from Core.h:45:0,
                     from MYSBootloader.c:81:
    MySensorsBootloader.h:59:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
     static bool inline sendMessage(void) {
     ^
    "/cygdrive/c/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc" -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
    "/cygdrive/c/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-objcopy" -O ihex -R .eeprom MYSBootloader.elf MYSBootloader.hex
    "/cygdrive/c/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-size" MYSBootloader.elf
       text    data     bss     dec     hex filename
       2032       6      71    2109     83d MYSBootloader.elf
    Micke @ Quasi ~/workspace/MySensorsBootloaderRF24 development
    $ file MYSBootloader.elf
    MYSBootloader.elf: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, stripped
    Micke @ Quasi ~/workspace/MySensorsBootloaderRF24 development
    $ ls -l MYSBootloader.elf
    -rwxrwxr-x+ 1 Micke None 2480 Jan 24 21:59 MYSBootloader.elf
    


  • @mfalkvidd what software did you use for this? (I'm on win10 pc, not linux) I'm downloading avr studio right now, dont know if its possible with this software. I have never done anything like this. But hey there is a first time for everything.๐Ÿ˜

    I have read on the forum and github that @Guillermo-Schimmel has successfully compiled the MYSbootloader for 8MHz. I'll try asking him for some clues.



  • @jimmy-loyens https://github.com/guillebot/MYSensors-Bootloaders

    The bootloader for all the channels, in 1, 8 and 16MHz flavor.



  • @mfalkvidd Compiling the bootloader in a linux machine is as easy as running make, given than you have devel tools and avr-gcc installed.



  • @guillermo-schimmel wow thanks alot, saves me alot of searching and work. Thanks


  • Mod

    @jimmy-loyens I am using Windows 7 (with cygwin). I didn't need Atmel Studio, I used avr-gcc provided by the Arduino IDE.



  • Now i used the 8MHz external Xtal bootloader for RFchannel 5 (GW is on channel 5) that i got from @Guillermo-Schimmel (thanks again) to flash onto my arduino pro mini using avrdudess (less hassle with editing boards.txt file of arduinoIDE), but still same result.

    I think mr bootloader is working though because the onboard led of the node behaves like this:

    (node power on) 10101-000000000000000000-10101-0-
    1111111111111111111111-0-1111111111111111111111-0-1111111111111111111111-0-1111111111111111111111-0-...
    (GW online)-11111111111111111111111111111111111111111111111111111111111111111111...
    

    So as long as GW is not online the led stays on for long period then goes off for very short period (i think its looking for the gateway), once GW comes online the onboard led of the node stays on (node has seen gateway online). If i unpower the GW at this point the node onboard led stays on until i reset node.

    It looks like the bootloader is working and detects the GW comming online, but for some reason it doesnt jump on to the programmemory.

    I have the node programmed with mysensors sketch on RFchannel 5 and GW with mqtt client on RF-channel 5. Added "#define MY_OTA_FIRMWARE_FEATURE" for both node and GW (even though i think its not nessecairy for the GW). are there any other defines i should add to the sketch(es)?

    @Guillermo-Schimmel I have some more questions for you:
    -Where the bootloaders compiled with the standard spi pins, being: "#define SPI_PINS_CE9_CSN10"
    -It says in the make file on github (MYSbootloader): "ISP_EFUSE = 06" but I cant seem to set the E fuse like this. For me only possible values are: F8/F9/FA/FB/FC/FD/FE/FF (this is probably not the problem because this only sets brown-out bits, just curious)
    -Did you allso have this problem when starting to use MYSbootloader

    I'll keep trying and searching ๐Ÿ˜„ ๐Ÿค” ๐Ÿค“

    Maybe another channel will help.



  • @jimmy-loyens Ok, this answers the question about the E fuse:
    "
    That's why :

    0x06 = 00000110
    0xFE = 11111110
    are doing the same job for the extended fuse. It depends of the tool you use for burning this fuse. Simply, if you get this warning, use the "equivalent".
    "



  • @jimmy-loyens Seems like i didn't need to add the define:

    "@tlustoch You need to enable MY_OTA_FIRMWARE_FEATURE only if you use DualOptiBoot.
    With MYSBootloader, you don't need ๐Ÿ˜‰

    I use MYSBootloader 1.3 pre-release with mysensors 2.0. You can find it here : https://forum.mysensors.org/topic/3453/mysbootloader-1-3-pre-release-myscontroller-1-0-0beta

    And yes it usable with 8 MHZ internal clock config if you burn the bootloader with 8Mhz internal clock setting."

    EDIT:
    Removing "MY_OTA_FIRMWARE_FEATURE" was not the solution



  • Ok, update:

    When i look in MYController under "status=>resources logs" i can see the node continuously requesting firmware config, so i'm 100% shure the bootloader is good. I'm just not shure what's supposed to happen now from my side. I tried uploading firmware to the node OTA using "resources=>nodes=>actions=>upload firmware" but this doesn't seem to succeed and doesn't show up in the resources logs.

    But atleast i have some new queries to google ๐Ÿ˜ ๐Ÿ˜‰

    0_1548413584026_mycontroller.png

    In MQTT.fx I can allso see the node constantly sending: "mygateway1-out/1/255/4/0/0 FFFFFFFF68057A890103"
    But if i see this correctly this would mean for node1 child255 Cmd=stream(OTA) Ack=0 Type=0(Dont know what 0 is in stream)

    Strange because my node has nodeID 107.๐Ÿค”

    Ok on closer inspection i can see in the resources log that the firmware config request comes from node1, so i tried updating firmware OTA of node 1, now i get a firmware config response inresources log.

    UPDATE:
    loaded the program back onto the node (changed batery level child from 0 to 255). Now node shows up with correct node ID in mycontroller. And now i get some output in serial monitor too, wich wasn't the case before.



  • And BOOM it works!!!! ๐Ÿ˜ ๐Ÿ˜‹

    I just did my first FOTA update๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘

    Thanks to everyone who helped



  • @jimmy-loyens Great!

    I have to say that the work done with the bootloader and mysensors is really good.

    It is very nice when FOTA starts working.



  • @guillermo-schimmel Yes indeed, no more running around with laptop and cables ๐Ÿ‘Œ ๐Ÿ‘

    Thanks again for the help and the bootloaders


  • Mod

    Great work @jimmy-loyens

    Since you now have a working system, would you mind writing down what was needed? I think you are in a good position to describe things so a newbie (like myself, at least when it comes to ota) can understand? Maybe something that can make https://www.mysensors.org/about/fota easier.



  • @mfalkvidd said in Arduino pro mini dead after flashing MYSbootloader.:

    Great work @jimmy-loyens

    Since you now have a working system, would you mind writing down what was needed? I think you are in a good position to describe things so a newbie (like myself, at least when it comes to ota) can understand? Maybe something that can make https://www.mysensors.org/about/fota easier.

    I will send you some little things to improve it:

    1. MYSBootloader uses channel 76 by default. To change the channel, a new bootloader must be compiled.

    Feel free to post my github project "https://github.com/guillebot/MYSensors-Bootloaders"

    I will keep updated the different channel versions and probably will upload my script and some info about compiling them.



    Arduino IDE 1.6.x installed
    Mysensors lib > 1.5.x installed

    You should probably update that to 1.8.8 and 2.3.1. It is not allways related to FOTA but it is allways better to stay updated.



    1. I would recommend to burn the bootloader with AVRDUDESS, not only the fuses. I had better luck with avrdudess than with arduino ide.

    At least show that you can do that (use Arduino ide OR AVRDUDESS)



  • @mfalkvidd I will rty to write some stuff down but some details i'm not sure off myself so it would be nice if other people can revieuw the text for errors or inaccuracies. Do I just put it down here on the forum or in a file?

    @Guillermo-Schimmel can i refer to your github page with bootloader flavors?



  • From Mysensors FOTA site:

    1)Keep this file opened and close Arduino ide (otherwise your changes will be erased).
    2)In preferences.txt, at the end, add this
    build.path=C:\Arduino-Output
    or another preferred path. That will be the output folder for your .hex compiled sketch files. Close the dialog box.

    I noticed that file gets reset to default (meaning added line disappears from file) on opening arduinoIDE!!!!โ˜น ๐Ÿ˜– ๐Ÿ˜ณ

    Has anyone else noticed this? Does anyone know how to remedy this?



  • This post is deleted!


  • @mfalkvidd
    Only for MYSbootloader

    First off know that the bootloader needs to be compiled for the right clock-mode (internal osc/RC-osc/Xtal) and for the RF channel the node is going to be used in. You can build your own bootloader from the source at https://github.com/mysensors/MySensorsBootloaderRF24 or use a precompiled bootloader from https://github.com/guillebot/MYSensors-Bootloaders with thanks to @Guillermo-Schimmel .

    Next make sure you have the right driver for the USBASP installed. Like the video on https://www.mysensors.org/about/fota suggests use Zadig (https://zadig.akeo.ie/) for this. The driver may be dependent on your operating system (I'm using Win10 and libusbK (v3.0.7.0) works for me). If u use the wrong driver it may be possible to read and write the fuses but burning the bootloader will fail!

    Make sure you are using the right fuses for your board. If not you may even potentially brick your board (i.e. if you dont have a Xtal on your board and use the internal oscillator but do burn the fuses to use a Xtal you will have to solder a Xtal to your board to reflash the right fuses because otherwise the ยตC wont have a clocksource)[not sure if this is 100% correct] If you don't know how to set the fuses correctly for your board use a fuse calculator like this http://www.engbedded.com/fusecalc/. If you dont know the meaning of some of the fuses you can look them up in the datasheet of ATmega328P.

    Now you can open AVRDUDESS to first check the connection of yourUSBASP and then burn the fuses. First connect your board to USBASP and click on detect. AVRDUDESS should indicate the MCU is a ATmega328p (even if its a arduino clone). You can either burn your fuses seperately by filling them in in the "fuses and lockbits" frame and clicking write (leave the lockbits alone or you might brick your MCU) or burn them together with your bootloader (if you use AVRDUDESS for bootloader) by filling in the bits and ticking the set fuses box. When burning the bootloader the fuses will be burnt first.

    For burning the bootloader you have 2 options. You can either burn the bootloader using the arduinoIDE like explained in the video but i prefer using AVRDUDESS (less hassle with editing the boards.txt file and adding the bootloaders to the right arduino directory). To burn the bootloader with AVRDUDESS just drag and drop the right bootloader into the "flash" textbox of AVRDUDESS, make shure the radio button for write is active and hit go. Tadaa!!! the bootloader is burnt.

    Now you can program your board (the good oldfashioned way) with a MySensors sketch using the same RF-channel as the bootloader. Make shure your gateway is allso programmed with the same RF-channel as the first thing the node (bootloader) does after booting is connecting to the gateway. This means your gateway needs to be online before the node can execute its sketch [pretty shure about this but not completely It will take the MYSbootloader a little longer to run then the stock bootloader so don't panic when you don't see anything in serial monitor at first, it should be coming.
    ==> With mys bootloader burnt its no longer possible to program node in "the old fashioned way" (using arduino IDE and serial connection). All updates must be made OTA!

    When you get output in serial monitor its time to install MYController (not the same as MYSController!). You can start the service by running "mycontroller/bin/start.bat" on windows or entering "./start.sh" on linux. Here is a (outdated) doc on MYController https://www.mycontroller.org/#/documents/user/1.4.0.Final.html. Now open a browser and go to deviceIP:8443 and log in to MYController with username:admin, password:admin. Under resources=>gateway enter the gateway setup you use for MySensors, and be shure to select MySensors under network type. Now you can enable your gateway in the table, select it and go to actions in the top right. There select discover. Now your nodes should be discovered automaticly. You can check this by looking under resources=>nodes. If not you can look under status=>resource logs to debug what's going on.

    To be able to do FOTA updates you need a .hex file of your sketch. You can do this by adding "build.path=C:\Arduino-Output" to the bottem of your arduino "preferences.txt" file (see https://www.mysensors.org/about/fota)[but this file seems to be deleted every time arduino starts!], load the desired sketch in the arduinoIDE, make shure the right board is connected and click verify. Now the .hex file should be in your C:\Arduino-Output\ folder.

    Now the part we've all been waiting for, the FOTA update! Under utilities=>firmware on the top right select "types" and add a type of node, then select version and add a version. After this you can select firmware and choose a hex file you compiled earlier. Go back to resources=>nodes, select your node you want to update, click actions=>edit. Here you can appoint a firmware, type and version to your node. hit save! Back in the nodes window select the same node go to actions=>upload firmware. Your first FOTA update should be underway.



  • @jimmy-loyens stuff in itallics i'm not absolutely shure about or are remaining problems. Anyone feel free to add or correct anything๐Ÿ˜

    While writing this tutorial my node went offline ๐Ÿ˜’ ๐Ÿ˜•
    So it might be i have to add some more to the tutorial lateron ๐Ÿ˜† ๐Ÿ˜
    Seems to be a problem with MYController because i can still see node trying to communicate over mqtt.

    I see its my sh***ty router acting up again, even my internet went down just now.๐Ÿ˜ซ ๐Ÿ˜ญ

    It seems that somehow the firmware on my node got corrupted, when connecting it to a serial monitor it didn't output anything. When looked on MQTT.fx at the messages node and GW where continiously exchanging "stream messages. Then i flashed the node the oldfashioned way and now its all up again. Still trying to find out what happened exactly.


Log in to reply
 

Suggested Topics

75
Online

11.4k
Users

11.1k
Topics

112.7k
Posts