Skip to content

Commit c865a77

Browse files
authored
config for internal flash only and SOTP offsets
* Remove a deprecated PAL config * Add configuration file for internal flash only configuration * Add config for max firmware size So we can check the firmware candidate actually fits inside the flash and does not infringe on any firmware storage. * Simplify configuration system * Add sotp related configs and Explicitly set sotp locations * Check size firmware candidate Reject firmware candidate that will not fit * Do not use SOTP for power cut test
1 parent 3f99f43 commit c865a77

12 files changed

+303
-121
lines changed

Jenkinsfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ def morpheusBuildStep(target,
121121
execute("mbed compile -m ${target} -t ${toolchain} -c -v --profile=tiny.json")
122122

123123
if (toolchain == "ARM") {
124-
// setup dependencies
125-
execute("power_cut_test/setup_dependencies.sh")
124+
// setup power cut test dependencies
125+
execute("mbed add https://github.com/ARMmbed/power-cut-jig --protocol ssh")
126126

127127
// build with test setup
128128
execute("mbed ls")
129-
execute("mbed compile -m ${target} -t ${toolchain} -c -v --profile=tiny.json")
129+
app_config = "power_cut_test/test_mbed_app.json"
130+
execute("mbed compile -m ${target} -t ${toolchain} -c -v --profile=tiny.json --app-config ${app_config}")
130131
archive "BUILD/${target}/${toolchain}/mbed-bootloader-internal.bin"
131132

132133
// Test with power cut hardware

configs/internal_flash_config.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"macros": [
3+
"MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
4+
"MAX_COPY_RETRIES=1",
5+
"SHOW_PROGRESS_BAR=1",
6+
"MAX_BOOT_RETRIES=3",
7+
"ARM_UC_USE_PAL_CRYPTO=0",
8+
"Mutex=PlatformMutex",
9+
"PAL_USE_INTERNAL_FLASH=1",
10+
"PAL_THREAD_SAFETY=0",
11+
"ARM_UC_USE_SOTP=1",
12+
"MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP"
13+
],
14+
"config": {
15+
"application-start-address": {
16+
"help": "Address of the active application firmware in flash",
17+
"value": null
18+
},
19+
"max-application-size": {
20+
"help": "Maximum size of the active application",
21+
"value": null
22+
},
23+
"sotp-section-1-address": {
24+
"help": "Flash sector address for SOTP sector 1",
25+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
26+
"value": null
27+
},
28+
"sotp-section-1-size": {
29+
"help": "Flash sector size for SOTP sector 1",
30+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
31+
"value": null
32+
},
33+
"sotp-section-2-address": {
34+
"help": "Flash sector address for SOTP sector 2",
35+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
36+
"value": null
37+
},
38+
"sotp-section-2-size": {
39+
"help": "Flash sector size for SOTP sector 2",
40+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
41+
"value": null
42+
}
43+
},
44+
"target_overrides": {
45+
"*": {
46+
"target.features_remove": ["LWIP"],
47+
"target.features_add": ["COMMON_PAL"],
48+
"platform.stdio-baud-rate": 115200,
49+
"platform.stdio-flush-at-exit": false,
50+
"update-client.firmware-header-version": "2"
51+
},
52+
"K64F": {
53+
"sotp-section-1-address" : "32*1024",
54+
"sotp-section-1-size" : "4*1024",
55+
"sotp-section-2-address" : "36*1024",
56+
"sotp-section-2-size" : "4*1024",
57+
"update-client.application-details": "40*1024",
58+
"application-start-address" : "41*1024",
59+
"max-application-size" : "(MBED_CONF_UPDATE_CLIENT_STORAGE_ADDRESS-MBED_CONF_APP_APPLICATION_START_ADDRESS)",
60+
"update-client.storage-address" : "436*1024",
61+
"update-client.storage-size" : "388*1024",
62+
"update-client.storage-locations" : 1,
63+
"update-client.storage-page" : 8
64+
}
65+
}
66+
}

firmware_update_test/firmware_update_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ void copyAppToSDCard(uint32_t firmware_size)
3737

3838
tr_info("calculate firmware SHA256\r\n");
3939
const uint8_t* appStart =
40-
(const uint8_t*) (MBED_CONF_APP_FIRMWARE_METADATA_HEADER_ADDRESS +
41-
MBED_CONF_APP_FIRMWARE_METADATA_HEADER_SIZE);
40+
(const uint8_t*) (MBED_CONF_APP_APPLICATION_START_ADDRESS);
4241
mbedtls_sha256(appStart, firmware_size, details.hash, 0);
4342

4443
details.version = UINT32_MAX - 1;

mbed_app.json

Lines changed: 90 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,130 @@
11
{
22
"macros": [
33
"MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
4-
"PAL_USE_FATFS_SD=1",
5-
"MAX_FIRMWARE_LOCATIONS=1",
64
"MAX_COPY_RETRIES=1",
75
"SHOW_PROGRESS_BAR=1",
86
"MAX_BOOT_RETRIES=3",
9-
"ARM_UC_USE_PAL_CRYPTO=0",
107
"Mutex=PlatformMutex",
11-
"ARM_UC_USE_PAL_BLOCKDEVICE=1",
128
"PAL_USE_INTERNAL_FLASH=1",
139
"PAL_THREAD_SAFETY=0",
14-
"ARM_UC_USE_SOTP=1"
10+
"ARM_UC_USE_PAL_CRYPTO=0",
11+
"ARM_UC_USE_SOTP=1",
12+
"ARM_UC_USE_PAL_BLOCKDEVICE=1",
13+
"MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE"
1514
],
1615
"config": {
17-
"firmware_metadata_header_address": {
18-
"help": "Firmware metadata header in flash",
16+
"application-start-address": {
17+
"help": "Address of the active application firmware in flash",
18+
"value": null
19+
},
20+
"max-application-size": {
21+
"help": "Maximum size of the active application",
1922
"value": null
2023
},
21-
"firmware_metadata_header_size": {
22-
"help": "Firmware metadata header size",
24+
"sotp-section-1-address": {
25+
"help": "Flash sector address for SOTP sector 1",
26+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
2327
"value": null
2428
},
25-
"serial_baudrate": {
26-
"help": "Terminal default baudrate",
27-
"value": 115200
29+
"sotp-section-1-size": {
30+
"help": "Flash sector size for SOTP sector 1",
31+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
32+
"value": null
33+
},
34+
"sotp-section-2-address": {
35+
"help": "Flash sector address for SOTP sector 2",
36+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
37+
"value": null
38+
},
39+
"sotp-section-2-size": {
40+
"help": "Flash sector size for SOTP sector 2",
41+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
42+
"value": null
2843
}
2944
},
3045
"target_overrides": {
3146
"*": {
32-
"target.features_add": ["COMMON_PAL"],
3347
"target.features_remove": ["LWIP"],
48+
"target.features_add": ["COMMON_PAL"],
3449
"platform.stdio-baud-rate": 115200,
50+
"platform.stdio-flush-at-exit": false,
3551
"update-client.storage-address": "1024*1024*64",
3652
"update-client.storage-size": "1024*1024",
37-
"update-client.storage-locations": "MAX_FIRMWARE_LOCATIONS",
38-
"platform.stdio-flush-at-exit": false,
53+
"update-client.storage-locations": 1,
3954
"update-client.firmware-header-version": "2"
4055
},
4156
"K64F": {
42-
"firmware_metadata_header_address": "0x20000",
43-
"update-client.application-details": "0x20000",
44-
"firmware_metadata_header_size": "0x400"
57+
"sotp-section-1-address" : "32*1024",
58+
"sotp-section-1-size" : "4*1024",
59+
"sotp-section-2-address" : "36*1024",
60+
"sotp-section-2-size" : "4*1024",
61+
"update-client.application-details": "40*1024",
62+
"application-start-address" : "41*1024",
63+
"max-application-size" : "(1024*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
4564
},
4665
"K66F": {
47-
"firmware_metadata_header_address": "0x20000",
48-
"update-client.application-details": "0x20000",
49-
"firmware_metadata_header_size": "0x400"
66+
"sotp-section-1-address" : "32*1024",
67+
"sotp-section-1-size" : "4*1024",
68+
"sotp-section-2-address" : "36*1024",
69+
"sotp-section-2-size" : "4*1024",
70+
"update-client.application-details": "40*1024",
71+
"application-start-address" : "41*1024",
72+
"max-application-size" : "(2048*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
5073
},
5174
"KW24D": {
52-
"firmware_metadata_header_address": "0x20000",
53-
"update-client.application-details": "0x19F04",
54-
"firmware_metadata_header_size": "0x400"
55-
},
56-
"NUCLEO_F429ZI": {
57-
"firmware_metadata_header_address": "0x08020000",
58-
"update-client.application-details": "0x08020000",
59-
"firmware_metadata_header_size": "0x400"
75+
"sotp-section-1-address" : "32*1024",
76+
"sotp-section-1-size" : "2*1024",
77+
"sotp-section-2-address" : "34*1024",
78+
"sotp-section-2-size" : "2*1024",
79+
"update-client.application-details": "36*1024",
80+
"application-start-address" : "37*1024",
81+
"max-application-size" : "(512*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
6082
},
6183
"NUCLEO_L476RG": {
62-
"firmware_metadata_header_address": "0x08020000",
63-
"update-client.application-details": "0x08020000",
64-
"firmware_metadata_header_size": "0x800"
84+
"sotp-section-1-address" : "32*1024",
85+
"sotp-section-1-size" : "2*1024",
86+
"sotp-section-2-address" : "34*1024",
87+
"sotp-section-2-size" : "2*1024",
88+
"update-client.application-details": "36*1024",
89+
"application-start-address" : "38*1024",
90+
"max-application-size" : "(1024*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
91+
},
92+
"DISCO_L476VG": {
93+
"sotp-section-1-address" : "32*1024",
94+
"sotp-section-1-size" : "2*1024",
95+
"sotp-section-2-address" : "34*1024",
96+
"sotp-section-2-size" : "2*1024",
97+
"update-client.application-details": "36*1024",
98+
"application-start-address" : "38*1024",
99+
"max-application-size" : "(1024*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
100+
},
101+
"NUCLEO_F429ZI": {
102+
"sotp-section-1-address" : "32*1024",
103+
"sotp-section-1-size" : "16*1024",
104+
"sotp-section-2-address" : "48*1024",
105+
"sotp-section-2-size" : "16*1024",
106+
"update-client.application-details": "64*1024",
107+
"application-start-address" : "65*1024",
108+
"max-application-size" : "(2048*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
65109
},
66110
"UBLOX_EVK_ODIN_W2": {
67111
"target.device_has_remove": ["EMAC"],
68-
"firmware_metadata_header_address": "0x08020000",
69-
"update-client.application-details": "0x08020000",
70-
"firmware_metadata_header_size": "0x400"
112+
"sotp-section-1-address" : "32*1024",
113+
"sotp-section-1-size" : "16*1024",
114+
"sotp-section-2-address" : "48*1024",
115+
"sotp-section-2-size" : "16*1024",
116+
"update-client.application-details": "64*1024",
117+
"application-start-address" : "65*1024",
118+
"max-application-size" : "(2048*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
71119
},
72120
"UBLOX_C030_U201": {
73-
"firmware_metadata_header_address": "0x08020000",
74-
"update-client.application-details": "0x08020000",
75-
"firmware_metadata_header_size": "0x800"
76-
},
77-
"DISCO_L476VG": {
78-
"firmware_metadata_header_address": "0x08020000",
79-
"update-client.application-details": "0x08020000",
80-
"firmware_metadata_header_size": "0x800"
121+
"sotp-section-1-address" : "32*1024",
122+
"sotp-section-1-size" : "16*1024",
123+
"sotp-section-2-address" : "48*1024",
124+
"sotp-section-2-size" : "16*1024",
125+
"update-client.application-details": "64*1024",
126+
"application-start-address" : "65*1024",
127+
"max-application-size" : "(1024*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
81128
}
82129
}
83130
}

power_cut_test/setup_dependencies.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

power_cut_test/test_mbed_app.json

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,67 @@
11
{
22
"macros": [
33
"MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
4-
"PAL_USE_FATFS_SD=1",
5-
"MAX_FIRMWARE_LOCATIONS=1",
64
"MAX_COPY_RETRIES=1",
75
"SHOW_PROGRESS_BAR=1",
86
"MAX_BOOT_RETRIES=3",
9-
"ARM_UC_USE_PAL_CRYPTO=0",
10-
"BOOTLOADER_POWER_CUT_TEST=1",
117
"Mutex=PlatformMutex",
12-
"ARM_UC_USE_PAL_BLOCKDEVICE=1",
138
"PAL_USE_INTERNAL_FLASH=1",
14-
"PAL_THREAD_SAFETY=0"
9+
"PAL_THREAD_SAFETY=0",
10+
"ARM_UC_USE_PAL_CRYPTO=0",
11+
"ARM_UC_USE_SOTP=0",
12+
"ARM_UC_USE_PAL_BLOCKDEVICE=1",
13+
"MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
14+
"BOOTLOADER_POWER_CUT_TEST=1"
1515
],
1616
"config": {
17-
"firmware_metadata_header_address": {
18-
"help": "Firmware metadata header in flash",
17+
"application-start-address": {
18+
"help": "Address of the active application firmware in flash",
1919
"value": null
2020
},
21-
"firmware_metadata_header_size": {
22-
"help": "Firmware metadata header size",
21+
"max-application-size": {
22+
"help": "Maximum size of the active application",
2323
"value": null
2424
},
25-
"serial_baudrate": {
26-
"help": "Terminal default baudrate",
27-
"value": 9600
25+
"sotp-section-1-address": {
26+
"help": "Flash sector address for SOTP sector 1",
27+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
28+
"value": null
29+
},
30+
"sotp-section-1-size": {
31+
"help": "Flash sector size for SOTP sector 1",
32+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
33+
"value": null
34+
},
35+
"sotp-section-2-address": {
36+
"help": "Flash sector address for SOTP sector 2",
37+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
38+
"value": null
39+
},
40+
"sotp-section-2-size": {
41+
"help": "Flash sector size for SOTP sector 2",
42+
"macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
43+
"value": null
2844
}
2945
},
3046
"target_overrides": {
3147
"*": {
48+
"target.features_remove": ["LWIP"],
3249
"target.features_add": ["COMMON_PAL"],
3350
"platform.stdio-baud-rate": 9600,
34-
"target.features_remove": ["LWIP"],
51+
"platform.stdio-flush-at-exit": false,
3552
"update-client.storage-address": "1024*1024*64",
3653
"update-client.storage-size": "1024*1024",
37-
"update-client.storage-locations": "MAX_FIRMWARE_LOCATIONS",
54+
"update-client.storage-locations": 1,
3855
"update-client.firmware-header-version": "2"
3956
},
4057
"K64F": {
41-
"firmware_metadata_header_address": "0x20000",
42-
"update-client.application-details": "0x20000",
43-
"firmware_metadata_header_size": "0x400"
58+
"sotp-section-1-address" : "32*1024",
59+
"sotp-section-1-size" : "4*1024",
60+
"sotp-section-2-address" : "36*1024",
61+
"sotp-section-2-size" : "4*1024",
62+
"update-client.application-details": "40*1024",
63+
"application-start-address" : "41*1024",
64+
"max-application-size" : "(1024*1024-MBED_CONF_APP_APPLICATION_START_ADDRESS)"
4465
}
4566
}
4667
}

0 commit comments

Comments
 (0)