@@ -248,6 +248,8 @@ boot_read_swap_state(const struct flash_area *fap,
248
248
uint8_t swap_info ;
249
249
int rc ;
250
250
251
+ BOOT_LOG_DBG ("boot_read_swap_state: flash area %p" , fap );
252
+
251
253
off = boot_magic_off (fap );
252
254
rc = flash_area_read (fap , off , magic , BOOT_MAGIC_SZ );
253
255
if (rc < 0 ) {
@@ -262,6 +264,7 @@ boot_read_swap_state(const struct flash_area *fap,
262
264
off = boot_swap_info_off (fap );
263
265
rc = flash_area_read (fap , off , & swap_info , sizeof swap_info );
264
266
if (rc < 0 ) {
267
+ BOOT_LOG_DBG ("boot_read_swap_state: error %d reading state" , rc );
265
268
return BOOT_EFLASH ;
266
269
}
267
270
@@ -324,12 +327,13 @@ boot_write_magic(const struct flash_area *fap)
324
327
memset (& magic [0 ], erased_val , sizeof (magic ));
325
328
memcpy (& magic [BOOT_MAGIC_ALIGN_SIZE - BOOT_MAGIC_SZ ], BOOT_IMG_MAGIC , BOOT_MAGIC_SZ );
326
329
327
- BOOT_LOG_DBG ("writing magic; fa_id=%d off=0x%lx (0x%lx)" ,
330
+ BOOT_LOG_DBG ("boot_write_magic: fa_id=%d off=0x%lx (0x%lx)" ,
328
331
flash_area_get_id (fap ), (unsigned long )off ,
329
332
(unsigned long )(flash_area_get_off (fap ) + off ));
330
333
rc = flash_area_write (fap , pad_off , & magic [0 ], BOOT_MAGIC_ALIGN_SIZE );
331
334
332
335
if (rc != 0 ) {
336
+ BOOT_LOG_DBG ("boot_write_magic: error %d on write" , rc );
333
337
return BOOT_EFLASH ;
334
338
}
335
339
@@ -350,9 +354,14 @@ boot_write_trailer(const struct flash_area *fap, uint32_t off,
350
354
uint32_t align ;
351
355
int rc ;
352
356
357
+ BOOT_LOG_DBG ("boot_write_trailer: for %p at %d, size = %d" ,
358
+ fap , off , inlen );
359
+
353
360
align = flash_area_align (fap );
354
361
align = ALIGN_UP (inlen , align );
355
362
if (align > BOOT_MAX_ALIGN ) {
363
+ /* This should never happen */
364
+ assert (0 );
356
365
return -1 ;
357
366
}
358
367
erased_val = flash_area_erased_val (fap );
@@ -596,6 +605,9 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
596
605
struct boot_swap_state slot_state ;
597
606
int rc ;
598
607
608
+ BOOT_LOG_DBG ("boot_set_next: fa %p active == %d, confirm == %d" ,
609
+ fa , (int )active , (int )confirm );
610
+
599
611
if (active ) {
600
612
/* The only way to set active slot for next boot is to confirm it,
601
613
* as DirectXIP will conclude that, since slot has not been confirmed
@@ -606,6 +618,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
606
618
607
619
rc = boot_read_swap_state (fa , & slot_state );
608
620
if (rc != 0 ) {
621
+ BOOT_LOG_DBG ("boot_set_next: error %d reading state" , rc );
609
622
return rc ;
610
623
}
611
624
@@ -733,6 +746,8 @@ boot_set_confirmed_multi(int image_index)
733
746
734
747
rc = flash_area_open (FLASH_AREA_IMAGE_PRIMARY (image_index ), & fap );
735
748
if (rc != 0 ) {
749
+ BOOT_LOG_DBG ("boot_set_confirmed_multi: error %d opening image %d" ,
750
+ rc , image_index );
736
751
return BOOT_EFLASH ;
737
752
}
738
753
@@ -763,10 +778,11 @@ boot_image_load_header(const struct flash_area *fa_p,
763
778
uint32_t size ;
764
779
int rc = flash_area_read (fa_p , 0 , hdr , sizeof * hdr );
765
780
781
+ BOOT_LOG_DBG ("boot_image_load_header: from %p, result %d" , fa_p , rc );
782
+
766
783
if (rc != 0 ) {
767
- rc = BOOT_EFLASH ;
768
784
BOOT_LOG_ERR ("Failed reading image header" );
769
- return BOOT_EFLASH ;
785
+ return BOOT_EFLASH ;
770
786
}
771
787
772
788
if (hdr -> ih_magic != IMAGE_MAGIC ) {
@@ -783,6 +799,7 @@ boot_image_load_header(const struct flash_area *fa_p,
783
799
784
800
if (!boot_u32_safe_add (& size , hdr -> ih_img_size , hdr -> ih_hdr_size ) ||
785
801
size >= flash_area_get_size (fa_p )) {
802
+ BOOT_LOG_ERR ("Incorrect image size" );
786
803
return BOOT_EBADIMAGE ;
787
804
}
788
805
0 commit comments