SIM (SmartCard) driver for i.mx25 (LINUX)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SIM (SmartCard) driver for i.mx25 (LINUX)

5,425 Views
V_Palacio
Contributor V

Hello All,

 

I have ported a SIM driver from i.mx51 to i.mx25. Now, when driver is fully ported (i.e., compiles and initializes SIM related hw), I 'm trying to use it, but there is no documentation about driver.

 

 https://lists.ubuntu.com/archives/kernel-team/2009-July/006395.html

 

Anybody have experience using SIM/SmartCard driver for i.mx51?

 

Regards,

0 Kudos
Reply
12 Replies

2,386 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

    For iMX25 board, to enable the SIM, you need add "sim" in uboot command lines, without this "sim", the code to config pins for SIM will be skipped in kernel file "mx25_3stack-gpio.c".

    The SIM card test code can be found at "imx-test-09.12.00\test\mxc_sim_test\", it works for iMX25 3stack board with L2.6.31_09.12.00 BSP.

0 Kudos
Reply

2,386 Views
erickang
Contributor II

Dear Qiang Li,

I have 2 questions for SIM control,

1 for adding "sim" in uboot command line and 1 for performing the SIM Test by using "mxc_sim_test.out".

1) "sim" uboot command line

   - How do I add "sim" in uboot command line?

     Could you show me the example to add "sim" in uboot command line?

   - I think the below will be an example,

     Change the bootargs_base of u-boot environment,

      from "setenv bootargs console=ttymxc0,115200"

      to "setenv bootargs console=ttymxc0,115200 sim"

2) perform the SIM Test

   - How do I perform the SIM Test by using mxc_sim_test.out "imx-test-09.12.00\test\mxc_sim_test\"?

   - In the code, I showed the SIM command usage,  "~ $ gsmdemo <pin>".

     So I think I can perform the SIM Test with "./mxc_sim_test.out <pin>"

     But I don't know what is the <pin>.

   - Now I'm using the SIM1_TX pin of SIM1(CSI_D5 pin of CPU) as Inout Data pin.

Best Regards,

Eric.

0 Kudos
Reply

2,386 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

For 1), you are right.

For 2), for pin, after checked the code, I think it hasn't been used, you can fill any value for pin. The test will dump some information from the SIM card and print out on console.


0 Kudos
Reply

2,386 Views
erickang
Contributor II

Dear Qiang Li,

Thanks for your response.

I have 2 questions for the SIM Interface.

1) SIM Application build method as standalone

    - I saw the Makefile in the imx-test-09.12.01/test/mxc_sim_test.

      I could build the mxc_sim_test.out file by using this Makefile.

      But I want to build the mxc_sim_test.c file as standalone.

      How do I build the mxc_sim_test.c file?

      In the Makefile, the file is built by using the below commmand.

      $(CC) -lpthread -o $(TARGET) $(OBJS) -lsim

    - In other words, I want to build the only mxc_sim_test.c file.

      For example, I will build the file like as the below commands.

      arm-none-linux-gnueabi-gcc mxc_sim_test.c -o mxc_sim_test

      with SIM library like as -lpthread and -lsim

      I want to know how to apply the -lpthread and -lsim library in the single build command line.

2) User Space Library

    - I confirmed the below SIM interface information

      in the "Chapter 27.2 Software Operation of SIM Driver" of i.MX25 PDK Linux Reference Manual.

      The SIM interface driver package for the i.MX familiy consist of two basic parts

      : the SIM kernel interface driver and the a user space library to simplify development.

    - Could you give me
      the User Space Library API Document and the source code for the User Space Library?

Best Regards,

Eric.


0 Kudos
Reply

2,386 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

    The libsim.so code can be found at "imx-lib-09.12.00\sim".  There is no API document, but you can find the description for those APIs in file "iso7816-3.c".

    Attached is two example "Makefile" to make the libsim.so and mxc_sim_test.out alone. You can unzip and put them into your home folder of Linux system. You need to check the followed setting in the Makefile to meet your PC setting before make them, and libsim should be made first.

TOOL_DIR =/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin

CC=$(TOOL_DIR)/arm-none-linux-gnueabi-gcc

PLATFORM_INC_DIR = /home/user/ltib/rpm/BUILD/linux-2.6.31/include

LIBSIM_DIR = "/home/user/libsim"

0 Kudos
Reply

2,386 Views
leonardoalmeida
Contributor I

Hi,

I'm involved with the same quest. When I run the "./mxc_sim_test.out <pin>", I got the following answer: "ReaderStart -22 2".

I saw into "mxc_sim_test.c" code that's an error. I think the error cause is the missing device "/dev/mxc_sim". In my rootfs there is no "/dev/mxc_sim" device.  I also think ltib creates the device.

Anyone of you could help me?

For noticing, the error occours in both boot modes, nand and nfs.

My u-boot variables are:

bootargs_base=setenv bootargs console=ttymxc0,115200 sim

bootcmd_net=run bootargs_base bootargs_nfs; tftpboot ${loadaddr} ${kernel}; bootm

bootcmd_nand=run bootargs_base bootargs_nand; nand read ${loadaddr} 0x300000 0x200000;bootm

I really appreciate your help.

0 Kudos
Reply

2,386 Views
qiang_li-mpu_se
NXP Employee
NXP Employee

For default setting, the SIM driver was built as module, did you insmod the "imx_sim.ko" before run the sim test application?

If the sim driver was loaded successfully, you should see the device "/dev/mxc_sim" in your run time rootfs.

0 Kudos
Reply

2,386 Views
leonardoalmeida
Contributor I

Hi, Qiang Li.

I've also located the module into ltib menu, and I changed it for "* ", instead of "M". After that, the device appears into "/dev". And I can send commands for the card now!

Now I have read your answer, I came back the configuration for "M" and the module was up, as the device. Is there any configuration for loading the modules automatcally?

Thanks for the help.

edit: Now I have other problem.When I run the test, I got errors for PDU commands. I tried to create my own test, sending command manually, and I still got error. The response is always 0x6060. I think it might be configuration parameters problem or driver problems. Anyway, I think the test should work. I've tried with two smartcards.

The return from mxc_sim_test.out:

root@freescale /unit_tests$ ./mxc_sim_test.out 1
Using pin 0001
ValidATR
ATR: 3b 68 00 ff 00 73 c8 40 13 00 90 00 3b 68 00 ff 00 73 c8 40 13 00 90 00
COM parameters: F = 372 D = 64/64 N = 0 T = 0
VERIFY PIN: SW = 6060 (24672)

Reading ICCID
SELECT FILE MF: SW = 6060 (24672)
SELECT FILE EF 2fe2: SW = 6060 (24672)
READ BINARY: SW = 6060 (24672)
ICCID: 00 00 00 00 00 00 00 00 00 00

Reading IMSI
SELECT FILE MF: SW = 6060 (24672)
SELECT FILE DF 7f20: SW = 6060 (24672)
SELECT FILE EF 6f07: SW = 6060 (24672)
READ BINARY: SW = 6060 (24672)
IMSI: 00 00 00 00 00 00 00 00 00

Reading KC
SELECT FILE EF 6f20: SW = 6060 (24672)
READ BINARY: SW = 6060 (24672)
KC: 00 00 00 00 00 00 00 00 00

Reading HPLMN
SELECT FILE EF 6f31: SW = 6060 (24672)
READ BINARY: SW = 6e00 (28160)
HPLMN: 00

Reading ACMax
SELECT FILE EF 6f37: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
ACMax: 00 00 00

Reading SST
SELECT FILE EF 6f38: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
SST: 00 00 00 00 00

Reading PUCT
SELECT FILE EF 6f41: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
PUCT: 00 00 00 00 00

Reading BCCH
SELECT FILE EF 6f74: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
BCCH: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Reading ACC
SELECT FILE EF 6f78: SW = 6884 (26756)
READ BINARY: SW = 6881 (26753)
ACC: 00 00

Reading FPLMN
SELECT FILE EF 6f7b: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
FPLMN: 00 00 00 00 00 00 00 00 00 00 00 00

Reading LOCI
SELECT FILE EF 6f7e: SW = 6985 (27013)
READ BINARY: SW = 6881 (26753)
LOCI: 00 00 00 00 00 00 00 00 00 00 00

Reading PHASE
SELECT FILE EF 6fae: SW = 6881 (26753)
READ BINARY: SW = 6881 (26753)
PHASE: 00
ValidATR
ATR: 3b 68 00 ff 00 73 c8 40 13 00 90 00
VERIFY PIN: SW = 6060 (24672)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (0060)
data received unexpectidly (006e)
data received unexpectidly (0000)

0 Kudos
Reply

2,386 Views
erickang
Contributor II

Dear Qiang Li,

Thanks for your rapid response.

I confirmed the SIM operation with your files, libsim and mxc_sim_test.

Best Regards,

Eric.

0 Kudos
Reply

2,386 Views
erickang
Contributor II

Thanks for your response.

I'll let you know the result after the SIM Operation.

0 Kudos
Reply

2,386 Views
fabio_estevam
NXP Employee
NXP Employee

The upcoming Freescale Linux BSP (SDK1.6) does provide SIM driver for MX51 and MX25.

 

Regards,

 

Fabio Estevam

0 Kudos
Reply

2,386 Views
erickang
Contributor II

Dear Fabio Estevam,

I have a question for Freescale Linux BSP version.

You mentioned the SDK1.6 as the Freescale Linux BSP version.

How can I confirm the SDK version in the downloaded BSP?

I'm using the L2.6.31_09.12.00_SDK_source.tar.gz.

Best Regards,

Eric.

0 Kudos
Reply