Programming SIM Cards Using PC/SC Smartcard Devices
SIMs are trimmed-down smartcards. We program SIMs with smartcard writers. Our experience is that smartcard writers come in two varieties:
- PC/SC devices. These devices are interfaced through a PC/SC driver and do not appear in the /dev directory. This device type is more common. The "Bluedrive II" available from Range is a device of this type.
- USB-Serial devices. In Unix systems, these appear in /dev as serial port devices, like /dev/ttyUSB0.
The following information has not been checked for accuracy against the current public release (v.4.0). Please use your own judgement and edit the page if you encounter any problems.
To support the PC/SC devices on an Ubuntu system, you need pySim, a GPLv2-licensed python tool to program SIM cards. It is available here: http://cgit.osmocom.org/pysim/
You will first need to install the following from apt-get:
You must also install the following from the "packages" branch:
- libusb (should be installed for OpenBTS already)
Or better yet, get the latest versions through apt-get:
sudo apt-get install libudev0 sudo apt-get install libpcsclite1 sudo apt-get install libccid sudo apt-get install python-pyscard
If you are using an ACS smart card reader, you may want to try this instead:
sudo apt-get install pcscd pcsc-tools libacr38u
Once all of that is installed, you can program your SIM card. Use the "-p" option to indicate the PC/SC interface for the device ("-p 0" usually) and, for the Range GR-Card blank SIMs, specify the card type as "-t grcardsim". For example:
openbts@ubuntu:~/pysim$ ./pySim-prog.py -p 0 -n OpenBTS -c 1 -x 001 -y 01 -j 4 -t grcardsim Failed to load symbol for: SCardCancelTransaction, /usr/local/lib/libpcsclite.so.1: undefined symbol: SCardCancelTransaction! Insert card now (or CTRL-C to cancel) Generated card parameters : > Name : OpenBTS > SMSP : 0015555 > ICCID : 89010010100000000004 > MCC/MNC : 1/1 > IMSI : 001010000000004 > Ki : bc9aecfabe1f81f1f85d09370f5a6f51 Programming ... Done !
Other comments on pySim:
- The "undefined symbol" warning does not appear to be a problem, so ignore it.
- If you get the error message
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1. Card is unpoweredthat means the SIM is in the drive upside down or backwards.
Use of the Bludrive II:
- Proper card orientation is with the metal contacts facing up, inside the device.
- When the SIM is inserted correctly, the LED on the unit will turn red for about ten seconds and then turn green again.
- If the SIM is not inserted correctly, the LED on the unit will flash red for about a second and then turn red and stay red until the SIM is removed.
Use of the ACR38T:
- (12-2012 by Pat) The ACR38T programmer is a thumb-drive sized USB device that programs the SIM card after it has been removed from the Smart-Card carrier. This allows you to reprogram an existing SIM card.
- To use it in Ubuntu 12, ignore the instructions on the ACR website and just apt-get install pcscd; then invoke pcscd, which is a daemon. The light on the device turns solid green only when it is properly recognized by pcscd. Then follow the instructions for pySim-prog.py herein.
- This programming device (and many others) can be purchased here: http://www.smartcardfocus.us/shop/ilp/se~4/SIM_USB_stick/p/index.shtml