M4 Sketch START failed: reboot system !

Discussion in 'UDOO NEO' started by Maurice, Nov 6, 2016.

  1. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Today I keep getting the following error:

    Address: 192.168.7.2
    Port: 5152
    UDOONeo 111256 bytes sent
    UDOONeo M4 Sketch START failed: reboot system !

    After I reboot the Neo, it works for a few deploys, then fails again.
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Are you doing something special in the sketch? There was another case here lately that had something to do with the sketch preventing from start it on the M4.
     
  3. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
  4. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Well, nothing special I thought. Just PWM'ing some leds. Maybe it was a programming fault in the program somewhere. Don't know.
     
  5. Francesco

    Francesco Active Member

    Joined:
    Jun 23, 2015
    Messages:
    220
    Likes Received:
    110
    Hi, please post the full sketch.
     
    Andrea Rovai likes this.
  6. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    @Francesco, I'm sorry, I don't have that sketch anymore. I guess it was a programming error like @waltervl suggested.
     
    Andrea Rovai likes this.
  7. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    Yes, it's exactly what I told here (http://www.udoo.org/forum/threads/how-to-refresh-a-sketch.6145/); that's why It was usefull a RST pin to stop the sketch at least.
    I've worked with Udoo since 10 days with a complex sketch that reads multiple sensors.

    I discovered that:
    - If the sketch is in a delay()
    - If the sketch is in a busy waiting (while(1){} in order to wait an interrupt)
    - If the sketch hangs for some reason/bug/wrong serial print..

    I ALWAYS have to rm the m4 file, reboot, wait for reconnection...
    Sometimes It happened that MCC minicom reader hangs, so I had to exit ssh, reset manually UDOO, wait for reconnection, rm the m4 file, reboot, wait for reconnection again and upload the sketch.
     
    Maurice likes this.
  8. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    @Gorgo @Maurice Could you please send us some sketch that gave you this issue? We will examine them and try to find and fix the problem.
     
  9. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    @Andrea Rovai, I already fixed my code. I think when there is some rogue memory access the problem occurs. Whereas the Arduino seems to keep rebooting the Neo ends up in this mode. Needless to say that the Arduino's way is much faster in fixing the error. For the Neo it costs a few minutes every time, and if you don't now the reason it is a multiple of a few times....
     
  10. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    Code:
    #include <Arduino.h>
    #include <HardwareSerial.h>
    #include <stdlib.h>
    #include <Time.h>
    #include <Wire.h>
    
    #define ALARMPIN 7
    #define led 13 // onboard LED
    #define pmPower 12 //PM sensor power control
    
    void setup() {
      pinMode(ALARMPIN, INPUT);
      pinMode(led, OUTPUT);       //SIGNALING WORKING STATE of the PM SENSOR
      pinMode(pmPower, OUTPUT);   //SETTING the WORKING STATE of the PM SEN
      Serial.begin(115200); //Serial is Linux side
      Serial.println("Serial begin OK...");
      Serial.flush();
      Wire1.begin(); 
      Serial0.begin(9600); //PM Sensor
    }
    
    void loop() { }
    
    This sketch runs the first time. Then the following times it usually fails stopping and then I must rm+reboot in order to avoid a "Start failed" when I compile another kind of sketch.
     
  11. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    @Gorgo, I have daisy chained my Neo and Mega in a similar way, and haven't noticed a problem. Can't claim I have run a intensive time though.
     
  12. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Why all those includes? For this sketch you only need Wire.h. The rest should be sorted out by the Arduine IDE compiler with the arduino board package.
     
  13. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    The sketch was bigger. I tried to get to a minimal version with the stop/start problem.

    @Maurice Did you try my sketch too?
     
  14. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    @Gorgo Also for the rest of the sketch you should not need for example hardwareserial.h, Arduino.h etc. Then you have the possibility the compiler uses the one on for example your home folder which could be errornous.

    What if you remove the "Serial.println("Serial begin OK...");" ? Sending data to Serial with println always gives a timeout if you are not having a process reading the serial on the linux side.. It is a known issue. So when you use Serial.println always have a serial monitor (minicom, Arduino IDE serial monitor or remote udoofota-serial) available.
    The arduino/M4 part is starting up much faster that the A9 part so it can fill the serial buffer (if you spam a lot) before you are able to read it.
    In the example you provided on the other hand it should not be blocking.
     
  15. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    When I try to compile your sketch i get an compile error:
    Code:
    Arduino: 1.6.12 (Windows 10), Board:"UDOO Neo (Cortex M4)"
    
    In file included from C:\Users\WALTE_~1\AppData\Local\Temp\untitled1698931359.tmp\sketch_nov30a\sketch_nov30a.ino:4:0:
    
    c:\users\walte_000\appdata\local\arduino15\packages\udoo\tools\gcc-arm-none-eabi\4.9-2014q4-20141203\arm-none-eabi\include\time.h:31:8: error: redefinition of 'struct tm'
     struct tm
            ^
    In file included from C:\Users\walte_000\AppData\Local\Arduino15\packages\UDOO\hardware\solox\1.6.7\variants\udooneo/wiring.h:27:0,
                     from C:\Users\walte_000\AppData\Local\Arduino15\packages\UDOO\hardware\solox\1.6.7\variants\udooneo/Arduino.h:108,
                     from C:\Users\WALTE_~1\AppData\Local\Temp\untitled1698931359.tmp\sketch_nov30a\sketch_nov30a.ino:1:
    C:\Users\walte_000\AppData\Local\Arduino15\packages\UDOO\hardware\solox\1.6.7\variants\udooneo/mqx/release/bsp/mqx.h:868:8: error: previous definition of 'struct tm'
     struct tm {
            ^
    exit status 1
    
    When I compile the same sketch but with only the wire.h include it compile and uploads without any problems, after reboot also no issues to upload again:
    Code:
    De schets gebruikt 108.544 bytes (20%)  programma-opslagruimte. Maximum is 524.288 bytes.
    Address:     192.168.1.120
    Port:        5152
    UDOONeo 115428 bytes sent
    UDOONeo M4 Sketch is running
    
     
  16. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    @Gorgo No, I haven't tried your code, nor have I had the time to do a stress test on my code. I haven't had a problem with it yet, but it may still come. I'll include the code in this post. The first part is on the Neo's M4 the second part is on the Arduino Mega.

    The M4's (and Mega's) output will be processed by a process on the i.MX6. This process will be much slower in being started than the M4 and Arduino, but I don't think that will be a problem as they will not produce output until everything has been started.


    Neo code:
    Code:
    #include "Module.h"
    #include "KeyLock.h"
    #include "Suitcase.h"
    #include "KeyMatrix.h"
    #include "PinDefs.h"
    
    Module* modules[] = {
      new KeyLock(),
      new Suitcase(),
      new KeyMatrix(),
      NULL
    };
    
    
    HardwareSerial& imxSerial = Serial;
    HardwareSerial& megaSerial = Serial0;
    
    
    void setup() {
      imxSerial.begin(115200);
      megaSerial.begin(115200);
    
      for (Module **mpp = modules; *mpp; mpp++) {
        (*mpp)->begin();
      }
    }
    
    void loop() {
      const unsigned long now = millis();
      static String imxInput;
      static String megaInput;
    
      if (checkSerial(imxSerial, imxInput)) {
        megaSerial.println(imxInput);
        dispatchCommand(imxInput);
        imxInput = "";
      }
    
      if (checkSerial(megaSerial, megaInput)) {
        imxSerial.println(megaInput);
        megaInput = "";
      }
    
      for (Module **mpp = modules; *mpp; mpp++) {
        (*mpp)->loop(now, imxSerial);
      }
    }
    
    void dispatchCommand(String& command) {  
      int index = command.indexOf(':');
      if (index > 0) {
        String id = command.substring(0, index);
        String data = command.substring(index + 1);
    
    
        for (Module **mpp = modules; *mpp; mpp++) {
          if ((*mpp)->isModule(id)) {
            (*mpp)->processCommand(data);
          }
        }
      }
    }
    
    
    bool checkSerial(Stream& stream, String& string) {
      int incoming = stream.read();
      if (incoming > 0 && incoming != '\n' && incoming != '\r') {
        string += (char)incoming;
      }
    
      return incoming == '\r';
    }
    
    
    Arduino code:
    Code:
    #include "Module.h"
    #include "LCD16x2.h"
    
    Module *modules[] = {
      new LCD16x2(),
      NULL,
    };
    
    HardwareSerial& neoSerial = Serial1;
    
    void setup() {
      neoSerial.begin(115200);
      Serial.begin(9600);
      for (Module **mpp = modules; *mpp; mpp++) {
        (*mpp)->begin();
      }
    }
    
    void loop() {
      const unsigned long now = millis();
      static String neoInput(80);
    
      if (checkSerial(neoSerial, neoInput)) {
        dispatchCommand(neoInput);
        neoInput = "";
      }
    
      for (Module **mpp = modules; *mpp; mpp++) {
        (*mpp)->loop(now, neoSerial);
      }
    }
    
    void dispatchCommand(String& command) {
      int index = command.indexOf(':');
      if (index > 0) {
        String id = command.substring(0, index);
        String data = command.substring(index + 1);
    
        for (Module **mpp = modules; *mpp; mpp++) {
          if ((*mpp)->isModule(id)) {
            (*mpp)->processCommand(data);
          }
        }
      }
    }
    
    bool checkSerial(Stream& stream, String& string) {
      int incoming = stream.read();
      if (incoming > 0 && incoming != '\n' && incoming != '\r') {
        string += (char)incoming;
      }
    
      return incoming == '\r';
    }
    
    
     
  17. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    Probably your Time library has some redefinition of tm with Wire.h.
    However, I commented #include <Time.h> but this is the Arduine IDE scenario:

    No Sketch running
    Sketch Uploaded (without Time library) ---> Running
    Uploading again ---> Running
    Wait a bit
    Uploading again --> Running
    Wait a bit
    Verify sketch --> Ok
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> Running
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> Running
    Uploading again --> Running
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> Running
    etc.


    Fun thing is that after all these uploads, I waited a bit longer, I retry to upload and Arduino IDE didn't ack me anything (No running or errors), then I retried and it said "Connection failed" + Java exception.
    I can't ssh 192.168.7.2, I can't upload the sketch and I have to reboot because I think Udoo is crashed.
     
  18. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    I added a delay(1000) in my loop (with Time.h included).
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch START failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch START failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch START failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch STOP failed: reboot system !
    Uploading again --> UDOONeo M4 Sketch START failed: reboot system !
    ....


    I'm using this Time library: https://github.com/PaulStoffregen/Time
     
  19. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    There is your problem. This library is most likely not compatible yet with the Neo. Timing libraries normally like to address hardware timers. Neo's timers are different from any other Arduino hardware. I am surprised it compiles.
     
  20. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    159
    Likes Received:
    17
    :eek: Argh!
    So what's the Time library for the NEO??
     

Share This Page