@@ -63,6 +63,10 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
63
63
64
64
static struct boot_loader_state boot_data ;
65
65
66
+ #if defined(MCUBOOT_DATA_SHARING )
67
+ static struct image_max_size image_max_sizes [BOOT_IMAGE_NUMBER ] = {0 };
68
+ #endif
69
+
66
70
#if (BOOT_IMAGE_NUMBER > 1 )
67
71
#define IMAGES_ITER (x ) for ((x) = 0; (x) < BOOT_IMAGE_NUMBER; ++(x))
68
72
#else
@@ -137,10 +141,6 @@ boot_add_shared_data(struct boot_loader_state *state,
137
141
#if defined(MCUBOOT_MEASURED_BOOT ) || defined(MCUBOOT_DATA_SHARING )
138
142
int rc ;
139
143
140
- #ifdef MCUBOOT_DATA_SHARING
141
- int max_app_size ;
142
- #endif
143
-
144
144
#ifdef MCUBOOT_MEASURED_BOOT
145
145
rc = boot_save_boot_status (BOOT_CURR_IMG (state ),
146
146
boot_img_hdr (state , active_slot ),
@@ -152,10 +152,9 @@ boot_add_shared_data(struct boot_loader_state *state,
152
152
#endif /* MCUBOOT_MEASURED_BOOT */
153
153
154
154
#ifdef MCUBOOT_DATA_SHARING
155
- max_app_size = app_max_size (state );
156
155
rc = boot_save_shared_data (boot_img_hdr (state , active_slot ),
157
156
BOOT_IMG_AREA (state , active_slot ),
158
- active_slot , max_app_size );
157
+ active_slot , image_max_sizes );
159
158
if (rc != 0 ) {
160
159
BOOT_LOG_ERR ("Failed to add data to shared memory area." );
161
160
return rc ;
@@ -1841,6 +1840,10 @@ boot_prepare_image_for_update(struct boot_loader_state *state,
1841
1840
int rc ;
1842
1841
FIH_DECLARE (fih_rc , FIH_FAILURE );
1843
1842
1843
+ #if defined(MCUBOOT_DATA_SHARING )
1844
+ int max_size ;
1845
+ #endif
1846
+
1844
1847
/* Determine the sector layout of the image slots and scratch area. */
1845
1848
rc = boot_read_sectors (state );
1846
1849
if (rc != 0 ) {
@@ -1867,6 +1870,16 @@ boot_prepare_image_for_update(struct boot_loader_state *state,
1867
1870
return ;
1868
1871
}
1869
1872
1873
+ #if defined(MCUBOOT_DATA_SHARING )
1874
+ /* Fetch information on maximum sizes for later usage, if needed */
1875
+ max_size = app_max_size (state );
1876
+
1877
+ if (max_size > 0 ) {
1878
+ image_max_sizes [BOOT_CURR_IMG (state )].calculated = true;
1879
+ image_max_sizes [BOOT_CURR_IMG (state )].max_size = max_size ;
1880
+ }
1881
+ #endif
1882
+
1870
1883
/* If the current image's slots aren't compatible, no swap is possible.
1871
1884
* Just boot into primary slot.
1872
1885
*/
@@ -3323,3 +3336,13 @@ void boot_state_clear(struct boot_loader_state *state)
3323
3336
memset (& boot_data , 0 , sizeof (struct boot_loader_state ));
3324
3337
}
3325
3338
}
3339
+
3340
+ #if defined(MCUBOOT_DATA_SHARING )
3341
+ /**
3342
+ * Fetches the maximum allowed size of the image
3343
+ */
3344
+ const struct image_max_size * boot_get_max_app_size (void )
3345
+ {
3346
+ return image_max_sizes ;
3347
+ }
3348
+ #endif
0 commit comments