[Solved] Accessing /dev/ttyMCC kernel panics Linux

Discussion in 'UDOO NEO' started by Ed McLain, Jun 5, 2016.

  1. Ed McLain

    Ed McLain New Member

    Joined:
    Jun 4, 2016
    Messages:
    4
    Likes Received:
    2
    I'm working on a project where I need to control the PWM on multiple pins at the same time. I'm doing this on a Yun so I started out just trying something simple on the Neo. The problem, though, is that as soon as I connect to /dev/ttyMCC through either screen or minicom the kernel panics and the linux side locks up. The M4 does keep running though. I even tried modifying the M4 code to wait for the serial to be available but again, as soon as I connect using screen or minicom the kernel panics. The code and system specs I'm using are below. My next step is to just try to use the serial port without PWM and see what happens.

    Any thoughts?

    Kickstarter UDOO Neo Full
    UDOObuntu 2.0 RC2 - Clean install with all updates via "apt-get dist-upgrade"


    Code:
    /**
    * Variables to configure this system
    */
    
    const int motorPins[] = { 3 };
    
    void setup() {
      Serial.begin(115200);
      pinMode(13, OUTPUT);
      delay(100);
    }
    
    void loop() {
      while ( Serial.available() > 0 ) {
        Serial.write("Starting cylce");
        for ( int i=0; i < sizeof(motorPins); i++ ) {
          Serial.write("ON ");
          Serial.write(i);
          Serial.write(":");
          Serial.write(motorPins[i]);
          Serial.write("\n");
          analogWrite(motorPins[i], 255);
        }
        Serial.write("Sleeping");
        delay(10000);
        for ( int i=0; i < sizeof(motorPins); i++ ) {
          Serial.write("OFF ");
          Serial.write(i);
          Serial.write(":");
          Serial.write(motorPins[i]);
          Serial.write("\n");
          analogWrite(motorPins[i], 0);
        }
        Serial.write("Sleeping");
        delay(10000);
      }
      delay(100);
    }
     
  2. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I'm not aware that there is a relation with using PWM. There are issues with serial though:http://www.udoo.org/docs-neo/Debugging_&_Troubleshooting/USB_stops_working_after_programming_M4.html

     
  3. Ed McLain

    Ed McLain New Member

    Joined:
    Jun 4, 2016
    Messages:
    4
    Likes Received:
    2
    Yeah, I've looked through that and modified my code to not send serial data until connected. The bigger issue though is that I'm connecting through SSH, vs USB, and all comm to the linux side "dies" when the kernel panic occurs. I've also used the serial debug ports (46 & 47) and that is where I have seen that the kernel panics. I have yet to actually see the panic message to get a good dump.
     
  4. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I'm sorry. In my project I'm using Java RXTX to read M4 communication, and it works fine. I'm not using PWM, even though I can't see a relation with that. But that doesn't mean that there is none. For example, I'm having problems with a simple 4x7 display, where a PWM doesn't hang the display but a simple digitalWrite() does.
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Looks like you're code is not coming anywhere: size motor pins is 1. So line i=0; i<1 ; i++ won't do anything.
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Never mind, I was not awake enough and couldn't count :)
     
  7. Ed McLain

    Ed McLain New Member

    Joined:
    Jun 4, 2016
    Messages:
    4
    Likes Received:
    2
    Well, I finally got back to testing and solved the problem - definitely what I get for working late into the night and not paying attention.

    Apparently, if you use Serial.write vs Serial.print[ln] that is what makes the difference. Serial.write will cause a kernel panic immediately, Serial.print works just fine. I haven't dug into the details but that at least got my sketch working.

    Thanks for the help. Now back to hacking!
     
    Andrea Rovai and waltervl like this.
  8. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I tried a sketch lately that uses Serial.write() but no problems found there. Did not use an analogwrite though. Only read a sensor and pushed the data to A9.
     
  9. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Just tested this again. The root cause for the kernel panic is the Serial.write(i); line when i=0.
    Also Serial.write((int)i); did not solve the issue. On a real Arduino this should work (according google) on the Neo not. Edit: Tested and it works on an Arduino Uno!

    When I do a Serial.write(0); or Serial.write((int)0); I get a compiling error:
    /usr/share/arduino/hardware/UDOO/variants/udooneo/print.h:50:12: note: size_t Print::write(const char*)
    size_t write(const char *str) {
    ^
    call of overloaded 'write(int)' is ambiguous

    If you modify the serial.write with serial.print as @Ed McLain did solves this issue but if you really want to send a zero byte you have a problem and the Neo freezes. So I think this should be addressed.
     
    Last edited: Aug 7, 2016
    iz0abd likes this.
  10. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Any update?
     
  11. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    We got no update at date.
     
  12. iz0abd

    iz0abd New Member

    Joined:
    Jun 17, 2017
    Messages:
    2
    Likes Received:
    0
    This is the best description of the problem I've read till now.
    Any update?
     
  13. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    No.....
    @Laura ?
     
  14. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
  15. Jan H

    Jan H New Member

    Joined:
    Oct 23, 2017
    Messages:
    1
    Likes Received:
    0
    Exactly, it does not work for Serial.write, it will still freeze the neo if you read from Serial where a zero was written to. Thats really bad!

    I would like to send an integer (uint16_t) to the Serial port. Minimal example that should work:

    int num = 1;
    byte *ptr_num = (byte*) &num;

    Serial.write (ptr_num, 2);​

    So this should send two bytes (0x00, 0x01) but it will ignore the 0x00 and only send 0x01.

    If I would seperate the write into two consequtive byte sendings it would crash the neo:

    int num = 1;
    byte *ptr_num = (byte*) &num;

    Serial.write ((byte) ptr_num[0]);
    Serial.write ((byte) ptr_num[1]);​

    Reading from the Serial on the Arm side now crashes the neo. Also a Serial.flush () does not help at all!

    How am I supposed to send raw data over the Serial Port, if zeros get ignored/crash the system??

    Is there any advance in this issue?
     

Share This Page