estkme-group / lpac

C-based eUICC LPA
GNU Affero General Public License v3.0
224 stars 61 forks source link

how to recover from an eSIM download that didn't write to the card? #101

Open AndySchroder opened 2 months ago

AndySchroder commented 2 months ago

Using profile download, I had it error out after provisioning on the server, but it didn't write to the eSIM card yet. I'm not sure if the card is full or what (https://github.com/estkme-group/lpac/issues/100). It seems to me like the eSIM data should be temporarily written to the local filesystem after downloading and then delete after successfully writing to the eSIM. That way we can re-try to write to the eSIM card if there was a failure instead of having to contact the provider and ask for another try. Right now it only seems to be stored in RAM.

Here's the output I got:


INFO: Connect
INFO: Open channel with AID a0000005591010ffffffff8900000100
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es10b_get_euicc_challenge_and_info'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es9p_initiate_authentication'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0, 'data': None, 'message': 'es10b_authenticate_server'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0, 'data': None, 'message': 'es9p_authenticate_client'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0, 'data': None, 'message': 'es10b_prepare_download'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es9p_get_bound_profile_package'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es10b_load_bound_profile_package'},
 'type': 'progress'}
INFO: Received LPA data. Printing...
{'payload': {'code': -1,
             'data': 'load_profile_elements,install_failed_due_to_pe_processing_error',
             'message': 'es10b_load_bound_profile_package'},
 'type': 'lpa'}
INFO: Close channel 2
close channel_id: 2
INFO: Disconnect
Exit code: 255

If I try again, I get

INFO: Connect
INFO: Open channel with AID a0000005591010ffffffff8900000100
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es10b_get_euicc_challenge_and_info'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0,
             'data': None,
             'message': 'es9p_initiate_authentication'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0, 'data': None, 'message': 'es10b_authenticate_server'},
 'type': 'progress'}
INFO: Received progress. Printing...
{'payload': {'code': 0, 'data': None, 'message': 'es9p_authenticate_client'},
 'type': 'progress'}
INFO: Received LPA data. Printing...
{'payload': {'code': -1,
             'data': 'Already in use',
             'message': 'es9p_authenticate_client'},
 'type': 'lpa'}
INFO: Close channel 2
close channel_id: 2
INFO: Disconnect
Exit code: 255

I'm using https://github.com/stich86/lpac-libmbim-wrapper , but I don't think that has to do with this problem.

damonto commented 2 months ago

The eSIM data will write to the eUICC chip directly. There is no way to write it to the local filesystem first.

I heard you are using 5ber eSIM. Unfortunately, 5ber eSIM has some bugs that may cause the download to fail. If you want to use the 5ber eSIM card, you may need to upgrade the firmware first.

We're working on the cancelSession function. It may resolve this problem.

AndySchroder commented 2 months ago

What would cancelSession do?

AndySchroder commented 2 months ago

I just tried again with another eSIM provider and was able to get it to work successfully. https://github.com/estkme-group/lpac/issues/100#issuecomment-2131970902 suggests there is a huge range in sizes for an eSIM though, so I don't yet know that this issue described above is due to card capacity or not. The one that didn't work was 3x the cost of the ones that did work though, but I don't know that cost of the plan should necessarily have any relationship to the data size of the eSIM.

AndySchroder commented 2 months ago

In https://github.com/estkme-group/lpac/issues/100 you suggest there is no definite way to know the profile size in advance. Seems like after downloading and you finally know the size, you should check the available memory on the chip before attempting to write. If you know there isn't enough space, give a warning message and write the profile to a file on the local filesystem to allow the user a chance to put it on a different SIM or delete old profiles first.

AndySchroder commented 2 months ago

There is no way to write it to the local filesystem first.

I don't understand why you can't save to some kind of file.

AndySchroder commented 2 months ago

I heard you are using 5ber eSIM. Unfortunately, 5ber eSIM has some bugs that may cause the download to fail. If you want to use the 5ber eSIM card, you may need to upgrade the firmware first.

I am getting some other eSIM to try from a different manufacturer and will see if it behaves differently with this problem service provider. Will report back on that in a few weeks.

damonto commented 2 months ago

If you want to know more about the technology details, you can read this document:

GSMA eSIM SGP.22 eSIM whitepaper IIJ Technical Seminar DAY2018 ~ eSIM とは何か

It is very useful for understanding how eUICC works and how lpac works.

Lasibian commented 2 months ago

@AndySchroder Which esim profile did you try to load unto your 5ber card?

AndySchroder commented 2 months ago

you mean which supplier?

Lasibian commented 2 months ago

Yes, the supplier.

AndySchroder commented 2 months ago

So, cancelSession can work even if the profile never made it to the eSIM card?