Using pelion without internal storage

Hello.
I try to modify pelion-ready-example on NUCLEO_F746ZG target to use without an internal flash storage.
To reach my goal I try to set external secure storage feature:

"mbed-cloud-client.external-sst-support": 1

After that I get compilation error:

./simple-mbed-cloud-client/mbed-cloud-client/mbed-client-pal/Source/Port/Reference-Impl/OS_Specific/mbedOS/ROT/pal_plat_rot.cpp:67:5: error: 'DeviceKey' was not declared in this scope

[Here] (DeviceKey was not declared for RZ_A1H target · Issue #10876 · ARMmbed/mbed-os · GitHub) I found solution and add FLASHIAP component:

"target.components_add" : ["FLASHIAP"],

Now it seems that internal flash is required again.
More over is correct compiled but fail on client initialization:

[DBG ][PAL ]: Init for the 1st time, initializing the modules
[DBG ][PAL ]: Network init
[DBG ][PAL ]: TLS init
[DBG ][PAL ]: Crypto init
[DBG ][PAL ]: Internal Flash init
[DBG ][PAL ]: SOTP init
[DBG ][PAL ]: init of SOTP module has failed with status 2
[DBG ][PAL ]: Destroying modules
[ERR ][PAL ]:
Init failed
[DBG ][PAL ]: FINISH PAL INIT
[ERR ][fcc ]: key_config_manager.c:43:kcm_init:<=== Failed initializing PAL (4294967294)
[ERR ][fcc ]: key_config_manager.c:103:kcm_item_store:<=== KCM initialization failed
[INFO][fcc ]: key_config_manager.c:98:kcm_item_store:===>
[INFO][fcc ]: key_config_manager.c:36:kcm_init:===>
[DBG ][PAL ]: Init for the 1st time, initializing the modules
[DBG ][PAL ]: Network init
[DBG ][PAL ]: TLS init
[DBG ][PAL ]: Crypto init
[DBG ][PAL ]: Internal Flash init
[DBG ][PAL ]: SOTP init
[DBG ][PAL ]: init of SOTP module has failed with status 2
[DBG ][PAL ]: Destroying modules
[ERR ][PAL ]:
Init failed
[DBG ][PAL ]: FINISH PAL INIT
[ERR ][fcc ]: key_config_manager.c:43:kcm_init:<=== Failed initializing PAL (4294967294)
[ERR ][fcc ]: key_config_manager.c:103:kcm_item_store:<=== KCM initialization failed
[INFO][fcc ]: factory_configurator_client.c:81:fcc_init:===>
[DBG ][PAL ]: Init for the 1st time, initializing the modules
[DBG ][PAL ]: Network init
[DBG ][PAL ]: TLS init
[DBG ][PAL ]: Crypto init
[DBG ][PAL ]: Internal Flash init
[DBG ][PAL ]: SOTP init
[DBG ][PAL ]: init of SOTP module has failed with status 2
[DBG ][PAL ]: Destroying modules
[ERR ][PAL ]:
Init failed
[DBG ][PAL ]: FINISH PAL INIT
[ERR ][fcc ]: factory_configurator_client.c:89:fcc_init:<=== Failed initializing internal storage (4294967294)
[ERR ][SMCC]: Factory Client Configuration failed with status 4
Pelion Client initialization failed (1)
[ERR ][UC  ]: [HUB ] update_client_hub.c:428: Update Client not initialized
[DBG ][mClt]: CloudClientStorage::uninitialize_storage
[INFO][fcc ]: key_config_manager.c:73:kcm_finalize:===>
[INFO][fcc ]: key_config_manager.c:89:kcm_finalize:<===

Here is my mbed_app.json

{
    "target_overrides": {
        "*": { 
            "platform.stdio-baud-rate"                  : 115200,
            "platform.stdio-convert-newlines"           : true,
            "mbed-trace.enable"                         : null,
            "nsapi.default-wifi-security"               : "WPA_WPA2",
            "nsapi.default-wifi-ssid"                   : "\"SSID\"",
            "nsapi.default-wifi-password"               : "\"Password\""
        },
	"NUCLEO_F746ZG": {
            "target.components_add"                     : ["SD"],
            "sd.SPI_MOSI"                               : "PC_12",
            "sd.SPI_MISO"                               : "PC_11",
            "sd.SPI_CLK"                                : "PC_10",
            "sd.SPI_CS"                                 : "PC_9",
            "device-management.flash-start-address"     : "0x08000000",
            "storage.storage_type"						: "FILESYSTEM_NO_RBP",
            "storage_filesystem_no_rbp.blockdevice"     : "SD",
            "storage_filesystem_no_rbp.mount_point"     : "fs",
            "storage_filesystem_no_rbp.folder_path"     : "kvstore",
            "update-client.storage-address"             : "(64*1024*1024)",
            "update-client.storage-size"                : "(2*1024*1024)",
            "update-client.storage-locations"           : 1,
            "mbed-cloud-client.external-sst-support"    : 1,
            "mbed-cloud-client.update-storage"          : "ARM_UCP_FILESYSTEM",
            "esp32.wifi-debug"                          : true,
            "esp32.wifi-en"                             : "PD_4",
            "esp32.wifi-io0"                            : "PD_3",
            "esp32.wifi-rts"                            : "NC",
            "esp32.wifi-cts"                            : "NC",
            "esp32.wifi-tx"                             : "PD_5",
            "esp32.wifi-rx"                             : "PD_6",
            "esp32.wifi-baudrate"                       : 115200,
            "mbed-trace.enable"							: 1
        }
    },
    "config": {
        "format-storage-layer-on-error": {
            "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
            "value": 1
        },
        "main-stack-size": {
            "value": 6000
        },
        "use-button": {
            "help": "Whether the target has a button",
            "macro_name": "USE_BUTTON",
            "value": true
        },
        "button-pressed-state": {
            "help": "Value of the button when pressed",
            "value": 1
        },
        "no_led": {
            "help": "This flag disables the heartbeat thread in tests. This is useful for platforms that don't have an LED or the LED is used for other functionality like LED on the SPI clockline etc",
            "value": null
        },
        "tests-fs-size": {
            "help": "Maximum size of the file system used for tests",
            "value": null
        }
    }
}

Is it possible to use pelion without using internal flash? And how I can make it?

Hi @SlavaDev503
Thank you for your question!

Unfortunately, I don’t have the device to reproduce, however, from the logs and code, I see that you get a failure from sotp_init, when internally it tries to erase internal flash.
As you can see from the code , the sotp_init() should not even be called if MBED_CONF_MBED_CLOUD_CLIENT_EXTERNAL_SST_SUPPORT is defined, which it should be defined, since you configured mbed-cloud-client.external-sst-support. Probably because of dependency between sotp and internal flash.
Please try updating your simple-mbed-cloud-client version as it seems that you are working on an old version.
in addition, I would suggest checking that MBED_CONF_MBED_CLOUD_CLIENT_EXTERNAL_SST_SUPPORT is in fact defined in your target’s mbed_config.h file
Regards,
Mbed Support
Ron

Ron, thank you for your response.
It seems that I send invalid log.
Actualy I get another error.
The updated config and log are below:
mbed_app.json:

{
    "target_overrides": {
        "*": { 
            "platform.stdio-baud-rate"                  : 115200,
            "platform.stdio-convert-newlines"           : true,
            "mbed-trace.enable"                         : null,
            "nsapi.default-wifi-security"               : "WPA_WPA2",
            "nsapi.default-wifi-ssid"                   : "\"SSID\"",
            "nsapi.default-wifi-password"               : "\"Password\""
        },
	"NUCLEO_F746ZG": {
            "target.components_add"                     : ["SD", "FLASHIAP"],
            "sd.SPI_MOSI"                               : "PC_12",
            "sd.SPI_MISO"                               : "PC_11",
            "sd.SPI_CLK"                                : "PC_10",
            "sd.SPI_CS"                                 : "PC_9",
            "device-management.flash-start-address"     : "0x08000000",
            "storage.storage_type"			: "FILESYSTEM_NO_RBP",
            "storage_filesystem_no_rbp.blockdevice"     : "SD",
            "storage_filesystem_no_rbp.mount_point"     : "fs",
            "storage_filesystem_no_rbp.folder_path"     : "kvstore",
            "update-client.storage-address"             : "(64*1024*1024)",
            "update-client.storage-size"                : "(2*1024*1024)",
            "update-client.storage-locations"           : 1,
            "mbed-cloud-client.external-sst-support"    : 1,
            "mbed-cloud-client.update-storage"          : "ARM_UCP_FILESYSTEM",
            "esp32.wifi-debug"                          : true,
            "esp32.wifi-en"                             : "PD_4",
            "esp32.wifi-io0"                            : "PD_3",
            "esp32.wifi-rts"                            : "NC",
            "esp32.wifi-cts"                            : "NC",
            "esp32.wifi-tx"                             : "PD_5",
            "esp32.wifi-rx"                             : "PD_6",
            "esp32.wifi-baudrate"                       : 115200,
            "mbed-trace.enable"				: 1
        }
    },
    "config": {
        "format-storage-layer-on-error": {
            "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
            "value": 1
        },
        "main-stack-size": {
            "value": 6000
        },
        "use-button": {
            "help": "Whether the target has a button",
            "macro_name": "USE_BUTTON",
            "value": true
        },
        "button-pressed-state": {
            "help": "Value of the button when pressed",
            "value": 1
        },
        "no_led": {
            "help": "This flag disables the heartbeat thread in tests. This is useful for platforms that don't have an LED or the LED is used for other functionality like LED on the SPI clockline etc",
            "value": null
        },
        "tests-fs-size": {
            "help": "Maximum size of the file system used for tests",
            "value": null
        }
    }
}

And log which I get with this configureation:

[INFO][fcc ]: key_config_manager.c:98:kcm_item_store:===>
[INFO][fcc ]: key_config_manager.c:36:kcm_init:===>
[DBG ][PAL ]: Init for the 1st time, initializing the modules

[DBG ][PAL ]: Network init

[DBG ][PAL ]: TLS init

[DBG ][PAL ]: Crypto init

[DBG ][PAL ]: Internal Flash init

[DBG ][PAL ]: FINISH PAL INIT

[INFO][fcc ]: storage.c:337:storage_rbp_read:===> item name =  saved_time
[INFO][FSST]: KV Dir: kvstore, doesnt exist - creating new..
[INFO][FSST]: Couldn't read: kvstore/saved_time
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[INFO][fcc ]: storage.c:345:storage_rbp_read:Item not found
[INFO][fcc ]: storage.c:337:storage_rbp_read:===> item name =  last_time_back
[INFO][FSST]: Couldn't read: kvstore/last_time_back
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[INFO][fcc ]: storage.c:345:storage_rbp_read:Item not found
[DBG ][fcc ]: storage.c:185:storage_init:===>
[INFO][FSST]: Couldn't read: kvstore/FR_ON
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[INFO][fcc ]: storage.c:590:storage_data_size_read:===> item name = renewal_status len=14
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=14
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_wmCfgParm_renewal_status
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[INFO][fcc ]: key_config_manager.c:64:kcm_init:<===
[INFO][fcc ]: storage_common.c:93:storage_data_write:===> item name =  mbed.VendorId len=13, data size=16
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=13
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_wCfgParam_mbed.VendorId
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=13
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_bCfgParam_mbed.VendorId
[DBG ][FSST]: File Verification failed, status: -2130771705
[ERR ][PAL ]: kv_status: 271, pal_sst status: 0xfc000a08
[ERR ][fcc ]: storage.c:559:storage_data_write_impl:<=== Failed to write data to backup
[ERR ][fcc ]: storage_common.c:123:storage_data_write:<=== storage_data_write_impl failed

[ERR ][fcc ]: key_config_manager.c:136:kcm_item_store:<=== Failed during storage_data_write
[INFO][fcc ]: key_config_manager.c:98:kcm_item_store:===>
[INFO][fcc ]: storage_common.c:93:storage_data_write:===> item name =  mbed.ClassId len=12, data size=16
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=12
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_wCfgParam_mbed.ClassId
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=12
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_bCfgParam_mbed.ClassId
[DBG ][FSST]: File Verification failed, status: -2130771705
[ERR ][PAL ]: kv_status: 271, pal_sst status: 0xfc000a08
[ERR ][fcc ]: storage.c:559:storage_data_write_impl:<=== Failed to write data to backup
[ERR ][fcc ]: storage_common.c:123:storage_data_write:<=== storage_data_write_impl failed

[ERR ][fcc ]: key_config_manager.c:136:kcm_item_store:<=== Failed during storage_data_write
[INFO][fcc ]: factory_configurator_client.c:81:fcc_init:===>
[DBG ][PAL ]: FINISH PAL INIT

[INFO][fcc ]: fcc_output_info_handler.c:463:fcc_init_output_info_handler:===>
[INFO][fcc ]: fcc_output_info_handler.c:470:fcc_init_output_info_handler:<===
[INFO][fcc ]: factory_configurator_client.c:97:fcc_init:<===
[DBG ][SMCS]: init() - BlockDevice init OK, bd->size() = 3980394496
[INFO][fcc ]: factory_configurator_client.c:236:fcc_rot_set:===> buf_size = 16
[ERR ][fcc ]: factory_configurator_client.c:245:fcc_rot_set:<=== Failed to set RoT
[INFO][SMCS]: Using hardcoded Root of Trust, not suitable for production use
[DBG ][SMCC]: Starting developer flow
[INFO][SMCC]: Resetting storage to an empty state...
[INFO][fcc ]: factory_configurator_client.c:137:fcc_storage_delete:===>
[DBG ][fcc ]: storage.c:212:storage_reset:===>
[DBG ][fcc ]: storage.c:217:storage_reset:<===
[INFO][fcc ]: factory_configurator_client.c:147:fcc_storage_delete:<===
[INFO][SMCC]: OK - Reset storage to an empty state...
[INFO][fcc ]: fcc_dev_flow.c:88:fcc_developer_flow:===>
[INFO][fcc ]: key_config_manager.c:98:kcm_item_store:===>
[INFO][fcc ]: storage_common.c:93:storage_data_write:===> item name =  mbed.UseBootstrap len=17, data size=4
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=17
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_wCfgParam_mbed.UseBootstrap
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=17
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_bCfgParam_mbed.UseBootstrap
[DBG ][FSST]: File Verification failed, status: -2130771705
[ERR ][PAL ]: kv_status: 271, pal_sst status: 0xfc000a08
[ERR ][fcc ]: storage.c:559:storage_data_write_impl:<=== Failed to write data to backup
[ERR ][fcc ]: storage_common.c:123:storage_data_write:<=== storage_data_write_impl failed

[ERR ][fcc ]: key_config_manager.c:136:kcm_item_store:<=== Failed during storage_data_write
[ERR ][fcc ]: fcc_dev_flow.c:97:fcc_developer_flow:<=== Store status: 1, Failed to store mbed.UseBootstrap
[DBG ][SMCC]: No developer credentials on storage layer yet
[INFO][SMCC]: Could not load certificate (e.g. no certificates or RoT might have changed), resetting storage...
[INFO][SMCC]: Resetting storage to an empty state...
[INFO][fcc ]: factory_configurator_client.c:137:fcc_storage_delete:===>
[DBG ][fcc ]: storage.c:212:storage_reset:===>
[DBG ][fcc ]: storage.c:217:storage_reset:<===
[INFO][fcc ]: factory_configurator_client.c:147:fcc_storage_delete:<===
[INFO][SMCC]: OK - Reset storage to an empty state...
[INFO][fcc ]: factory_configurator_client.c:236:fcc_rot_set:===> buf_size = 16
[ERR ][fcc ]: factory_configurator_client.c:245:fcc_rot_set:<=== Failed to set RoT
[INFO][SMCS]: Using hardcoded Root of Trust, not suitable for production use
[DBG ][SMCC]: Starting developer flow
[INFO][SMCC]: Resetting storage to an empty state...
[INFO][fcc ]: factory_configurator_client.c:137:fcc_storage_delete:===>
[DBG ][fcc ]: storage.c:212:storage_reset:===>
[DBG ][fcc ]: storage.c:217:storage_reset:<===
[INFO][fcc ]: factory_configurator_client.c:147:fcc_storage_delete:<===
[INFO][SMCC]: OK - Reset storage to an empty state...
[INFO][fcc ]: fcc_dev_flow.c:88:fcc_developer_flow:===>
[INFO][fcc ]: key_config_manager.c:98:kcm_item_store:===>
[INFO][fcc ]: storage_common.c:93:storage_data_write:===> item name =  mbed.UseBootstrap len=17, data size=4
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=17
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_wCfgParam_mbed.UseBootstrap
[DBG ][FSST]: File Verification failed, status: -2130771705
[DBG ][PAL ]: kv_status: 263, pal_sst status: 0xfc000a01
[DBG ][fcc ]: storage.c:149:storage_create_compelete_data_name:===> name len=17
[DBG ][fcc ]: storage.c:175:storage_create_compelete_data_name:<===
[INFO][FSST]: Couldn't read: kvstore/pelion_bCfgParam_mbed.UseBootstrap
[DBG ][FSST]: File Verification failed, status: -2130771705
[ERR ][PAL ]: kv_status: 271, pal_sst status: 0xfc000a08
[ERR ][fcc ]: storage.c:559:storage_data_write_impl:<=== Failed to write data to backup
[ERR ][fcc ]: storage_common.c:123:storage_data_write:<=== storage_data_write_impl failed

[ERR ][fcc ]: key_config_manager.c:136:kcm_item_store:<=== Failed during storage_data_write
[ERR ][fcc ]: fcc_dev_flow.c:97:fcc_developer_flow:<=== Store status: 1, Failed to store mbed.UseBootstrap
[DBG ][SMCC]: No developer credentials on storage layer yet
Pelion Client initialization failed (15)
[ERR ][UC  ]: [HUB ] update_client_hub.c:428: Update Client not initialized
[DBG ][mClt]: CloudClientStorage::uninitialize_storage
[INFO][fcc ]: key_config_manager.c:73:kcm_finalize:===>
[INFO][fcc ]: key_config_manager.c:89:kcm_finalize:<===

Hi Slava,
It is not clear to me what verision of the application you are working on.
With your mbed_app.json I get compilation errors, once of them is redefinition of MBED_CLOUD_CLIENT_UPDATE_STORAGE for example