Bonescript simple examples not working


I just install Bonescript on my cloud9. Now I’m trying to use some simple examples.
However, when I tried to use them I got some error, nevertheless, I didn’t understand why, and how I can solve them.

First example : Toogle LED

var b = require(‘bonescript’);

var leds = [“USR0”, “USR1”, “USR2”, “USR3”,“P8_07”];

for(var i in leds) {
b.pinMode(leds[i], b.OUTPUT);

var state = b.LOW;
for(var i in leds) {
b.digitalWrite(leds[i], state);

setInterval(toggle, 1000);

function toggle() {
if(state == b.LOW) state = b.HIGH;
else state = b.LOW;
for(var i in leds) {
b.digitalWrite(leds[i], state);

The error that I got :

if(!pinmux) { throw p + " was not found under " + my.is_ocp(); }
ocp:P8_07_pinmux was not found under /sys/devices/platform/ocp


Remark : if I change the line

var leds = ["USR0", "USR1", "USR2", "USR3","P8_07"];

var leds = ["USR0", "USR1", "USR2", "USR3",];

My program is working because it didn’t use a gpio pin which request a configuration.

Second example : set a PWM signal and change the duty cycle of it :
source :

var b = require(‘bonescript’);
var SERVO = ‘P9_14’;
var duty_min = 0.03;
var position = 0;
var increment = 0.1;

//b.pinMode(SERVO, b.OUTPUT);

function updateDuty() {
// compute and adjust duty_cycle based on
// desired position in range 0…1
var duty_cycle = (position0.115) + duty_min;
b.analogWrite(SERVO, duty_cycle, 60, scheduleNextUpdate);
console.log("Duty Cycle: " +
100).toFixed(1) + " %");

function scheduleNextUpdate() {
// adjust position by increment and
// reverse if it exceeds range of 0…1
position = position + increment;
if(position < 0) {
position = 0;
increment = -increment;
} else if(position > 1) {
position = 1;
increment = -increment;

// call updateDuty after 200ms
setTimeout(updateDuty, 200);


Error :

/root/labs/cloud9_app/node_modules/bonescript/src/hw_mainline.js:84 if(!pinmux) { throw p + " was not found under " + my.is_ocp(); } ^ ocp:P9_14_pinmux was not found under /sys/devices/platform/ocp

To confirm that my code was working I have tested it on the original kernel install on the beaglebone.
Both were working on it. So, I was wondering if it didn’t come from the dts/dtbo file.
To test that I copy the one form the original kernel in my own one. It didn’t succeed either.

Here are my current configuration :


node --version


npm --version


node -pe “require(‘bonescript’).getPlatform().bonescript”


uname -a

Linux beagle09 4.1.21-bone-rt-r20 #3 Wed May 25 13:55:22 CEST 2016 armv7l GNU/Linux

Did someone have an Idea on what’s wrong ? Am I missing something ?
If you have any questions do not hesitate.
Thanks by advance for your help

" Enjoy life no matter what ! "

Hi Vincent,

I am facing the same problems. Did you find some solution?


Bonescript has had various breakages because of kernel changes for over a year now. No solid solution yet, but Jason & Robert seem to be working on it, look for a new image on when Jason puts it up.

In the meantime, I evaluated several images in June and July, search for my posts and Bonescript and I believe there were a few kernels than mostly had working Bonescript functions, I don’t remember which images they were, but they are listed in my posts.


I didn’t find “solution to fix it”. However, there is some alternative to it : create your own library, or find other one.
You can maybe have a look at the following one:

This one uses the file reading operation to interact with the peripheral.

The other solution (slower), could be to execute shell command with JS

example of function to export a GPIO pin:

function to export a gpio Pin
Parameter : the pin that you want to export
function gpio_export(pin)

var path_export=path+"/export"; // export path

//method where we execute the shell command

var command = "echo “+pin.toString()+” > "+path_export //the shell command that want to do

//execution of the command
process.exec(command,function (err,stdout,stderr) {
//if there is some error print them
if (err) {
} else {


I hope that it will help you.
If you have further questions, do not hesitate.

" Enjoy life no matter what ! "