SSBL update
Description
This folder aims to show how to update your SSBL.
Hardware
This examples uses a GAP9_EVK board.
How to run
Build the SDK, the first SSBL and the application
Note
A layout is needed in your application folder. It must contains two SSBL, system tables and your app, at least. See app/ 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.# In ssbl_a/ folder gap init gap build
# In app/ folder gap init gap build
Flash application
# In app/ folder gap flash
Boot
Power-off the board, place a jumper on J10 (BOOT1) to boot from MRAM, and power-on the board.
Enter update process
Reset the board
Update SSBL
Once the max boot counter is reached, the SSBL enters the CLI. You can process to the update.
First, build the second SSBL and get its description:
Warning
It must have a custom layout with the
ssbl_b
field filled with its binary. Otherwise it will be interpeted as a classic app and the description will be wrong. See ssbl_b/ for more details on the layout.# In ssbl_b/ folder gap init gap build gap flash_dump_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 and by selecting the `SSBL update` checkbox
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 first SSBL:
CONFIG_BOOT_COUNTER=y
CONFIG_BOOT_COUNTER_MAX_TRY=3
Here are the config given to the second SSBL:
CONFIG_FLASH_LAYOUT_CUSTOM=y
CONFIG_FLASH_LAYOUT_PATH="layout/ssbl_b_layout.json"
CONFIG_BOOT_COUNTER=y
CONFIG_BOOT_COUNTER_MAX_TRY=2
Here is the layout used by application:
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_ssblupdate_app"
}
}
]
},
{
"name":"flash",
"sections": []
}
]
}
Here are the logs of GAP from an UART port:
[17:41:12:392] LBoot ssbl a␊
[17:41:12:392] LBoot app␊
[17:41:12:392] LPartition app load test␊
[17:41:12:392] Loffset: 0x00015b80␊
[17:41:12:407] LGet App BIN description␊
[17:41:12:407] LApp_description: 0xc001b001␊
[17:41:12:407] LLoad App Bin␊
[17:41:12:421] Llaunch the app␊
[17:41:12:438] Hello from app␊
[17:41:13:334] <break>
[17:41:13:510] LBoot ssbl a␊
[17:41:13:510] LBoot app␊
[17:41:13:510] LPartition app load test␊
[17:41:13:510] Loffset: 0x00015b80␊
[17:41:13:525] LGet App BIN description␊
[17:41:13:525] LApp_description: 0xc001b001␊
[17:41:13:525] LLoad App Bin␊
[17:41:13:540] Llaunch the app␊
[17:41:13:555] Hello from app␊
[17:41:14:199] <break>
[17:41:14:375] LBoot ssbl a␊
[17:41:14:375] LBoot app␊
[17:41:14:375] LPartition app load test␊
[17:41:14:375] Loffset: 0x00015b80␊
[17:41:14:375] LGet App BIN description␊
[17:41:14:375] LApp_description: 0xc001b001␊
[17:41:14:391] LLoad App Bin␊
[17:41:14:399] Llaunch the app␊
[17:41:14:415] Hello from app␊
[17:41:14:982] <break>
[17:41:15:142] LBoot ssbl a␊
[17:41:15:142] LBoot app␊
[17:41:15:142] LPartition app load test␊
[17:41:15:158] LApp failed to boot many times in a row, mark it invalid␊
[17:41:15:158] LFailed to load the active app volume (rc=5)␊
[17:41:15:158] LBoot app failed -6␊
[17:41:15:158] LBoot recovery␊
[17:41:15:158] L␊
[17:41:15:158] LUART ID: 0 - BPS: 115200 - FC: 1␊
[17:41:15:173] LCLI opened␊
[17:41:15:173] LCLI running␊
[17:41:15:173] LWaiting new command␊
[17:41:25:429] L[CLI command]: SSBL CTRL Open␊
[17:41:25:429] LOpening mram␊
[17:41:25:429] LLoading the partition table␊
[17:41:25:429] LLoading successful␊
[17:41:25:429] Lptable_offset = 0x15080␊
[17:41:25:429] Lvtable found␊
[17:41:25:429] LVolume table dump:␊
[17:41:25:445] L* Volume idx 0. uuid: 0x0000, label: app, nb: 1, max_nb: 5, desc: 0x1c11e650␊
[17:41:25:445] L* Volume idx 1. uuid: 0x0001, label: factory, nb: 7, max_nb: 11, desc: 0x1c11e658␊
[17:41:25:445] LApp volume found␊
[17:41:25:461] LVolume (uuid: 0x0000, label: app, flags: 0x0001, boot_counter: 0xFF, boot_order: 0x00) dump:␊
[17:41:25:461] L* [idx: 0] partition uuid: 0x0007, label: app␊
[17:41:25:461] LSSBL control opened␊
[17:41:25:461] LStatus 0x3␊
[17:41:25:477] LReplying 0xfe␊
[17:41:25:477] LWaiting new command␊
[17:41:39:781] L[CLI SSBL command]: partition update␊
[17:41:39:781] Lpayload size = 39184␊
[17:41:39:781] Lpart info size = 16␊
[17:41:39:781] LSSBL update: 1␊
[17:41:43:188] LFirst frame: 1␊
[17:41:43:188] LUpdating partition: ssbl_b␊
[17:41:43:188] LFlash the bin (39184 bytes) in 1 flash, part cur offset = 0␊
[17:41:43:188] LBin flashed␊
[17:41:43:204] LResetting boot counter␊
[17:41:43:204] LPartition fully updated␊
[17:41:43:204] LStatus 0x3␊
[17:41:43:204] LReplying 0xfb␊
[17:41:43:204] LWaiting new command␊
[17:41:45:860] L[CLI SSBL command]: ssbl ctrl exit␊
[17:41:45:860] LClosing SSBL control␊
[17:41:45:876] LSSBL closed␊
[17:41:45:876] LStatus 0x3␊
[17:41:45:876] LReplying 0xfb␊
[17:41:45:876] LWaiting new command␊
[17:41:47:883] L[Cli command]: Closing the cli␊
[17:41:47:883] LCLI closed␊
[17:41:47:883] LBoot recovery done␊
[17:41:47:883] <break>
[17:41:47:914] LBoot ssbl b␊
[17:41:47:914] LBoot app␊
[17:41:47:914] LPartition app load test␊
[17:41:47:914] Loffset: 0x00015b80␊
[17:41:47:914] LGet App BIN description␊
[17:41:47:930] LApp_description: 0xc001b001␊
[17:41:47:930] LLoad App Bin␊
[17:41:47:943] Llaunch the app␊
[17:41:47:957] Hello from app␊
[17:41:54:564] <break>
[17:41:54:755] LBoot ssbl b␊
[17:41:54:755] LBoot app␊
[17:41:54:755] LPartition app load test␊
[17:41:54:771] Loffset: 0x00015b80␊
[17:41:54:771] LGet App BIN description␊
[17:41:54:771] LApp_description: 0xc001b001␊
[17:41:54:771] LLoad App Bin␊
[17:41:54:791] Llaunch the app␊
[17:41:54:806] Hello from app␊
[17:41:55:891] <break>
[17:41:56:066] LBoot ssbl b␊
[17:41:56:066] LBoot app␊
[17:41:56:066] LPartition app load test␊
[17:41:56:082] LApp failed to boot many times in a row, mark it invalid␊
[17:41:56:082] LFailed to load the active app volume (rc=5)␊
[17:41:56:082] LBoot app failed -6␊
[17:41:56:082] LBoot recovery␊
[17:41:56:082] LCLI opened␊
[17:41:56:098] LCLI running␊