onomondo / nrf-softsim

Manifest repo for integrating SoftSIM and nrf-sdk
24 stars 6 forks source link

Fix provisioning check inconsistencies and other minor changes #18

Closed MirkoCovizzi closed 8 months ago

MirkoCovizzi commented 8 months ago

This PR addresses some issues regarding connectivity caused by improper provisioning steps.

When flashing a new firmware, the device can be in two states:

When flashing a new firmware and bundling a SIM profile template, we are also overwriting the NVS file system that contains some of the SIM profile information. Flashing does not erase the tfm_storage partition so previous keys may still be present. We want to provision when the profile template has not been provisioned (so it contains still default values). If we provision when there are already provisioned keys in the tfm_storage, with the current implementation we will get errors because the keys exist already. They also may be inconsistent with the current profile being checked/provisioned. To fix this, during provisioning step, always delete KI, KIC, KID and import the new ones that are guaranteed to be compatible with the new profile. This change introduces a coupling between the nvs_storage part of the profile and the tfm_storage part. This change is working under the assumption that the default (unprovisioned) IMSI when flashing a "fresh" template is always: [0x08, 0x09, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10] (@peterbornerup please correct me if this assumption is wrong).

Other minor changes:

With these changes the samples can now attach correctly to the network and connect successfully to the server.