DualOptiboot Bootloader (Solved)


  • Hardware Contributor

    Hello Again,

    i am going crazy . . .where can i find the DualOptiboot Bootloader. I found the normal Optiboot, but i want to use OTA via seperate SPI Flash.

    I found this: https://github.com/mysensors/DualOptiboot

    But is doesnt work.

    Thanks!


  • Hardware Contributor


  • Hardware Contributor

    Jupp, i know this side, but i am looking dir the Hex File. Anyway i found it already.

    But my ota does Not work. Transfer Starts only if i Push Reset and after the Transfer nothing happens. I dont know if i Set up the Flash corect in my Sketch. Use pin 8 for cs. Bootloader is sensbrender Micro.


  • Admin

    Have you run basic tests against your flash, and checked that you are able to communicate with it? F. Ex with a test sketch, that tries to read the id of the flash.

    Next step would be to setup the mysensors sketch, with Ota enabled. I haven't used it myself yet, as I usually just go around to all nodes and reprogram them manually (even though they are sensebender micros with onboard flash)


  • Hardware Contributor

    Hey, thanks for Respons...

    how can i test it? I try this sketch but it is hanging around init. . .

    /*
      |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
      |                                                                Diagnostics.ino                                                                |
      |                                                               SPIFlash library                                                                |
      |                                                                   v 2.4.0                                                                     |
      |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
      |                                                                    Marzogh                                                                    |
      |                                                                  11.09.2016                                                                   |
      |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
      |                                                                                                                                               |
      |                                  For a full diagnostics rundown - with error codes and details of the errors                                  |
      |                                uncomment #define RUNDIAGNOSTIC in SPIFlash.cpp in the library before compiling                                |
      |                                             and loading this application onto your Arduino.                                                   |
      |                                                                                                                                               |
      |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
    */
    
    #include<SPIFlash.h>
    #include<SPI.h>
    
    #define WINBOND     0xEF
    #define MICROCHIP   0xBF
    
    char printBuffer[128];
    
    SPIFlash flash;
    
    void setup() {
      Serial.begin(115200);
      Serial.print(F("Initialising Flash memory"));
      for (int i = 0; i < 10; ++i)
      {
        Serial.print(F("."));
      }
      Serial.println();
      flash.begin();
      Serial.println();
      Serial.println();
    
      randomSeed(analogRead(A0));
      getID();
      diagnose();
    }
    
    void loop() {
    
    }
    
    
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Serial Print Functions~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
    
    void clearprintBuffer()
    {
      for (uint8_t i = 0; i < 128; i++) {
        printBuffer[i] = 0;
      }
    }
    
    void printLine() {
      Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"));
    }
    
    void printPass() {
      Serial.print(F("Pass"));
    }
    
    void printFail() {
      Serial.print(F("Fail"));
    }
    
    void printTab(uint8_t a, uint8_t b) {
      for (uint8_t i = 0; i < a; i++) {
        Serial.print(F("\t"));
      }
      if (b > 0) {
        Serial.print("||");
        for (uint8_t i = 0; i < b; i++) {
          Serial.print(F("\t"));
        }
      }
    }
    
    void printTime(uint32_t _wTime, uint32_t _rTime) {
      printTab(2, 1);
      printTimer(_wTime);
      printTab(2, 1);
      printTimer(_rTime);
    }
    
    void printTimer(uint32_t _us) {
    
      if (_us > 1000000) {
        float _s = _us / (float)1000000;
        Serial.print(_s, 4);
        Serial.print(" s");
      }
      else if (_us > 10000) {
        float _ms = _us / (float)1000;
        Serial.print(_ms, 4);
        Serial.print(" ms");
      }
      else {
        Serial.print(_us);
        Serial.print(F(" us"));
      }
    }
    

    I use AT25DF512C-SSHN-B


  • Admin

    Hangs around init, of which module?

    What does the serial output tell you in that sketch?

    There is one example here
    https://github.com/mysensors/MySensorsArduinoExamples/blob/master/libraries/SPIFlash/examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino


  • Hardware Contributor

    I found that Sketch now . . SPIFlash_ReadWrite.ino

    Start...Init FAIL!
    

    I use AT25DF512C-SSHN-B


  • Hardware Contributor


  • Hardware Contributor

    @scalz

    That works, i think πŸ˜‰

    Init OK!
    Start...Init OK!
    Flash content:
    0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.
    Erasing Flash chip ... DONE
    DeviceID: 0
    

    But OTA does not work . . .

    My Test-Sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * DESCRIPTION
     *
     * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
     * http://www.mysensors.org/build/temp
     */
    
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define MY_RF24_PA_LEVEL RF24_PA_MAX
    #define MY_BAUD_RATE 115200
    #define MY_NODE_ID 50
    #define MY_RF24_CHANNEL 105
    #define MY_OTA_FIRMWARE_FEATURE
    #define MY_OTA_FLASH_SS   8     // EEprom CS pin
    //#define OTA_WAIT_PERIOD 300
    
    //#define ATSHA204_PIN      12    // A3 Arduino Digital I/O pin number for ATSHA204A sot23 ic (for authentication)
    //#define MY_SIGNING_SOFT
    //#define MY_SIGNING_ATSHA204
    //#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}}
    //#define MY_SIGNING_REQUEST_SIGNATURES
    //#ifndef MY_SIGNING_SOFT_RANDOMSEED_PIN
    //#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
    //#endif
    //#ifndef MY_SIGNING_ATSHA204_PIN
    //#define MY_SIGNING_ATSHA204_PIN 17
    //#endif
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
    
    #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected 
    #define MAX_ATTACHED_DS18B20 16
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    bool receivedConfig = false;
    bool metric = true;
    // Initialize temperature message
    MyMessage msg(0,V_TEMP);
    
    void before()
    {
      // Startup up the OneWire library
      sensors.begin();
    }
    
    void setup()  
    { 
      // requestTemperatures() will not block current thread
      sensors.setWaitForConversion(false);
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Temperature Sensor", "1.1");
    
      // Fetch the number of attached temperature sensors  
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
         present(i, S_TEMP);
      }
    }
    
    void loop()     
    {     
      // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // query conversion time and sleep until conversion completed
      int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      //sleep(conversionTime);
    
      // Read temperatures and send them to controller 
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
    
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
    
        // Only send data if temperature has changed and no error
        #if COMPARE_TEMP == 1
        if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
        #else
        if (temperature != -127.00 && temperature != 85.00) {
        #endif
    
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature,1));
          // Save new temperatures for next compare
          lastTemperature[i]=temperature;
        }
      }
    }
    

    MYSController log Node 50:

    21.10.2016 12:25:37	NODE	New node discovered, node id=50
    21.10.2016 12:25:37	CHILD	New child discovered, node id=50, child id=internal
    21.10.2016 12:25:37	INFO	BL version=768
    21.10.2016 12:25:37	INFO	No FW assigned
    21.10.2016 12:25:37	RX	50;255;4;0;0;0A000200B004B6D30300
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=0,t=17,pt=0,l=5,sg=0:2.0.0
    21.10.2016 12:25:37	DEBUG	Update child id=255, type=ARDUINO_NODE
    21.10.2016 12:25:37	RX	50;255;0;0;17;2.0.0
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
    21.10.2016 12:25:37	TX	50;255;3;0;6;M
    21.10.2016 12:25:37	RX	50;255;3;0;6;0
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=ok:M
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=3,t=11,pt=0,l=18,sg=0:Temperature Sensor
    21.10.2016 12:25:37	RX	50;255;3;0;11;Temperature Sensor
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.1
    21.10.2016 12:25:37	RX	50;255;3;0;12;1.1
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=0,c=0,t=6,pt=0,l=0,sg=0:
    21.10.2016 12:25:37	CHILD	New child discovered, node id=50, child id=0
    21.10.2016 12:25:37	DEBUG	Update child id=0, type=TEMP
    21.10.2016 12:25:37	RX	50;0;0;0;6;
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=3,t=26,pt=1,l=1,sg=0:2
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=ok:1
    21.10.2016 12:25:37	RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=0,c=1,t=0,pt=7,l=5,sg=0:25.3
    

    If i assigning new FW, following in log, but nothing happens . . ..

    21.10.2016 12:28:43	INFO	FW "Test02" assigned to node 50
    21.10.2016 12:28:43	INFO	Send FW info to node 50: type=A, version=2, blocks=0x04B0, CRC=0xD3B6
    21.10.2016 12:28:43	TX	50;0;4;0;1;0A000200B004B6D3
    21.10.2016 12:28:43	RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=0,c=4,t=1,pt=6,l=8,sg=0,ft=0,st=ok:0A000200B004B6D3
    

  • Hardware Contributor

    OK . . . The Upload is successful right now, dont know why but it works.

    Now i have the Problem after transfer Data it stops at "Ongoing 100%" and nothing happens anymore. The Node needs Powercycle, Resetbutton has no effect.... (scalz Rollershutter HW)

    alt text


  • Hardware Contributor

    Works right now. . . my faulty was to flash the first Programm with the wrong Bootloader. 😑


  • Hardware Contributor

    why i told you to read the howto, because you would have burnt the right BL (sensebender in boards) πŸ˜‰
    great you got it working πŸ™‚


  • Hardware Contributor

    @scalz yahh i know. I dit but i dont found the right bootloader and arduinos ide folder structure is horrorbil.

    Btw.... On the nrf24 Layout you have to remove the pullup R14


  • Hardware Contributor

    @Takero
    why removing R14? then is avrspi still working?? it's a pull-up for CSN, and when you have multiple ic on SPI bus, it's good practice to have it, and avoid some dumb issue..it didn't work with R14?? perhaps..


  • Hardware Contributor

    I know but i had Trouble with the nrf is it pluged. I will try it again and give you a Feedback.


  • Hardware Contributor

    @scalz
    OK, tested with R14 again and it works πŸ‘

    Thanks again for the PCB and help!!


  • Hardware Contributor

    I does not work again . . . i dont know why 😞

    After Upload new Firmware, the device wont reboot and hanging in an bootloop.

    Log from MYSController:

    [2016-10-29 14:30:37.589 Info] RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=4,t=3,pt=6,l=22,sg=0,ft=0,st=ok:6400020001000C941F040C941F040C9409140C941F04
     [2016-10-29 14:30:37.602 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-0 s=255,c=4,t=2,pt=6,l=6,sg=0:640002000000
     [2016-10-29 14:30:37.612 Info] TX	50;255;4;0;3;6400020000000C94F7030C94A3190C947C190C941F04
     [2016-10-29 14:30:37.622 Info] RX	50;255;4;0;2;640002000000
     [2016-10-29 14:30:37.641 Info] RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=4,t=3,pt=6,l=22,sg=0,ft=0,st=ok:6400020000000C94F7030C94A3190C947C190C941F04
     [2016-10-29 14:30:40.031 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
     [2016-10-29 14:30:40.046 Info] RX	0;255;3;0;9;TSP:MSG:BC
     [2016-10-29 14:30:40.060 Info] RX	0;255;3;0;9;TSP:MSG:FPAR REQ (sender=50)
     [2016-10-29 14:30:40.069 Info] RX	0;255;3;0;9;TSP:CHKUPL:OK
     [2016-10-29 14:30:40.077 Info] RX	0;255;3;0;9;TSP:MSG:GWL OK
     [2016-10-29 14:30:40.576 Info] RX	0;255;3;0;9;!TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0
     [2016-10-29 14:30:40.594 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
     [2016-10-29 14:30:40.606 Info] RX	0;255;3;0;9;TSP:MSG:BC
     [2016-10-29 14:30:40.615 Info] RX	0;255;3;0;9;TSP:MSG:FPAR REQ (sender=50)
     [2016-10-29 14:30:40.624 Info] RX	0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
     [2016-10-29 14:30:40.633 Info] RX	0;255;3;0;9;TSP:MSG:GWL OK
     [2016-10-29 14:30:40.643 Info] RX	0;255;3;0;9;TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=ok:0
     [2016-10-29 14:30:40.653 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
     [2016-10-29 14:30:40.662 Info] RX	0;255;3;0;9;TSP:MSG:BC
     [2016-10-29 14:30:40.673 Info] RX	0;255;3;0;9;TSP:MSG:FPAR REQ (sender=50)
     [2016-10-29 14:30:40.682 Info] RX	0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
     [2016-10-29 14:30:40.692 Info] RX	0;255;3;0;9;TSP:MSG:GWL OK
     [2016-10-29 14:30:40.774 Info] RX	0;255;3;0;9;!TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0
     [2016-10-29 14:30:40.784 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
     [2016-10-29 14:30:40.794 Info] RX	0;255;3;0;9;TSP:MSG:BC
     [2016-10-29 14:30:40.806 Info] RX	0;255;3;0;9;TSP:MSG:FPAR REQ (sender=50)
     [2016-10-29 14:30:40.815 Info] RX	0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
     [2016-10-29 14:30:40.825 Info] RX	0;255;3;0;9;TSP:MSG:GWL OK
     [2016-10-29 14:30:41.089 Info] RX	0;255;3;0;9;!TSP:MSG:SEND 0-0-50-50 s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=fail:0
     [2016-10-29 14:30:41.110 Info] RX	0;255;3;0;9;TSP:MSG:READ 50-50-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
     [2016-10-29 14:30:41.120 Info] RX	0;255;3;0;9;TSP:MSG:BC
     [2016-10-29 14:30:41.129 Info] RX	0;255;3;0;9;TSP:MSG:FPAR REQ (sender=50)
     [2016-10-29 14:30:41.139 Info] RX	0;255;3;0;9;TSP:CHKUPL:OK (FLDCTRL)
     [2016-10-29 14:30:41.148 Info] RX	0;255;3;0;9;TSP:MSG:GWL OK
    
    

    Any Tips?


Log in to reply
 

Suggested Topics

7
Online

11.4k
Users

11.1k
Topics

112.7k
Posts