| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Tue Feb 15, 2011 4:18 pm    Post subject: Correct usage of select() and sim() | 
				     | 
			 
			
				
  | 
			 
			
				Hello,
 
 
I am trying to use select() and sim() to read the IMSI from the SIM card.
 
 
I have the following code:
 
 
u8 PROGMEM ef_imsi_path[] = { 0x3F, 0x00, 0x7F, 0x20, 0x6F, 0x07 };
 
 
void read_imsi(u8* imsibuf)
 
{
 
u8 path[6];
 
memcpy(path, ef_imsi_path, 6);
 
select(ef_imsi_path, 3);
 
sim(ME_CMD_READ_BINARY, 0x00, 0x00, 0x09, imsibuf);
 
select(0, 0);
 
}
 
 
From here, imsibuf contains data that changes each time I boot, but it always start with 6981.
 
 
NB: This function is called from a stk_thread called in ACTION_FIRST_STK
 
 
Is 6981 the return code from the card? If so, it means "Command incompatible with file structure".
 
 
What's happening? | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz
 
 
  Joined: 12 Mar 2004 Posts: 1161
 
  | 
		
			
				 Posted: Tue Feb 15, 2011 5:15 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| Here trace of whole ME-TL2-SIM would help to see all picture. Btw. you init path but then don't use it, is it what you want? | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Wed Feb 16, 2011 8:27 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				 	  | pz wrote: | 	 		  | Here trace of whole ME-TL2-SIM would help to see all picture. | 	  
 
 
I heard about a L1 debug kernel on this forum, is it available somewhere?
 
You can send it to the e-mail address associated with this account.
 
 
 	  | pz wrote: | 	 		  | Btw. you init path but then don't use it, is it what you want? | 	  
 
 
Yes sorry, the code I am actually using is :
 
 
 	  | Code: | 	 		  
 
u8 PROGMEM ef_imsi_path[] = { 0x3F, 0x00, 0x7F, 0x20, 0x6F, 0x07 };
 
 
void read_imsi(u8* imsibuf)
 
{
 
u8 path[6];
 
memcpy(path, ef_imsi_path, 6);
 
select(path, 3);
 
sim(ME_CMD_READ_BINARY, 0x00, 0x00, 0x09, imsibuf);
 
select(0, 0);
 
} | 	  
 
 
I have tried with two different SIM cards from different operators and the problem is the same. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Wed Feb 16, 2011 3:16 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				I have received the L1 debug kernel and have tried it.
 
It seems to show that there is indeed a problem with the kernel code.
 
 
Dbg output:
 
 
 	  | Code: | 	 		  3f007f206f07
 
TO SIM:   00 a4 00 00 02
 
TO SIM:   3f 00 
 
FROM SIM: 6b 00 
 
TO SIM:   00 b0 00 00 09
 
FROM SIM: 69 81 
 
TO SIM:   00 a4 00 00 02
 
TO SIM:   3f 00 
 
FROM SIM: 6b 00 
 
6981e5f1fbdfbf5f45
 
 | 	  
 
 
Associated code:
 
 
 	  | Code: | 	 		  u8 PROGMEM ef_imsi_path[6] = { 0x3F, 0x00, 0x7F, 0x20, 0x6F, 0x07 };
 
 
void readSim_IMSI (u8* imsi)
 
{
 
   u8 path[6];
 
   u8 i;
 
 
   memcpy(path, ef_imsi_path, 6);
 
 
   for (i=0; i<6; i++)
 
      dbch(path[i]);
 
   dbc('\n');
 
 
   select(path, 3);
 
   sim(ME_CMD_READ_BINARY, 0x00, 0x00, 0x09, imsi);
 
   select(0, 0);
 
 
   for (i=0; i<9; i++)
 
      dbch(imsi[i]);
 
   dbc('\n');
 
}
 
 | 	  
 
 
Please advise on what to do | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz
 
 
  Joined: 12 Mar 2004 Posts: 1161
 
  | 
		
			
				 Posted: Sat Feb 19, 2011 7:49 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| Can you post a longer trace, from reset to the time phone connects to the network? (Remove sms/phonebook related apdus.) | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Mon Feb 21, 2011 12:57 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| I have sent you a test code producing this issue by e-mail. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Tue Mar 01, 2011 4:31 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| Any news?...... | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		pz
 
 
  Joined: 12 Mar 2004 Posts: 1161
 
  | 
		
			
				 Posted: Tue Mar 01, 2011 5:23 pm    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| Eeeh I answered on your email that if you could send us the whole debug from reset. This is related to what SIM (USIM resp.) is used so your log is needed. | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Mon Aug 29, 2011 7:59 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				Hello,
 
 
I have sent a full log by e-mail, finally.
 
 
Could you please check it out and let me know how I can workaround the bug ?
 
 
Thanks | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		jacko
 
 
  Joined: 20 Dec 2010 Posts: 19
 
  | 
		
			
				 Posted: Tue Sep 27, 2011 8:36 am    Post subject:  | 
				     | 
			 
			
				
  | 
			 
			
				| No news ? | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |