Application update

Description

This folder aims to show how to update your application.

Hardware

This example uses a GAP9_EVK board.

How to run

  1. Build the SDK, the custom SSBL and the first application

    Note

    A layout is needed in your first application folder. It must contains one SSBL, system tables and your app, at least. See app1/ folder for more details on this layout.

    # In $GAP_SDK_HOME folder
    make clean all WITH_GUI_TOOLS=1
    

    WITH_GUI_TOOLS=1 is optional. It will allow you to do the update via the clisender’s GUI. Here we will suppose you do. Otherwise you will need to use the command line. See Host GAP CLI for more details.

  2. Flash application 1

    # In app1/ folder
    gap flash
    
  3. Boot

    Power-off the board, place a jumper on J10 (BOOT1) to boot from MRAM, and power-on the board.

  4. Enter update process

    Reset the board

  5. Update application

    Once the max boot counter is reached, the SSBL enters the CLI. You can process to the update.

    First, build the second application and get its description:

    # In app2/ folder
    gap init
    gap build
    gap flash_dump_app_sections
    

    The last command generates mram-description.json file. The latter is the json that you will give to the clisender.

    Then, launch the clisender:

    # WITH_GUI_TOOLS must have been set when building the SDK
    clisender
    
    • Connect your device (UART or SPI)

    • Open SSBL

    • Partition update by giving the json file freshly generated

    • Close SSBL

    • Close the clisender

    When closing the clisender, GAP will reboot and you should see your new app running.

Demonstration

Here are the config given to the custom SSBL:

CONFIG_BOOT_COUNTER=y
CONFIG_BOOT_COUNTER_MAX_TRY=3

Here is the layout used by app1:

Note

It contains more than just what is required, but reflects more a real case than just a basic example.

{
    "flashes":[
        {
            "name":"mram",
            "sections": [
                {
                    "name": "fsbl",
                    "template": "rom",
                    "properties": {
                        "binary": null,
                        "boot" :" true",
                        "subtype" : "fsbl"
                    }
                },
                {
                    "name": "meta_table",
                    "template": "meta table",
                    "properties": {
                        "ssbl_a": "ssbl_a",
                        "ssbl_b": "ssbl_b",
                        "pt_a": "partition table",
                        "pt_b": "partition table"
                    }
                },
                {
                    "name": "ssbl_a",
                    "template": "app binary",
                    "properties": {
                        "binary": null,
                        "compressed": true,
                        "subtype" : "ssbl"
                    }
                },
                {
                    "name": "ssbl_b",
                    "template": "app binary",
                    "properties": {
                        "binary": null,
                        "compressed": true,
                        "subtype" : "ssbl"
                    }
                },
                {
                    "name": "partition table",
                    "template": "partition table v2",
                    "properties": {
                        "size": 1024
                    }
                },
                {
                    "name": "volume table",
                    "template": "volume table"
                },
                {
                    "name": "secret_storage",
                    "template": "secret storage",
                    "properties": {
                        "encrypted": true,
                        "kc_list": [
                            {
                                "name": "pre_shared",
                                "id": 0,
                                "size" : 128
                            },
                            {
                                "name": "pubkey",
                                "id": 1,
                                "size" : 2176
                            }
                        ]
                    }
                },
                {
                    "name": "app",
                    "template": "app binary",
                    "properties": {
                        "binary": "ssbl_appupdate_app1"
                    }
                }
            ]
        },
        {
            "name":"flash",
            "sections": []
        }
    ]
}

Here are the logs of GAP from an UART port:

[09:57:32:898] LBoot ssbl a custom␊
[09:57:32:898] LBoot app␊
[09:57:32:898] LPartition app load test␊
[09:57:32:915] Loffset: 0x0000af90␊
[09:57:32:915] LGet App BIN description␊
[09:57:32:915] LApp_description: 0xc001b001␊
[09:57:32:915] LLoad App Bin␊
[09:57:32:933] Llaunch the app␊
[09:57:32:949] Hello from app 1[09:57:36:604] <break>
[09:57:36:779] LBoot ssbl a custom␊
[09:57:36:779] LBoot app␊
[09:57:36:779] LPartition app load test␊
[09:57:36:795] Loffset: 0x0000af90␊
[09:57:36:795] LGet App BIN description␊
[09:57:36:795] LApp_description: 0xc001b001␊
[09:57:36:795] LLoad App Bin␊
[09:57:36:812] Llaunch the app␊
[09:57:36:828] Hello from app 1[09:57:37:715] <break>
[09:57:37:874] LBoot ssbl a custom␊
[09:57:37:874] LBoot app␊
[09:57:37:874] LPartition app load test␊
[09:57:37:874] Loffset: 0x0000af90␊
[09:57:37:890] LGet App BIN description␊
[09:57:37:890] LApp_description: 0xc001b001␊
[09:57:37:890] LLoad App Bin␊
[09:57:37:904] Llaunch the app␊
[09:57:37:920] Hello from app 1[09:57:38:625] <break>
[09:57:38:784] LBoot ssbl a custom␊
[09:57:38:784] LBoot app␊
[09:57:38:784] LPartition app load test␊
[09:57:38:784] LApp failed to boot many times in a row, mark it invalid␊
[09:57:38:800] LFailed to load the active app volume (rc=5)[09:57:38:800] LBoot app failed -6␊
[09:57:38:800] LBoot recovery␊
[09:57:38:800] LCLI opened␊
[09:57:38:800] LCLI running␊
[09:58:45:005] LVolume table dump:␊
[09:58:45:005] L* Volume idx 0. uuid: 0x0000, label: app, nb: 1, max_nb: 5, desc: 0x1c11d3a0␊
[09:58:45:021] L* Volume idx 1. uuid: 0x0001, label: factory, nb: 7, max_nb: 11, desc: 0x1c11d3a8␊
[09:58:45:021] LVolume (uuid: 0x0000, label: app, flags: 0x0001, boot_counter: 0xFF, boot_order: 0x00) dump:␊
[09:58:45:038] L* [idx: 0] partition uuid: 0x0007, label: app␊
[09:59:29:699] LCLI closed␊
[09:59:29:699] LBoot recovery done[09:59:29:699] <break>
[09:59:29:730] LBoot ssbl a custom␊
[09:59:29:730] LBoot app␊
[09:59:29:730] LPartition app load test␊
[09:59:29:730] Loffset: 0x0000af90␊
[09:59:29:730] LGet App BIN description␊
[09:59:29:746] LApp_description: 0xc001b001␊
[09:59:29:746] LLoad App Bin␊
[09:59:29:759] Llaunch the app␊
[09:59:29:774] Hello from app 2[09:59:34:903] <break>
[09:59:35:094] LBoot ssbl a custom␊
[09:59:35:094] LBoot app␊
[09:59:35:094] LPartition app load test␊
[09:59:35:094] Loffset: 0x0000af90␊
[09:59:35:094] LGet App BIN description␊
[09:59:35:094] LApp_description: 0xc001b001␊
[09:59:35:110] LLoad App Bin␊
[09:59:35:120] Llaunch the app␊
[09:59:35:136] Hello from app 2[09:59:36:482] <break>
[09:59:36:657] LBoot ssbl a custom␊
[09:59:36:657] LBoot app␊
[09:59:36:657] LPartition app load test␊
[09:59:36:657] Loffset: 0x0000af90␊
[09:59:36:673] LGet App BIN description␊
[09:59:36:673] LApp_description: 0xc001b001␊
[09:59:36:673] LLoad App Bin␊
[09:59:36:688] Llaunch the app␊
[09:59:36:703] Hello from app 2[09:59:37:429] <break>
[09:59:37:572] LBoot ssbl a custom␊
[09:59:37:572] LBoot app␊
[09:59:37:572] LPartition app load test␊
[09:59:37:572] LApp failed to boot many times in a row, mark it invalid␊
[09:59:37:588] LFailed to load the active app volume (rc=5)[09:59:37:588] LBoot app failed -6␊
[09:59:37:588] LBoot recovery␊
[09:59:37:588] LCLI opened␊
[09:59:37:588] LCLI running␊
[10:00:48:017] LVolume table dump:␊
[10:00:48:033] L* Volume idx 0. uuid: 0x0000, label: app, nb: 1, max_nb: 5, desc: 0x1c11d3a0␊
[10:00:48:033] L* Volume idx 1. uuid: 0x0001, label: factory, nb: 7, max_nb: 11, desc: 0x1c11d3a8␊
[10:00:48:033] LVolume (uuid: 0x0000, label: app, flags: 0x0001, boot_counter: 0xFF, boot_order: 0x00) dump:␊
[10:00:48:049] L* [idx: 0] partition uuid: 0x0007, label: app␊
[10:01:27:930] LCLI closed␊
[10:01:27:930] LBoot recovery done[10:01:27:930] <break>
[10:01:27:962] LBoot ssbl a custom␊
[10:01:27:962] LBoot app␊
[10:01:27:962] LPartition app load test␊
[10:01:27:962] Loffset: 0x0000af90␊
[10:01:27:962] LGet App BIN description␊
[10:01:27:978] LApp_description: 0xc001b001␊
[10:01:27:978] LLoad App Bin␊
[10:01:27:990] Llaunch the app␊
[10:01:28:006] Hello from app 3