diff --git a/package.json b/package.json index ea6dc47f..fc6a38c3 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "express": "4.13.4", "socket.io": "1.4.5", "systemd": "0.2.6", - "winston": "2.1.1" + "winston": "2.1.1", + "shelljs": "0.8.2" }, "optionalDependencies": { "serialport": "3.1.2", diff --git a/src/hw_mainline.js b/src/hw_mainline.js index ee4e3c55..4cca394f 100644 --- a/src/hw_mainline.js +++ b/src/hw_mainline.js @@ -4,6 +4,7 @@ var parse = require('./parse'); var eeprom = require('./eeprom'); var util = require('util'); var winston = require('winston'); +var shell = require('shelljs'); var debug = process.env.DEBUG ? true : false; if (debug) { @@ -47,6 +48,15 @@ var readGPIODirection = function (n, gpio) { var readPinMux = function (pin, mode, callback) { var pinctrlFile = '/sys/kernel/debug/pinctrl/44e10800.pinmux/pins'; var muxRegOffset = parseInt(pin.muxRegOffset, 16); + //handle the case when debugfs not mounted + if (!my.file_existsSync(pinctrlFile)) { + //exit code is 1 if /sys/kernel/debug not mounted + const umount = shell.exec('mountpoint -q /sys/kernel/debug/').code; + if (umount) + shell.exec('mount -t debugfs none /sys/kernel/debug/', { + silent: true + }); + } var readPinctrl = function (err, data) { if (err) { mode.err = 'readPinctrl error: ' + err;