apache / mynewt-mcumgr-cli

MCU Manager CLI
https://mynewt.apache.org/
Apache License 2.0
58 stars 37 forks source link

Can't init hci #25

Open des-gan09 opened 2 years ago

des-gan09 commented 2 years ago

I was trying to run the mcumgr cli via the ble and encounter this error. I managed to circumvent this using sudo. Is there any other method without using sudo.

sjanc commented 2 years ago

this tool uses so called "user channel" to access HCI interface and that requires CAP_NET_ADMIN privilege

des-gan09 commented 2 years ago

So how do i give myself CAP_NET_ADMIN privilege at the user level

muratdolaz commented 1 year ago

When i tried the example 'mcumgr --conntype ble --connstring peer_name=Zephyr echo hello' i encountered an error that 'Error: [hci0]: can't init hci: can't down device: operation not permitted'. Using the command with sudo gave 'sudo: mcumgr: command not found' error. So how can i make it work?

sjanc commented 1 year ago

depends on where you put your mcumgr binary, you may try with sudo -E which preserves your local user environment variables (ie PATH), or you may provide full path to mcumgr binary

sk3p71c commented 1 month ago

I have just come across the same error two years later: "Error: [hci0]: can't init hci: can't down device: operation not permitted".

Giving the utility the CAP_NET_ADMIN capability worked for me; once you do so, the user does not need to be in sudoers when running the utility. To do so, I did the following under debian Bookworm. You'll need to run these commands as root, replacing the path with your installation location.

apt-get install libcap2-bin
setcap 'cap_net_admin=ep' /home/dev/go/bin/mcumgr

Could this capability be granted by the installer, or a warning given if a non-root user installs it? The error message alone does not make obvious what the solution should be, and I spent a lot of time trying to add my user to various groups for instance, under the assumption it was a permissions issue.

Thanks.

sjanc commented 1 month ago

Hi,

Yeah, I guess we could make error message more descriptive and also update web documentation...