Hi,
Today i will explain how to assign a permanent device name to your smargo readers on Dreambox 7020si STB. How to for the other models and PC Linux will come later too. Most of the time when you plug a usb device into dreambox or a pc the linux kernel assign to it a device name and point it to a specfic port. (ex /dev/usb/tts/0
/dev/usb/tts/1, /dev/usb/tts/2, /dev/usb/tts/3, for my 4 smargo readers) but sometimes when you reboot the system the kernel don't assign the same port to the same previously connected usb device, this will cause issues for the EMU trying to point to a specific SmartCard. At the end of this tutorial you will have a shell script that will solve this issues by assigning a device name to your USB devices, this names remain the same even you restart the system or you do a hotplug of the device all that you need to do is to call this script before you start your EMU. This names will be used in the EMU conf file instead of the names assigned by the linux kernel.
Requirements :
a. Dreambox 7020si.
b. One or more smargo smartreader(s) with firmware 1.4 (Later i will give the link to download all the necessary tools and files to accomplish this work).
c. USB HUB if you plan to use more than 1 samrgo smartreader.
Notes :
All the used Dreambox STB's are genuine.
The image running in my DM7020si is the Gemini Project Version 4.70. For the older versions the drivers are not delivred with the system so you must install them manualy.
To enable the Chipset FTDI drivers go to Blue Panel ----> (3) Extras / Setup ----> USB-CardReader drop down the list and select the item Chipset FTDI finally push the green button on the remote controle to save the changes. Push the exit Button twice to quit all the opened windows. Now it is time to reboot the STB to changes take effect. Push the button MENU ----> (9) Shutdown ----> restart.
To display all the attached USB devices to the DM7020si coonect to the DM7020si using putty and issue this command:
, in my case the output look like this :
root@dm7020:~> cat /proc/bus/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 1, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.9 ohci_hcd
S: Product=OCP OHCI
[COLOR=#ff0000]S: SerialNumber=ocp[/COLOR]
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 7
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=2001 ProdID=f103 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
T: Bus=01 Lev=02 Prnt=02 [COLOR=#800000]Port=01[/COLOR] Cnt=01 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
[COLOR=#000000]P: Vendor=0403 ProdID=6001 Rev= 4.00
[/COLOR][COLOR=#ff0000]S: SerialNumber=Reader 150[/COLOR]
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
T: Bus=01 Lev=02 Prnt=02 [COLOR=#800000]Port=03[/COLOR] Cnt=02 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
[COLOR=#000000]P: Vendor=0403 ProdID=6001 Rev= 4.00
[/COLOR][COLOR=#ff0000]S: SerialNumber=Reader 128@@@WCF_PRE_LINEBREAK@@@[/COLOR]C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
T: Bus=01 Lev=02 Prnt=02 [COLOR=#800000]Port=04[/COLOR] Cnt=03 Dev#= 5 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
[COLOR=#000000]P: Vendor=0403 ProdID=6001 Rev= 4.00
[/COLOR][COLOR=#ff0000]S: SerialNumber=Reader 215@@@WCF_PRE_LINEBREAK@@@[/COLOR]C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
T: Bus=01 Lev=02 Prnt=02 [COLOR=#800000]Port=06[/COLOR] Cnt=04 Dev#= 6 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
[COLOR=#000000]P: Vendor=0403 ProdID=6001 Rev= 4.00@@@WCF_PRE_LINEBREAK@@@[/COLOR][COLOR=#ff0000]S: SerialNumber=Reader 216[/COLOR]
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=ftdi_sio
E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms
root@dm7020:~>
Display More
root@dm7020:~> cat /proc/tty/driver/usbserial
usbserinfo:1.0 driver:v2.0
[COLOR=#8b4513]0[/COLOR]: module:ftdi_sio name:"FTDI FT232BM Compatible" vendor:0403 product:6001 num_ports:1 port:1 path:usb-ocp-1.[COLOR=#0000cd]2[/COLOR]
[COLOR=#8b4513]1[/COLOR]: module:ftdi_sio name:"FTDI FT232BM Compatible" vendor:0403 product:6001 num_ports:1 port:1 path:usb-ocp-1.[COLOR=#0000cd]4[/COLOR]
[COLOR=#8b4513]2[/COLOR]: module:ftdi_sio name:"FTDI FT232BM Compatible" vendor:0403 product:6001 num_ports:1 port:1 path:usb-ocp-1.[COLOR=#0000cd]5[/COLOR]
[COLOR=#8b4513]3[/COLOR]: module:ftdi_sio name:"FTDI FT232BM Compatible" vendor:0403 product:6001 num_ports:1 port:1 path:usb-ocp-1.[COLOR=#0000cd]7[/COLOR]
root@dm7020:~>
root@dm7020:~> ls /dev/usb/tts/
[COLOR=#8b4513]0 1 2 3[/COLOR][COLOR=#0000ff]
[/COLOR]root@dm7020:~>
now i will explain the relation between the 3 outputs :
Port 0 in the command output of "ls /dev/usb/tts/" correspond to the port 0 in the command output of "cat /proc/tty/driver/usbserial" this is the device file created for the smargo smart reader connected in the hub port number usb-ocp-1."2" the "2" value is obtained from the addition of 1 to the value of Port=01 obtained from the command output of "cat /proc/bus/usb/devices " which represent the smargo with SerialNumber=Reader 150.
Here is a table that explain the conection between the device file created by the kernel and the smargo smartreaders SerialNumber which will be used to create the persistent device names.
[COLOR=#0000cd][COLOR=#8b4513][COLOR=#8b4513][COLOR=#0000cd][COLOR=#800000][COLOR=#ff0000]@@@WCF_PRE_LINEBREAK@@@[/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR]CMD3 CMD2 CMD1
"ls /dev/usb/tts/" cat /proc/tty/driver/usbserial cat /proc/bus/usb/devices
device file device file Hub-port Hub port serial number
[COLOR=#0000cd][COLOR=#8b4513][COLOR=#8b4513][COLOR=#0000cd][COLOR=#800000][COLOR=#ff0000][COLOR=#8b4513][COLOR=#8b4513]0 [COLOR=#8b4513]<--------[COLOR=#8b4513]--------[COLOR=#8b4513]----[/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#222222] [COLOR=#8b4513][COLOR=#8b4513]0 <-------- [/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#0000cd]2 <------- 1 + [COLOR=#800000]Port=01 <- [COLOR=#ff0000]Reader 150[/COLOR][/COLOR][/COLOR]@@@WCF_PRE_LINEBREAK@@@[COLOR=#8b4513]1 [COLOR=#8b4513]<-------------------- [/COLOR][/COLOR][COLOR=#8b4513][COLOR=#8b4513]1 [COLOR=#8b4513]<-------- [/COLOR][/COLOR][/COLOR][COLOR=#0000cd]4[COLOR=#0000cd] <------- 1 + [/COLOR][COLOR=#800000]Port=03 [/COLOR][COLOR=#800000]<- [/COLOR][COLOR=#ff0000]Reader 128[/COLOR][/COLOR]@@@WCF_PRE_LINEBREAK@@@[COLOR=#8b4513]2 [COLOR=#8b4513]<-------------------- [/COLOR][COLOR=#8b4513][COLOR=#8b4513]2 [COLOR=#8b4513]<-------- [/COLOR][/COLOR][/COLOR][COLOR=#0000cd]5[COLOR=#0000cd] <------- 1 + [/COLOR][COLOR=#800000]Port=04 [COLOR=#800000]<- [/COLOR][COLOR=#ff0000]Reader 215[/COLOR][/COLOR][/COLOR][/COLOR]@@@WCF_PRE_LINEBREAK@@@[COLOR=#8b4513]3 [COLOR=#8b4513]<-------------------- [/COLOR][COLOR=#0000cd][COLOR=#8b4513][COLOR=#8b4513]3 [COLOR=#8b4513]<-------- [/COLOR][COLOR=#0000cd]7[COLOR=#0000cd] <------- 1 + [/COLOR][COLOR=#800000]Port=06 [COLOR=#800000]<- [/COLOR][COLOR=#ff0000]Reader 216 [/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR]@@@WCF_PRE_LINEBREAK@@@[/COLOR][/COLOR][/COLOR][/COLOR][/COLOR][/COLOR]
Well the sh script will use the CMD3 and CMD2 commands to collect data create then create the persistent devices names (symlinks) to the correponding devices files created by the linux kernel.Here is the script code :
#!/bin/sh
#Author: BOUDRAA Cheikh [EMAIL='bcheikh26@yahoo.com']bcheikh26@yahoo.com[/EMAIL]
echo "This script checks the existence of eventual smargo readers and assign them a persistent name that can be used instead of the name assigned by the system"
echo "Checking..."
devPath="/dev/"
SerialReadersList=`cat /proc/bus/usb/devices | grep "Reader" -A0 -B3 | grep "Reader" | cut -d "=" -f 2 | tr ' ' '_'`
DEVICES=/dev/ttyUSB*
devicePath="/dev/usb/tts/"
Reader_128="_CSATV4S19E"
Reader_150="_BISTVV4S13E"
Reader_215="_SRGV4S13E"
Reader_216="_JSCV4S7W13E26E"
echo $DEVICES
if [ -n '$DEVICES' ] ; then
for readerSerial in $SerialReadersList
do
echo "Processing $readerSerial device..."
# take action on each serial reader. $readerSerial store current usbserialid
RSP=`echo $readerSerial | tr '_' ' '`
readerSerialPort=`cat /proc/bus/usb/devices | grep "$RSP" -A0 -B3 | grep "Port" | cut -d " " -f 6 | cut -d "=" -f 2`
if [ -n '$readerSerialPort' ] ; then
# case start here
echo $readerSerialPort
case $readerSerial in
"Reader_128" )
devicePort=`expr $readerSerialPort + 1`
readerSerialPath="path:usb-ocp-1."$devicePort
device=`cat /proc/tty/driver/usbserial | grep "$readerSerialPath" | cut -d " " -f 1 | cut -d ":" -f 1`
echo "Device : " $device
if [ -L $devPath$readerSerial$Reader_128 ]
then
echo $devPath$readerSerial$Reader_128 " exists."
rm $devPath$readerSerial$Reader_128
ln -s $devicePath$device $devPath$readerSerial$Reader_128
else ln -s $devicePath$device $devPath$readerSerial$Reader_128
fi
;;
"Reader_150" )
devicePort=`expr $readerSerialPort + 1`
readerSerialPath="path:usb-ocp-1."$devicePort
device=`cat /proc/tty/driver/usbserial | grep "$readerSerialPath" | cut -d " " -f 1 | cut -d ":" -f 1`
echo "Device : " $device
if [ -L $devPath$readerSerial$Reader_150 ]
then
echo $devPath$readerSerial$Reader_150 " exists."
rm $devPath$readerSerial$Reader_150
ln -s $devicePath$device $devPath$readerSerial$Reader_150
else ln -s $devicePath$device $devPath$readerSerial$Reader_150
fi
;;
"Reader_215" )
devicePort=`expr $readerSerialPort + 1`
readerSerialPath="path:usb-ocp-1."$devicePort
device=`cat /proc/tty/driver/usbserial | grep "$readerSerialPath" | cut -d " " -f 1 | cut -d ":" -f 1`
echo "Device : " $device
if [ -L $devPath$readerSerial$Reader_215 ]
then
echo $devPath$readerSerial$Reader_215 " exists."
rm $devPath$readerSerial$Reader_215
ln -s $devicePath$device $devPath$readerSerial$Reader_215
else ln -s $devicePath$device $devPath$readerSerial$Reader_215
fi
;;
"Reader_216" )
devicePort=`expr $readerSerialPort + 1`
readerSerialPath="path:usb-ocp-1."$devicePort
device=`cat /proc/tty/driver/usbserial | grep "$readerSerialPath" | cut -d " " -f 1 | cut -d ":" -f 1`
echo "Device : " $device
if [ -L $devPath$readerSerial$Reader_216 ]
then
echo $devPath$readerSerial$Reader_216 " exists."
rm $devPath$readerSerial$Reader_216
ln -s $devicePath$device $devPath$readerSerial$Reader_216
else ln -s $devicePath$device $devPath$readerSerial$Reader_216
fi
;;
* )
echo "Reader Serial '$readerSerial' is not declared."
;;
esac
else
echo "serial id not found"
fi
done
else
echo "No USB reader detected"
fi
echo "...done."
Display More
Give it a name ex : RenameUSBReaders.sh save it to /var/script/ directory.
Issue this commande to make it executable : chmod 755 /var/script/RenameUSBReaders.sh
Issue this command : /var/script/RenameUSBReaders.sh
if every things is ok you will get an ouputs. To check if the new devices names are created issue this commande : "ls -la /dev/Reader_*"
root@dm7020:~> ls -la /dev/Reader_*
lr-xr-xr-x 1 root root 14 Nov 7 17:50 /dev/Reader_128_CSATV4S19E -> /dev/usb/tts/1
lr-xr-xr-x 1 root root 14 Nov 7 17:50 /dev/Reader_150_BISTVV4S13E -> /dev/usb/tts/0
lr-xr-xr-x 1 root root 14 Nov 7 17:50 /dev/Reader_215_SRGV4S13E -> /dev/usb/tts/2
lr-xr-xr-x 1 root root 14 Nov 7 17:50 /dev/Reader_216_JSCV4S7W13E26E -> /dev/usb/tts/3
root@dm7020:~>
Now you can use the new created symlinks into your EMU conf without any issues.
Next post i will give some examples on how to use the new device files to communicate with the smargo smart reader.
Good Luck
To be continued.
magische_vogel