bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Correct usage of select() and sim()

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Tue Feb 15, 2011 4:18 pm    Post subject: Correct usage of select() and sim() Reply with quote

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
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Tue Feb 15, 2011 5:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Wed Feb 16, 2011 8:27 am    Post subject: Reply with quote

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
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Wed Feb 16, 2011 3:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Sat Feb 19, 2011 7:49 am    Post subject: Reply with quote

Can you post a longer trace, from reset to the time phone connects to the network? (Remove sms/phonebook related apdus.)
Back to top
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Mon Feb 21, 2011 12:57 pm    Post subject: Reply with quote

I have sent you a test code producing this issue by e-mail.
Back to top
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Tue Mar 01, 2011 4:31 pm    Post subject: Reply with quote

Any news?......
Back to top
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Tue Mar 01, 2011 5:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Mon Aug 29, 2011 7:59 am    Post subject: Reply with quote

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
View user's profile Send private message
jacko



Joined: 20 Dec 2010
Posts: 19

PostPosted: Tue Sep 27, 2011 8:36 am    Post subject: Reply with quote

No news ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group