5 Replies Latest reply on Aug 3, 2015 1:52 PM by JPMontero_Intel

    SPI in NodeJS on Edison Crashing the device!

    LeonY

      This is driving me mad!

      • I have the latest image running on the Edison Mini Breakout Board.
      • I have a simple NodeJS app that sends a small packet of bytes out SPI

      Sometimes it works, sometimes it crashes, sometimes I get a rubbish signal!

       

      CODE:

      var m = require('mraa');
      x = new m.Spi(0);
      
      var LEDs = new Buffer(4);
      var startFrame = new Buffer(4);
      var endFrame = new Buffer(4);
      
      
      x.frequency(1000000);
      x.lsbmode(false);
        startFrame[0] = 0;
        startFrame[1] = 0;
        startFrame[2] = 0;
        startFrame[3] = 0;
        endFrame[0] = 255;
        endFrame[1] = 255;
        endFrame[2] = 255;
        endFrame[3] = 255;
      
          console.log("LIBMRAA Versoin details\n--->\t\t"+m.getVersion());
          
          for(var cIndex=0; cIndex<100; cIndex++)
           {
                     LEDs[0] = 255;
                     LEDs[1] = 0;
                     LEDs[2] = 0;
                     LEDs[3] = 255;
                    x.write(startFrame);
                    x.write(LEDs);
                    x.write(endFrame);
            }
      

       

      Here is what happens!

      The core runs for an arbitrary amount of time, its completely random when it crashes, but when it does, the app just hangs:

      This is top output

       

      365   351 root     D    37760   4%   0% node main.js
      

       

      And a minute later i get this on the console:

       

      root@edison:/node_app_slot# node main.js
      [  240.618710] INFO: task node:365 blocked for more than 120 seconds.
      [  240.618800] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      

      This repeats, i can no longer run any node apps, and i have to reboot the device!

       

      Now this issue has been ongoing, as soon as i purchased the Edison, this happened. So i flashed the new image, and it went away and not its happening again....WHATS GOING ON??

      I have tried all kinds of different SPI speeds as well, i started at 50kz and got the same thing!

        • 1. Re: SPI in NodeJS on Edison Crashing the device!
          JPMontero_Intel

          Hi LeonY,

           

          There were some updates to the SPI in the mraa library, make sure you are using the latest version 0.7.3. In case you don’t know how to update your mraa version, you can do it with the following commands:

          echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf

          opkg update
          opkg install libmraa0

          Please try with this version and let us know if it works.

           

          Regards,
          JPMontero_Intel

          • 2. Re: SPI in NodeJS on Edison Crashing the device!
            LeonY

            JPMontero_Intel

            I am on the latest version of MRAA already. I ran the following code to test:

            var m = require('mraa');
            x = new m.Spi(0);
            console.log("LIBMRAA Versoin details\n--->\t\t"+m.getVersion());
            

            The resulting out put was:

            root@edison:/node_app_slot# node main.js
            LIBMRAA Versoin details
            --->            v0.7.3
            

            I then ran the command syou suggested to double check that i was on the latest:

            root@edison:~# opkg update
            Downloading http://iotdk.intel.com/repos/1.5/intelgalactic/Packages.
            Updated list of available packages in /var/lib/opkg/iotkit.
            Downloading http://iotdk.intel.com/repos/1.1/intelgalactic/Packages.
            Updated list of available packages in /var/lib/opkg/mraa-upm.
            root@edison:~# opkg install libmraa0
            Package libmraa0 (0.7.3) installed in root is up to date.
            

            I then rebooted and tested the code again and got the same result:

            root@edison:/node_app_slot# node main.js
            LIBMRAA Versoin details
            --->            v0.7.3
            

            Problem is still there. Can you sugest a way to identify exactly what is faulting?I tried the xdk debugger but it does nothing.

            • 3. Re: SPI in NodeJS on Edison Crashing the device!
              LeonY

              I have an update on this issue:

              I think this issue is not related to MRAA but specificaly to the SPI device on the Edison.

              • I re-flashed the latest image onto the Edison
              • Updated MRAA
              • Ran my code and ran into the same issue

              I then

              • Re-flashed the latest image on to the Edison again
              • Installed spi-npm via "npm install spi-npm"
              • Verified that the module works, using "/dev/spidev5.1" i could see a clock and data signal on my Scope
              • Ran my test code and ran into the same problem!

              I believe there may be an issue with the SPI device on the edison..maybe specifically to mine.

              If so, what is the best way to return it and get a replacement unit via warranty?

              Leon

              • 4. Re: SPI in NodeJS on Edison Crashing the device!
                LeonY

                As suggested by the developer of "mraa" here is the dmesg output from my Edison board:

                http://www.elec-tron.org/wp-content/uploads/2015/08/dmesg.txt

                • 5. Re: SPI in NodeJS on Edison Crashing the device!
                  JPMontero_Intel

                  Hi LeonY,

                   

                  Thank you for the dmesg output. Additionally we received your warranty request, we will continue with this issue via email.

                   

                  Regards,
                  JPMontero_Intel