Bitcoin Forum
December 13, 2024, 02:53:22 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: CGMiner stealing serial ports  (Read 149 times)
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 18, 2024, 12:10:37 PM
Merited by ABCbits (3)
 #1

Does anyone know how to prevent CGMiner from stealing all of the serial ports when it runs?

I need to access /dev/ttyUSB0 etc as it is being used for terminal outputs in another application, this device is an FTDI USB serial converter and has the same VID and PID as the CompacF miner

When CGMiner is started it also claims the USB UART devices attached to /dev/ttyUSB0-4

If I press U for USB management in CGminer I get the following output:-

Bus 1 Device 7 ID: 0403:6015 FTDI FT231X USB UART inactive
Bus 1 Device 10 ID: 0403:6015 FTDI FT231X USB UART inactive
Bus 1 Device 13 ID: 0403:6015 FTDI FT231X USB UART inactive
Bus 1 Device 15 ID: 0403:6015 FTDI FT231X USB UART inactive
Bus 1 Device 14 ID: 0403:6015 GekkoScience CompacF Bitcoin Miner active
Bus 1 Device 11 ID: 0403:6015 GekkoScience CompacF Bitcoin Miner active
Bus 1 Device 8 ID: 0403:6015 GekkoScience CompacF Bitcoin Miner active
Bus 1 Device 5 ID: 0403:6015 GekkoScience CompacF Bitcoin Miner active

But I cannot disable any of the USB UART devices so they can be used by other applications.

If anyone can offer some advice it would be appreciated, thanks in advance.

G.
philipma1957
Legendary
*
Online Online

Activity: 4340
Merit: 9023


'The right to privacy matters'


View Profile WWW
April 18, 2024, 12:58:30 PM
Merited by ABCbits (3)
 #2

try doing the other application first .

get it running.

then try to start cgminer and add the usb sticks

Since the other app is in operation it may keep working and maybe cgminer will start and skip the occupied




After closely reading what you wrote it looks as if you already had the first devices up and running and cgminer grabbed them and terminated the other app?

Is this what is happening?


1) None cgminer app working

2) Cgminer app offline all good

3) put cgminer app online it works but kills the none cgminer app



▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
.
 MΞTAWIN  THE FIRST WEB3 CASINO   
.
.. PLAY NOW ..
DaveF
Legendary
*
Offline Offline

Activity: 3696
Merit: 6686


Crypto Swap Exchange


View Profile WWW
April 18, 2024, 01:12:44 PM
Merited by ABCbits (1)
 #3

This *might* help from https://cgminer.info/documentation/arguments/
(I know it's also from someplace else just can't remember at the moment)

Quote
The –usb option can restrict how many USB devices are found:

–usb 1:2,1:3,1:4,1:* or –usb BAS:1,BFL:1,MMQ:0,ICA:0,KLN:0 or –usb :10

You can only use one of the above 3

The first version –usb 1:2,1:3,1:4,1:* allows you to select which devices to mine on with a list of USB bus_number:device_address All other USB devices will be ignored Hotplug will also only look at the devices matching the list specified and find nothing new if they are all in use You can specify just the USB bus_number to find all devices like 1:* which means any devices on USB bus_number 1 This is useful if you unplug a device then plug it back in the same port, it usually reappears with the same bus_number but a different device_address

You can see the list of all USB devices on linux with ‘sudo lsusb’ Cgminer will list the recognised USB devices

with the ‘-n’ option or the ‘–usb-dump 0’ option The ‘–usb-dump N’ option with a value of N greater than 0 will dump a lot of details about each recognised USB device If you wish to see all USB devices, include the –usb-list-all option

The second version –usb BAS:1,BFL:1,MMQ:0,ICA:0,KLN:0 allows you to specify how many devices to choose based on each device driver cgminer has - the current USB drivers are: AVA, BAS, BFL, BF1, DRB, HFA, ICA, KLN and MMQ.

N.B. you can only specify which device driver to limit, not the type of each device, e.g. with BAS:n you can limit how many BFL ASIC devices will be checked, but you cannot limit the number of each type of BFL ASIC

Also note that the MMQ count is the number of MMQ backplanes you have not the number of MMQ FPGAs

The third version –usb :10 means only use a maximum of 10 devices of any supported USB devices Once cgminer has 10 devices it will not configure any more and hotplug will not scan for any more If one of the 10 devices stops working, hotplug - if enabled, as is default

    will scan normally again until it has 10 devices

    –usb :0 will disable all USB I/O other than to initialise libusb

If that does not work, can you cgminer as a different user?

-Dave

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 18, 2024, 01:14:18 PM
 #4

try doing the other application first .

get it running.

then try to start cgminer and add the usb sticks

Since the other app is in operation it may keep working and maybe cgminer will start and skip the occupied




After closely reading what you wrote it looks as if you already had the first devices up and running and cgminer grabbed them and terminated the other app?

Is this what is happening?


1) None cgminer app working

2) Cgminer app offline all good

3) put cgminer app online it works but kills the none cgminer app




Thanks for your help.

Yes I tried that and yes it forces the all the other serial applications to quit (your note 3).

CGMiner runs fine once its started I don't have an issue there, but it steals the other ports irrespecive of what applicaiton I have tied to them.

They work fine without CGMiner running.

It's a little frustrating.







Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 18, 2024, 01:16:56 PM
 #5

This *might* help from https://cgminer.info/documentation/arguments/
(I know it's also from someplace else just can't remember at the moment)

Quote
The –usb option can restrict how many USB devices are found:

–usb 1:2,1:3,1:4,1:* or –usb BAS:1,BFL:1,MMQ:0,ICA:0,KLN:0 or –usb :10

You can only use one of the above 3

The first version –usb 1:2,1:3,1:4,1:* allows you to select which devices to mine on with a list of USB bus_number:device_address All other USB devices will be ignored Hotplug will also only look at the devices matching the list specified and find nothing new if they are all in use You can specify just the USB bus_number to find all devices like 1:* which means any devices on USB bus_number 1 This is useful if you unplug a device then plug it back in the same port, it usually reappears with the same bus_number but a different device_address

You can see the list of all USB devices on linux with ‘sudo lsusb’ Cgminer will list the recognised USB devices

with the ‘-n’ option or the ‘–usb-dump 0’ option The ‘–usb-dump N’ option with a value of N greater than 0 will dump a lot of details about each recognised USB device If you wish to see all USB devices, include the –usb-list-all option

The second version –usb BAS:1,BFL:1,MMQ:0,ICA:0,KLN:0 allows you to specify how many devices to choose based on each device driver cgminer has - the current USB drivers are: AVA, BAS, BFL, BF1, DRB, HFA, ICA, KLN and MMQ.

N.B. you can only specify which device driver to limit, not the type of each device, e.g. with BAS:n you can limit how many BFL ASIC devices will be checked, but you cannot limit the number of each type of BFL ASIC

Also note that the MMQ count is the number of MMQ backplanes you have not the number of MMQ FPGAs

The third version –usb :10 means only use a maximum of 10 devices of any supported USB devices Once cgminer has 10 devices it will not configure any more and hotplug will not scan for any more If one of the 10 devices stops working, hotplug - if enabled, as is default

    will scan normally again until it has 10 devices

    –usb :0 will disable all USB I/O other than to initialise libusb

If that does not work, can you cgminer as a different user?

-Dave

Hi Dave,

Thanks for this information. I'll give it a go in a while and let you know how things work out. That sounds like it may be the answer, I'll give it a try.

Thank you.
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 18, 2024, 02:07:37 PM
Last edit: April 18, 2024, 07:07:29 PM by Nexus9090
 #6

This *might* help from https://cgminer.info/documentation/arguments/
*SNIP


-Dave



Dave,

Thats perfect. Once I'd worked out what ports the miners were attached to using the switch --usb 1:11,1:8,1:5,1:14 allows it to run without taking the other serial ports.


I've no doubt if things move around I'll have to find which ports are which again but its a start.

Thank you for your help.

 Grin



NotFuzzyWarm
Legendary
*
Offline Offline

Activity: 3850
Merit: 2738


Evil beware: We have waffles!


View Profile
April 18, 2024, 07:14:58 PM
 #7

Glad you got a solution to your issue.
Since you mentioned running a Compac-F I take it you are running Kano's latest version of cgminer? If not link to it is in my sig.
I should add that Sidehack has a new Smart Hub that may good for your needs. Oh course Kano hangs out there as well since he did the driver for the Compac F.

- For bitcoin to succeed the community must police itself -    My info useful? Donations welcome!  3NtFuzyWREGoDHWeMczeJzxFZpiLAFJXYr
 -Sole remaining active Primary developer of cgminer, Kano's repo is here  Discord support invite at https://kano.is/
-Support Sidehacks miner development. Donations to:   1BURGERAXHH6Yi6LRybRJK7ybEm5m5HwTr
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 18, 2024, 10:27:12 PM
 #8

Glad you got a solution to your issue.
Since you mentioned running a Compac-F I take it you are running Kano's latest version of cgminer? If not link to it is in my sig.
I should add that Sidehack has a new Smart Hub that may good for your needs. Oh course Kano hangs out there as well since he did the driver for the Compac F.

Thanks, I'm running Kano's 4.12.1 it works well. been using it for a while now. Just run into this little snag with the serial ports, but all solved now

Thanks for your help.
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 19, 2024, 11:09:43 AM
Merited by DaveF (4)
 #9

For anyone thats interested, I cobbled together this shell script based on usb-list

it scans for usb devices and compiles a list of available ports matching the product id then launches cgminer with the explicit list of usb devices --usb 1:1,1:2,1:3

Code:
#!/bin/sh
# CGMiner start script
#
# Based on usb-list script, modified to scan for devices with a specific product id


print_device(){


local devpath=$1
local parent=$2
local level=$3
local count=$4

[ -d $devpath ] || return
cd $devpath

local busnum=`cat busnum`
local devnum=`cat devnum`


if [ -f "manufacturer" ]; then

       local manufacturer=`cat manufacturer`
fi


if [ -f "product" ]; then

local product=`cat product`
fi


if [ "$product" = "CompacF Bitcoin Miner" ]; then

device_ports="$device_ports$busnum:$devnum,"

echo "$busnum:$devnum - $manufacturer : $product"


fi


local devcount=0
for subdev in $busnum-*
do
echo "$subdev" | grep -Eq "^$busnum-[0-9]+(\.[0-9]+)*$" \
|| continue

devcount=$(($devcount + 1))
if [ -d $devpath/$subdev ]; then
print_device $devpath/$subdev \
$devnum $(($level +1)) $devcount
fi
done

}

device_ports=""

for device in /sys/bus/usb/devices/usb*
do
print_device $device 0 0 0
done

# show ports that matched our search
echo "$device_ports"

#trim the last character removing superfluous comma
usb_list=${device_ports%?}

#did we get it right?
echo "$usb_list"
sleep 5

#now call CGminer
#update the absolute path as necessry
exec /home/garry/cgminer/cgminer -o stratum+tcp://solo.ckpool.org:3333 -u 3MbtxahpbkC1fGhvcWR7Ja38u8cwN9wzY8 -p x --gekko-compacf-freq 500 --gekko-start-freq 500 --gekko-mine2 --gekko-tune2 60 --suggest-diff 868 --usb $usb_list





copy the code to your local cgminer directory as cgstart.sh

chmod +x cgstart.sh

then run it

sudo ./cgstart.sh


I'm no expert at shell scripts, but this seems to work in my environment.

Obviously this doesnt take into account any cgminer.conf files, so if your set-up uses that then i'm not sure if the --usb switch will be passed on.'


modify adapt and use as you see fit. No warranty expressed or implied, provided as-is, use at your own risk.

DaveF
Legendary
*
Offline Offline

Activity: 3696
Merit: 6686


Crypto Swap Exchange


View Profile WWW
April 19, 2024, 11:52:27 AM
 #10

For anyone thats interested, I cobbled together this shell script based on usb-list

it scans for usb devices and compiles a list of available ports matching the product id then launches cgminer with the explicit list of usb devices --usb 1:1,1:2,1:3

Code:
#!/bin/sh
# CGMiner start script
#
# Based on usb-list script, modified to scan for devices with a specific product id


print_device(){


local devpath=$1
local parent=$2
local level=$3
local count=$4

[ -d $devpath ] || return
cd $devpath

local busnum=`cat busnum`
local devnum=`cat devnum`


if [ -f "manufacturer" ]; then

       local manufacturer=`cat manufacturer`
fi


if [ -f "product" ]; then

local product=`cat product`
fi


if [ "$product" = "CompacF Bitcoin Miner" ]; then

device_ports="$device_ports$busnum:$devnum,"

echo "$busnum:$devnum - $manufacturer : $product"


fi


local devcount=0
for subdev in $busnum-*
do
echo "$subdev" | grep -Eq "^$busnum-[0-9]+(\.[0-9]+)*$" \
|| continue

devcount=$(($devcount + 1))
if [ -d $devpath/$subdev ]; then
print_device $devpath/$subdev \
$devnum $(($level +1)) $devcount
fi
done

}

device_ports=""

for device in /sys/bus/usb/devices/usb*
do
print_device $device 0 0 0
done

# show ports that matched our search
echo "$device_ports"

#trim the last character removing superfluous comma
usb_list=${device_ports%?}

#did we get it right?
echo "$usb_list"
sleep 5

#now call CGminer
#update the absolute path as necessry
exec /home/garry/cgminer/cgminer -o stratum+tcp://solo.ckpool.org:3333 -u 3MbtxahpbkC1fGhvcWR7Ja38u8cwN9wzY8 -p x --gekko-compacf-freq 500 --gekko-start-freq 500 --gekko-mine2 --gekko-tune2 60 --suggest-diff 868 --usb $usb_list





copy the code to your local cgminer directory as cgstart.sh

chmod +x cgstart.sh

then run it

sudo ./cgstart.sh


I'm no expert at shell scripts, but this seems to work in my environment.

Obviously this doesnt take into account any cgminer.conf files, so if your set-up uses that then i'm not sure if the --usb switch will be passed on.'


modify adapt and use as you see fit. No warranty expressed or implied, provided as-is, use at your own risk.




Good script, will probably save a bunch of people setting up USB sticks / pods some time.
A couple of thoughts.

1) I would make the sleep longer since cgminer does clear the screen when it starts so 5 seconds may not be enough. Or a press any key to continue thing.
2) People are more and more using different USB miners at the same time, would there be a way to loop it to add more devices?
3) [more like 2a] A list of devices that will NOT be included might help users with other debugging.

This is how software becomes bloat. A programmer comes up with a good thing and users keep throwing in more things. :-)

-Dave

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 19, 2024, 12:05:44 PM
Last edit: April 19, 2024, 12:49:28 PM by Nexus9090
 #11



Good script, will probably save a bunch of people setting up USB sticks / pods some time.
A couple of thoughts.

1) I would make the sleep longer since cgminer does clear the screen when it starts so 5 seconds may not be enough. Or a press any key to continue thing.
2) People are more and more using different USB miners at the same time, would there be a way to loop it to add more devices?
3) [more like 2a] A list of devices that will NOT be included might help users with other debugging.

This is how software becomes bloat. A programmer comes up with a good thing and users keep throwing in more things. :-)

-Dave

Hi Dave,

Thanks, initially I had the sleep period set for 15 seconds, just while I was debugging it. Its easy enough to change.

The script loops through all available USB devices, so if a new one was added it would show up in the list automatically once the script is run.

To include another type of device, provided you know what the product id string is, that could be added or modified in the section:-

Code:

if [ "$product" = "CompacF Bitcoin Miner" ]; then


I guess to something like this(updated):-

Code:

if [ "$product" = "CompacF Bitcoin Miner" ] || [ "$product" = "ANOther Miner" ] || [ "$product" = "And Another Miner" ]; then



I excluded not used devices simply because they were of no interest to CGMiner, but again it could be added if necessary just as an output.


Thanks

Garry

Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 19, 2024, 12:29:01 PM
Last edit: April 19, 2024, 01:43:57 PM by Nexus9090
 #12


Good script, will probably save a bunch of people setting up USB sticks / pods some time.
A couple of thoughts.

1) I would make the sleep longer since cgminer does clear the screen when it starts so 5 seconds may not be enough. Or a press any key to continue thing.
2) People are more and more using different USB miners at the same time, would there be a way to loop it to add more devices?
3) [more like 2a] A list of devices that will NOT be included might help users with other debugging.

This is how software becomes bloat. A programmer comes up with a good thing and users keep throwing in more things. :-)

-Dave


I updated the code to show unused devices as well...

Ouput as follows:-

Code:
1:1 - Linux 6.1.21-v8+ dwc_otg_hcd : DWC OTG Controller - Not Used
1:2 - Linux 6.1.21-v8+ dwc_otg_hcd : DWC OTG Controller - Not Used
1:3 - GekkoScience : CompacF Bitcoin Miner - Added to CGMiner USB list
1:4 - FTDI : FT231X USB UART - Not Used
**********************************
1:3,
1:3



Updated code:-

Code:
#!/bin/sh
# CGMiner start script
#
# Based on usb-list script, modified to scan for devices with a specific product id


print_device(){


local devpath=$1
local parent=$2
local level=$3
local count=$4

[ -d $devpath ] || return
cd $devpath

local busnum=`cat busnum`
local devnum=`cat devnum`


if [ -f "manufacturer" ]; then

#echo "S:  $name=`cat $file`"
local manufacturer=`cat manufacturer`
fi


if [ -f "product" ]; then

local product=`cat product`
fi


if [ "$product" = "CompacF Bitcoin Miner" ]; then

device_ports="$device_ports$busnum:$devnum,"

echo "$busnum:$devnum - $manufacturer : $product - Added to CGMiner USB list"
else

echo "$busnum:$devnum - $manufacturer : $product - Not Used"

fi


local devcount=0
for subdev in $busnum-*
do
echo "$subdev" | grep -Eq "^$busnum-[0-9]+(\.[0-9]+)*$" \
|| continue

devcount=$(($devcount + 1))
if [ -d $devpath/$subdev ]; then
print_device $devpath/$subdev \
$devnum $(($level +1)) $devcount
fi
done

}

device_ports=""

for device in /sys/bus/usb/devices/usb*
do
print_device $device 0 0 0
done

# show ports that matched our search
echo "**********************************"
echo "$device_ports"

#trim the last character removing superfluous comma
usb_list=${device_ports%?}

#did we get it right?
echo "$usb_list"
sleep 15

#now call CGminer
#update the absolute path as necessry
exec /home/garry/cgminer/cgminer -o stratum+tcp://solo.ckpool.org:3333 -u 3MbtxahpbkC1fGhvcWR7Ja38u8cwN9wzY8 -p x --gekko-compacf-freq 500 --gekko-start-freq 500 --gekko-mine2 --gekko-tune2 60 --suggest-diff 868 --usb $usb_list



Nexus9090 (OP)
Member
**
Offline Offline

Activity: 279
Merit: 95

So many numbers and so little time


View Profile
April 19, 2024, 12:52:06 PM
 #13

Just for fun I added an old antminer U2 to it.

It identifies as a CP2102 USB to UART Bridge Controller

1:1 - Linux 6.1.21-v8+ dwc_otg_hcd : DWC OTG Controller - Not Used
1:2 - Linux 6.1.21-v8+ dwc_otg_hcd : DWC OTG Controller - Not Used
1:3 - GekkoScience : CompacF Bitcoin Miner - Added to CGMiner USB list
1:5 - Silicon Labs : CP2102 USB to UART Bridge Controller - Added to CGMiner USB list
1:4 - FTDI : FT231X USB UART - Not Used
**********************************
1:3,1:5,
1:3,1:5

the code edits to include the device look like this

Code:
if [ "$product" = "CompacF Bitcoin Miner" ] || [ "$product" = "CP2102 USB to UART Bridge Controller" ]; then
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!