Fwd: Pocket Beagle index.js issue?

58 views
Skip to first unread message

Fred Kerr

unread,
Feb 28, 2018, 6:56:08 PM2/28/18
to beagl...@googlegroups.com
Forwarded on Jason's request.

---------- Forwarded message ----------
From: Fred Kerr <fek...@gmail.com>
Date: Wed, Feb 28, 2018 at 2:41 PM
Subject: Pocket Beagle index.js issue?
To: Jason Kridner <jkri...@beagleboard.org>


Hello Jason,

I'm new to Pocket Beagle but I have other low-level experience (mainly x86 pre-boot firmware, 16-bit and UEFI 32, 64).

This is likely to be a known issue but I don't know where to look yet. I'm sure I need to get some versions and other information for you, or just find how to get the latest code.

Am I correct that this "b." should apparently be "g."? Based on context from the file, it seems so, and fixed the issue I had.

/usr/local/lib/node_modules/bonescript/src/index.js:325
            if(bitOrder == b.LSBFIRST) {

Also, I get this when I run a simple script that resets some GPIO values. (I'm playing with a 44-LED light bar with serial input.)

debian@beaglebone:~/src/node$ node reset.js

Exiting Cleanly
Unable to open /dev/mem
Unable to open /dev/mem
ERROR: trying to disable motors before they have been initialized
Unable to open /dev/mem
Unable to open /dev/mem
Unable to open /dev/mem

Most likely, I just need to look around for the libraries to use with C/C++ development on Pocket Beagle. I just transitioned to Pocket Beagle after working with RPi3b for a few weeks. Just long enough to get JTAG to start to work. I started working with the Pocket Beagle since they are using it at the ELC/OpenIot summit in Portland OR Mar 12-14.

Thanks,
Fred Kerr

Jason Kridner

unread,
Feb 28, 2018, 8:32:08 PM2/28/18
to beagl...@googlegroups.com


On Feb 28, 2018, at 6:55 PM, Fred Kerr <fek...@gmail.com> wrote:

Forwarded on Jason's request.

---------- Forwarded message ----------
From: Fred Kerr <fek...@gmail.com>
Date: Wed, Feb 28, 2018 at 2:41 PM
Subject: Pocket Beagle index.js issue?
To: Jason Kridner <jkri...@beagleboard.org>


Hello Jason,

I'm new to Pocket Beagle but I have other low-level experience (mainly x86 pre-boot firmware, 16-bit and UEFI 32, 64).

This is likely to be a known issue but I don't know where to look yet. I'm sure I need to get some versions and other information for you, or just find how to get the latest code.

Latest BoneScript? You can install the latest via

TERM=none npm install -g —unsafe-perm bonescript


Am I correct that this "b." should apparently be "g."? Based on context from the file, it seems so, and fixed the issue I had.

I’d need to see the source. It is a variable. 


/usr/local/lib/node_modules/bonescript/src/index.js:325
            if(bitOrder == b.LSBFIRST) {

Also, I get this when I run a simple script that resets some GPIO values. (I'm playing with a 44-LED light bar with serial input.)

debian@beaglebone:~/src/node$ node reset.js

What is the source to reset.js?


Exiting Cleanly
Unable to open /dev/mem
Unable to open /dev/mem
ERROR: trying to disable motors before they have been initialized
Unable to open /dev/mem
Unable to open /dev/mem
Unable to open /dev/mem

I need to clean this up. It is harmless. 


Most likely, I just need to look around for the libraries to use with C/C++ development on Pocket Beagle.

Depending. Do you have a reason to use JavaScript other than the BoneScript examples?

I just transitioned to Pocket Beagle after working with RPi3b for a few weeks. Just long enough to get JTAG to start to work. I started working with the Pocket Beagle since they are using it at the ELC/OpenIot summit in Portland OR Mar 12-14.

Thanks,
Fred Kerr

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CA%2BaxsPZ7OS8QiGM%2ByUxcbX7G5cPY9-uL5xMoV9XyYtcyXqK_gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Fred Kerr

unread,
Feb 28, 2018, 9:38:32 PM2/28/18
to BeagleBoard
Thanks Jason,

I don't currently need javascript; I'm just exploring the examples. I may need it in the future for some things, TBD. :) 
reset.js just contains this:
 
//# fekerr 20180227

var b = require('bonescript');

var LE = "P2_33" ; // GPIO45
var SPI = "P2_25"; // MOSI
var CLK = "P2_29"; // CLK

var chip = [0, 0, 0, 0, 0, 0]; // 44 outputs, 5 1/2 chips

// Configure pins as outputs
b.pinMode(LE, b.OUTPUT);
b.pinMode(SPI, b.OUTPUT);
b.pinMode(CLK, b.OUTPUT);

// initial states
b.digitalWrite(LE, b.LOW);
b.digitalWrite(SPI, b.LOW);
b.digitalWrite(CLK, b.LOW);

doUpdate();

function doUpdate()
{
    var i;
    b.digitalWrite(LE, b.LOW);
    for(i=0; i<6; ++i)
    {
        b.shiftOut(SPI, CLK, b.MSBFIRST, chip[i]);
    }
    b.digitalWrite(LE, b.HIGH);
}
 
debian@beaglebone:/usr/local/lib/node_modules/bonescript/src$ ls -rtl
total 232
-rw-r--r-- 1 debian debian  6000 Jan 12 21:11 socket_handlers.js
-rw-r--r-- 1 debian debian  2190 Jan 12 21:11 server.js
-rw-r--r-- 1 debian debian   680 Jan 12 21:11 serial.js
-rw-r--r-- 1 debian debian  1639 Jan 12 21:11 rc.js
-rw-r--r-- 1 debian debian  3777 Jan 12 21:11 parse.js
-rw-r--r-- 1 debian debian 17253 Jan 12 21:11 my.js
-rw-r--r-- 1 debian debian  1063 Jan 12 21:11 iic.js
-rw-r--r-- 1 debian debian  9873 Jan 12 21:11 hw_universal.js
-rw-r--r-- 1 debian debian  2940 Jan 12 21:11 hw_simulator.js
-rw-r--r-- 1 debian debian  6039 Jan 12 21:11 hw_oldkernel.js
-rw-r--r-- 1 debian debian 13019 Jan 12 21:11 hw_mainline.js
-rw-r--r-- 1 debian debian 14571 Jan 12 21:11 hw_capemgr.js
-rw-r--r-- 1 debian debian  4349 Jan 12 21:11 functions.js
-rw-r--r-- 1 debian debian 11980 Jan 12 21:11 eeprom.js
-rw-r--r-- 1 debian debian   393 Jan 12 21:11 constants.js
-rw-r--r-- 1 debian debian  4596 Jan 12 21:11 bonescript.js
-rw-r--r-- 1 debian debian 69177 Jan 12 21:11 bone.js
-rw-r--r-- 1 debian debian  4394 Jan 12 21:11 autorun.js
-rw-r--r-- 1 debian debian 19763 Feb 28 00:26 index.js

...

index.js, lines 1-5:
 // Copyright (C) 2011 - Texas Instruments, Jason Kridner
  2 //
  3 //
  4 var fs = require('fs');
  5 var child_process = require('child_process');
...
lines pi-hundred to 333:

         } else if(clock == 2) {
315             i++;
316             clock = 0;
317             f.digitalWrite(clockPin, g.LOW, next);
318         }
319     }
320 
321     if(callback) {
322         next();
323     } else {
324         for(i = 0; i < 8; i++) {
325 //fekerr 20180227            if(bitOrder == b.LSBFIRST) {
326             if(bitOrder == g.LSBFIRST) {
327                 bit = val & (1 << i);
328             } else {
329                 bit = val & (1 << (7 - i));
330             }
331 
332             if(bit) {
333                 f.digitalWrite(dataPin, g.HIGH);


Jason Kridner

unread,
Mar 1, 2018, 12:32:08 PM3/1/18
to beagl...@googlegroups.com
Thanks for the issue report and test code. It helped me verify the fix for shiftOut.js. Indeed it got broken some time back and it seems no one tried using the function.

Anyway, it is now fixed in 0.6.3.

Install via 'sudo npm install -g --unsafe-perm bonescript'.

I tested with the BaconBits PocketCape on PocketBeagle: 
https://gist.github.com/jadonk/4557087c543e2ba29ca824badd1d4aa8 

I adjusted your code a bit for the BaconBits hardware:
* nCS was on a different pin
* Addressing was a bit different than you seem to have planned

It starts up a bit slow, but it works.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

Fred Kerr

unread,
Mar 1, 2018, 2:38:46 PM3/1/18
to beagl...@googlegroups.com
Great, thanks! I was just choosing some pins to connect to the light bar. I had initially wired it up to an Arduino101 to amuse my ~4 - year old son.

I'm just grabbing things out of my parts that I have available and as time permits.

I started playing with a small solar cell as an input to 1.8v analog input.

I don't have enough fluency in javascript right now so I should probably switch to python. I will eventually want to use a c/c++ library.

I just found the reference to the Cape last night.

When I get to my laptop or desktop I plan to check on something. I think P2_36 has a P2_35 typo in one of the tables.

Fred Kerr (mobile)


To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/iT3JsATQIjI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CA%2BT6QPmutJYGDnG1uH%2Bg9zkJ-yignn1AnCS4YUp6Y0WfXq%2BT1A%40mail.gmail.com.

Jason Kridner

unread,
Mar 1, 2018, 4:45:19 PM3/1/18
to beagl...@googlegroups.com
Responding to a query you made privately....

Try clearing the npm cache and setting the install path. The root user environment doesn't seem quite right.

TERM=none sudo npm cache clear
TERM=none sudo npm install -g --prefix /usr/local --unsafe-perm bonescript


To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/iT3JsATQIjI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CA%2BaxsPb38vg88o8pKZNrF%2B61TEtnVssSvg2k5iTQEkyECd7mFQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
--

Fred Kerr

unread,
Mar 1, 2018, 6:46:16 PM3/1/18
to BeagleBoard
Thanks, it reports 0.6.3 now.

What pins should I be using? I don't know the conventions and expected usages. I'm wiring OE to ground, and driving SDI, CLK, and LE.

44 LED light bar:
Based on the STP08CL596 chip made by ST.
There are six IC's. Five control forty LED's(eight each...) and one IC controls a group of four.
Serial data goes to the first chip's SDI pin then it outputs serial data to the next chip via the SDO pin.

Pin out:
J1 Connector Pin Out (Pin 6 is on the ond of the bar)
1: SDI (to the first chip)
2: CLK (to all chips)
3: /LE (to all chips)
4: /OE (to all chips)
5: Ground (to all chips)
6: 3.3vDC (to all chips)

debian@beaglebone:~/update$ node -pe "require('bonescript').getPlatform().bonescript"
0.6.3
Reply all
Reply to author
Forward
0 new messages