<div dir="ltr">Thanks Domonkos.<div><b>It does not give me helpful info.</b></div><div><b>only code relevant to my issue is as below:</b></div><div><img src="cid:ii_ki81163m0" alt="image.png" width="552" height="35"><br></div><div><b>but my issue is as below:</b></div><div><br></div><div>





<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Programming ...</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:13px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Card programming failed with an execption:</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">---------------------8<---------------------</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">Traceback (most recent call last):</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">  </span>File "./pySim-prog.py", line 719, in <module></span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>rc = process_card(opts, first, card_handler)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">  </span>File "./pySim-prog.py", line 671, in process_card</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>card.program(cp)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">  </span>File "/home/support/pysim/pySim/cards.py", line 713, in program</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>self._scc.verify_chv(0x0A, h2b(p['pin_adm']))</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">  </span>File "/home/support/pysim/pySim/commands.py", line 206, in verify_chv</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">  </span>File "/home/support/pysim/pySim/transport/__init__.py", line 104, in send_apdu_checksw</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space">    </span>raise RuntimeError("SW match failed! Expected %s and got %s." % (sw.lower(), rv[1]))</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">RuntimeError: SW match failed! Expected 9000 and got 63c8.</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">I'm flashing this SIM card for a 5G project at </span><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"><a href="https://github.com/free5gc/free5gc">https://github.com/free5gc/free5gc</a></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)">Does this SIM card SW supports 5G?</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)">Thanks.</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)">Br,</span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)">Chunlin</span></p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 1, 2020 at 2:30 AM Tomcsányi, Domonkos <<a href="mailto:domi@tomcsanyi.net">domi@tomcsanyi.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Andrew,<br>
<br>
Have a look at this list for example for APDU response codes to<br>
understand better what is going on.<br>
<a href="https://www.eftlab.com/knowledge-base/complete-list-of-apdu-responses/" rel="noreferrer" target="_blank">https://www.eftlab.com/knowledge-base/complete-list-of-apdu-responses/</a><br>
<br>
Kind regards,<br>
Domi<br>
<br>
On Tue, Dec 1, 2020 at 10:24 AM Chunlin Yang <<a href="mailto:chliny2016@gmail.com" target="_blank">chliny2016@gmail.com</a>> wrote:<br>
><br>
> Hi Vadim and all,<br>
><br>
> pyProg.py fails with an error, could you help (btw, I change all real info to xxx :)):<br>
><br>
> support@S2600WFT:~/pysim$ python ./pySim-prog.py -p 0 -x 208 -y 93 -t sysmoUSIM-SJS1 -i 208930000000003 --op=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -k xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -s xxxxxxxxxxxxxxxxxxxxx -a xxxxxxxx<br>
> Using PC/SC reader interface<br>
> Ready for Programming: Insert card now (or CTRL-C to cancel)<br>
> Generated card parameters :<br>
>  > Name     : Magic<br>
>  > SMSP     : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>
>  > ICCID    : xxxxxxxxxxxxxxxxxxxx<br>
>  > MCC/MNC  : 208/93<br>
>  > IMSI     : xxxxxxxxxxxxxxx<br>
>  > Ki       : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>
>  > OPC      : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>
>  > ACC      : None<br>
>  > ADM1(hex): xxxxxxxxxxxxxxxx<br>
> Programming ...<br>
><br>
> Card programming failed with an execption:<br>
> ---------------------8<---------------------<br>
> Traceback (most recent call last):<br>
>   File "./pySim-prog.py", line 719, in <module><br>
>     rc = process_card(opts, first, card_handler)<br>
>   File "./pySim-prog.py", line 671, in process_card<br>
>     card.program(cp)<br>
>   File "/home/support/pysim/pySim/cards.py", line 713, in program<br>
>     self._scc.verify_chv(0x0A, h2b(p['pin_adm']))<br>
>   File "/home/support/pysim/pySim/commands.py", line 206, in verify_chv<br>
>     return self._tp.send_apdu_checksw(self.cla_byte + '2000' + ('%02X' % chv_no) + '08' + fc)<br>
>   File "/home/support/pysim/pySim/transport/__init__.py", line 104, in send_apdu_checksw<br>
>     raise RuntimeError("SW match failed! Expected %s and got %s." % (sw.lower(), rv[1]))<br>
> RuntimeError: SW match failed! Expected 9000 and got 63c9.<br>
> ---------------------8<---------------------<br>
><br>
> Programming failed: Remove card from reader<br>
><br>
> Thanks.<br>
> Br,<br>
> Andrew<br>
><br>
> On Tue, Dec 1, 2020 at 1:07 AM Chunlin Yang <<a href="mailto:chliny2016@gmail.com" target="_blank">chliny2016@gmail.com</a>> wrote:<br>
>><br>
>> Thanks a lot Vadim!<br>
>> I have thought it might be an issue between python3 and python2. So I have tried on both versions.<br>
>> on Python3, I got same error.<br>
>> But now with this command  'python ./pySim-read.py -p0', it works. I used to use this command './pySim-read.py -p0' and it gave me the same error.<br>
>><br>
>> But although 'python ./pySim-read.py -p0' works (reads out the content of the SIM, it gives me an error/prompt at the end:<br>
>> Traceback (most recent call last):<br>
>>   File "./pySim-read.py", line 255, in <module><br>
>>     (res, sw) = card.read_ehplmn()<br>
>> AttributeError: 'OpenCellsSim' object has no attribute 'read_ehplmn'<br>
>><br>
>> maybe I can just ignore this prompt as I don't need ehplmn.<br>
>><br>
>> Br,<br>
>> Andrew<br>
>><br>
>> On Tue, Dec 1, 2020 at 12:45 AM Vadim Yanitskiy <<a href="mailto:vyanitskiy@sysmocom.de" target="_blank">vyanitskiy@sysmocom.de</a>> wrote:<br>
>>><br>
>>> On 12/1/20 2:17 AM, Chunlin Yang wrote:<br>
>>> > ModuleNotFoundError: No module named 'smartcard'<br>
>>> ><br>
>>> > BTW, I have manually imported smartcard in python, and it's successful.<br>
>>><br>
>>> I guess you have two Python versions (2.7 and 3.x), so it could be that<br>
>>> you've installed smartcard for 3.x and in works in the shell.<br>
>>> Unfortunately, pySim has not been completely migrated to 3.x yet, so it<br>
>>> starts under 2.7 by default.  You can try to run it under 3.x:<br>
>>><br>
>>>    python3 ./pySim-read.py -p0<br>
>>><br>
>>> or install the 'smartcard' module for Python 2.7.<br>
>>><br>
>>> Best regards,<br>
>>> Vadim.<br>
>>><br>
>>> --<br>
>>> - Vadim Yanitskiy <vyanitskiy at <a href="http://sysmocom.de" rel="noreferrer" target="_blank">sysmocom.de</a>>    <a href="http://www.sysmocom.de/" rel="noreferrer" target="_blank">http://www.sysmocom.de/</a><br>
>>> =======================================================================<br>
>>> * sysmocom - systems for mobile communications GmbH<br>
>>> * Alt-Moabit 93<br>
>>> * 10559 Berlin, Germany<br>
>>> * Sitz / Registered office: Berlin, HRB 134158 B<br>
>>> * Geschaeftsfuehrer / Managing Director: Harald Welte<br>
</blockquote></div>