Pin works when sketch is loaded from IDE but not loaded during boot

Discussion in 'UDOO NEO' started by jaeg, Jul 18, 2018.

  1. jaeg

    jaeg Member

    Joined:
    Oct 22, 2013
    Messages:
    62
    Likes Received:
    0
    Hi,
    So I've been working on a robot that uses Redis to communicate between a server and itself. As I was testing this I noticed something odd. If I load the sketch from the Arduino IDE, Web page, or from an external PC it works fine. But if I reset the whole board Pin 12 won't work and stays in a floating state (I tested it with a multimeter). If I reupload the sketch it'll work just fine again.

    I've tried other sketches as well, I modified the sample sketch that turns Pin 13 (the led one) one and off to use Pin 12. Same results as my initial sketch.

    I've noticed sometimes it will blink on 12 during part of the boot process.

    I've eliminated external hardware from the equation too, currently I'm using a jumper plugged into pin12 and another one plugged into ground so I can test with a multimeter.

    Any suggestions please?
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Never noticed this but with the Neo you never know....
     
  3. jaeg

    jaeg Member

    Joined:
    Oct 22, 2013
    Messages:
    62
    Likes Received:
    0
    So it's just generally unstable like that?

    I guess I could do a work around with a script that runs the arduino compiler and reloads the sketch after everything has booted up. But it seems weird that I have to do something like that.
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Generally it should not be unstable but the Neo Arduino part has some differences from a normal Arduino.
    Also the M4 (arduino) pins are shared with the A9 processor so it could be that during boot something is happening here unexpected.
    During every boot the compiled sketched is uploaded to the M4, see https://www.udoo.org/docs-neo/Arduino_M4_Processor/Overview.html

    The Neo is also very picky on Pinmode() placement, you can only use it safely in setup(), not in Loop().
    Furthermore the Neo is picky on sending data through Serial() if no process on the A9 side is listening. Be sure you do not send any data from Arduino unless you are sure on the A9 side a process (Arduino IDE serial monitor, minicom, own written python, etc) is listening.
    See also some links with more examples and a link to the known issues topic.

    Known Neo Arduino issues, Howto Neo IoT Sensors, Howto Neo Webcontrol
     
  5. jaeg

    jaeg Member

    Joined:
    Oct 22, 2013
    Messages:
    62
    Likes Received:
    0
    I was wondering if it was the serial port last night and had tried to see if removing that would help. Currently it's running this:

    Code:
    void setup() {
      pinMode(12, OUTPUT);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(12, HIGH); 
      delay(1000); 
      digitalWrite(12, LOW);  
      delay(1000); 
    }
    Which works if I load it from an IDE but doesn't when it is loaded during boot.
    I've tried the other pins and none of them seem to have this behavior.

    I've also tried:

    Code:
    void setup() {
      pinMode(12, OUTPUT);
      pinMode(13, OUTPUT);
    }
    
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(12, HIGH); 
      digitalWrite(13, HIGH); 
      delay(1000); 
      digitalWrite(12, LOW); 
      digitalWrite(13, LOW); 
      delay(1000); 
    }
    Which has the same behavior however pin 13 will toggle back and forth even on a reboot while 12 doesn't.
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    This looks like a bug in the Arduino implementation. @Laura Can you or one of the Udoo engineers look into this? I am in a relocation so all my boards are packed and temporarily onavailable for reproducing this issue.
     
  7. jaeg

    jaeg Member

    Joined:
    Oct 22, 2013
    Messages:
    62
    Likes Received:
    0
    Ran this after it finished booting:
    Code:
    udooneo-m4uploader /var/opt/m4/m4last.fw 
    and the pin seems to work fine. I'm tempted to put this in my profile.d so it runs at startup as a temporary fix.
     
  8. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I have seen some comments of @jas-mx about the upload of the Arduino binary during boot is not completely correct. This could be a feasible workaround.....
     

Share This Page