# Error when starting Bluetooth Util

**URL:** <https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834>\
**Category:** Tutorials\
**Created:** [October 23, 2017, 7:41am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834 "2017-10-23T07:41:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![GabiSRC](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@GabiSRC](https://mangoh.discourse.group/u/GabiSRC)\
**Post date:** [October 23, 2017, 7:41am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/1 "2017-10-23T07:41:33Z")

</div>

Hi,  
I am currently trying to run the bluetoothUtil demo on my mangoH Green.

But I get the following errors when starting the app:  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | /legato/systems/current/apps/bluetoothUtil/read-only/bin/bt-init.sh:`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | line 27:`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | mux: not found`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] |`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | /legato/systems/current/apps/bluetoothUtil/read-only/bin/bt-init.sh:`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | line 28:`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] | mux: not found`  
`Jan 6 00:16:21 | =ERR= | bt-init.sh[2995] |`

I installed the muxControl from the github [https://github.com/mangOH/MuxControl](https://github.com/mangOH/MuxControl) and they are running:  
`root@swi-mdm9x15:~# app status`  
`[running] atClient`  
`[running] atServer`  
`[running] audioService`  
`[running] avcService`  
`[running] cellNetService`  
`[running] dataConnectionService`  
`[running] fwupdateService`  
`[running] gpioService`  
`[running] modemService`  
`[running] positioningService`  
`[running] powerMgr`  
`[running] secStore`  
`[stopped] smsInboxService`  
`[stopped] spiService`  
`[stopped] tools`  
`[stopped] voiceCallService`  
`[stopped] wifi`  
`[stopped] wifiApTest`  
`[stopped] wifiClientTest`  
`[running] wifiService`  
`[stopped] wifiWebAp`  
`[running] bluetoothUtil`  
`[running] muxCtrlService`  
`[running] muxCtrlTools`

Has anyone having the same issue?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 23, 2017, 3:06pm UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/2 "2017-10-23T15:06:34Z")

</div>

OK, this is going to be a bit of a long story…

MuxCtrlService and MuxCtrlTools are apps that were written a while back to manage muxing of IO on the mangOH Green from userspace using a Legato app. Later we came up with the idea of the IoT framework which was a kernel based system for setting up IoT cards including the muxing of IOs. This code lives in the legato repository under `drivers/mangoh`. More recently, we have split out the driver loading from the IoT framework. The driver loading is now done by `linux_kernel_modules/mangoh` in the mangOH repository. This driver is incompatible with the mangoh driver in the legato repository. For the IoT framework, I have been working on migrating the mangoh driver from legato into a driver that will work for the mangOH Red and Green. mangOH Red support is 95% complete. I will update the forum when I post the source for the IoT framework driver that supports mangOH Red.

While you’re waiting, you can remove the `mux` commands and the echo commands from [bt-init.sh](http://bt-init.sh) and replace it with this:

```
# Set IoT card GPIO3 to high
echo 7 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio7/direction
echo 1 > /sys/class/gpio/gpio7/value
# Take the IoT card out of reset
echo 2 > /sys/class/gpio/export
echo out > /sys/class/gpio/direction
echo 1 > /sys/class/gpio/gpio2/value

```

Let me know if you’re still stuck after trying that.

---

<div class="post-metadata">

**Author:** ![GabiSRC](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@GabiSRC](https://mangoh.discourse.group/u/GabiSRC)\
**Post date:** [October 24, 2017, 6:59am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/3 "2017-10-24T06:59:20Z")

</div>

> [@dfrey](#):
>
> # Set IoT card GPIO3 to high
> 
> echo 7 \> /sys/class/gpio/export  
> echo out \> /sys/class/gpio/gpio7/direction  
> echo 1 \> /sys/class/gpio/gpio7/value
> 
> # Take the IoT card out of reset
> 
> echo 2 \> /sys/class/gpio/export  
> echo out \> /sys/class/gpio/direction  
> echo 1 \> /sys/class/gpio/gpio2/value

Thank you for the story, it’s always pleasant to know the story behind 🙂

So, I did what you suggested and I get  
`root@swi-mdm9x15:/legato/systems/current/appsWriteable/bluetoothUtil/bin# ./bt-init.sh `  
`PWD is: /legato/systems/current/appsWriteable/bluetoothUtil/bin`  
`./bt-init.sh: line 36: can't create /sys/class/gpio/direction: Permission denied`  
`sh: write error: Operation not permitted`  
`Can't set device: Device or resource busy`  
`Can't initialize device: Device or resource busy`  
`hci0: Type: BR/EDR Bus: UART`  
` BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0`  
` DOWN`  
` RX bytes:0 acl:0 sco:0 events:0 errors:0`  
` TX bytes:24 acl:0 sco:0 commands:6 errors:0`  
`Can't init device hci0: Connection timed out (110)`

I really don’t know how to get rid of this permission error…

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 24, 2017, 3:22pm UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/4 "2017-10-24T15:22:41Z")

</div>

oops, It should have been `echo out > /sys/class/gpio/gpio2/direction` for the second block.

---

<div class="post-metadata">

**Author:** ![GabiSRC](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@GabiSRC](https://mangoh.discourse.group/u/GabiSRC)\
**Post date:** [October 24, 2017, 3:39pm UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/5 "2017-10-24T15:39:38Z")

</div>

Ok, now I do not have the permission issue anymore, thank you 🙂

I still have  
`sh: write error: Device or resource busy`  
`Can't set device: Device or resource busy`

And I do not see my talon bluetooth IoT card leds ON. I put my IoT card on the slot 0; maybe it should be a different one?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 24, 2017, 5:10pm UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/6 "2017-10-24T17:10:20Z")

</div>

Sorry, I just realize that I sent you down the wrong path. For some reason I thought you were using a mangOH Red. Since you are using a mangOH Green, it should just be a matter of creating an appropriate SDEF and building that.

Take a look at this for example: [https://github.com/mangOH/Demos/blob/master/smartBoat.sdef](https://github.com/mangOH/Demos/blob/master/smartBoat.sdef)

You can take out all of the apps except for `bluetoothUtil`. The mangOH\_Green.sdef (that is reference by the above example) is what provides the `mux` command. Also, please undo the modifications to [bt-init.sh](http://bt-init.sh) that I suggested previously since those were based on my (incorrect) understanding that you are using mangOH Red.

---

<div class="post-metadata">

**Author:** ![GabiSRC](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@GabiSRC](https://mangoh.discourse.group/u/GabiSRC)\
**Post date:** [October 25, 2017, 7:29am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/7 "2017-10-25T07:29:34Z")

</div>

Hi,  
Ok, but I do not understand how I am suppose to build the application from a .sdef file. Could you please elaborate?

I thought that to build an app, I had only to go the sample folder and run `make` or `mkapp -t wp85 <.adef file>`. When I run the `mkapp` command on the .sdef file I have: `Path 'containerTracking.sdef' does not end in '.adef'.`  
I ran these commands from my ubuntu VM on which the legato tools is installed.

Also, I do not understand how the mux command is provided from this file.

Thank you

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [October 25, 2017, 4:29pm UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/8 "2017-10-25T16:29:08Z")

</div>

`mksys -t wp85 path/to/system.sdef`

The sdef represents an entire legato system. So it builds all the apps.

---

<div class="post-metadata">

**Author:** ![FebinPS](https://avatars.discourse-cdn.com/v4/letter/f/fbc32d/32.png) [@FebinPS](https://mangoh.discourse.group/u/FebinPS)\
**Post date:** [March 1, 2018, 9:29am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/9 "2018-03-01T09:29:33Z")

</div>

Hi,

I am at a similar fix.

why is that we get **-sh: mux: not found** when using mux commands ?

---

<div class="post-metadata">

**Author:** ![FebinPS](https://avatars.discourse-cdn.com/v4/letter/f/fbc32d/32.png) [@FebinPS](https://mangoh.discourse.group/u/FebinPS)\
**Post date:** [March 1, 2018, 11:35am UTC](https://mangoh.discourse.group/t/error-when-starting-bluetooth-util/834/10 "2018-03-01T11:35:45Z")

</div>

Is there any way we can circumvent the use of mux commands ?
