@@ -324,7 +324,7 @@ boot_write_magic(const struct flash_area *fap)
324
324
memset (& magic [0 ], erased_val , sizeof (magic ));
325
325
memcpy (& magic [BOOT_MAGIC_ALIGN_SIZE - BOOT_MAGIC_SZ ], BOOT_IMG_MAGIC , BOOT_MAGIC_SZ );
326
326
327
- BOOT_LOG_DBG ("writing magic; fa_id=%d off=0x%lx (0x%lx)" ,
327
+ BOOT_LOG_DBG ("boot_write_magic: fa_id=%d off=0x%lx (0x%lx)" ,
328
328
flash_area_get_id (fap ), (unsigned long )off ,
329
329
(unsigned long )(flash_area_get_off (fap ) + off ));
330
330
rc = flash_area_write (fap , pad_off , & magic [0 ], BOOT_MAGIC_ALIGN_SIZE );
@@ -350,9 +350,14 @@ boot_write_trailer(const struct flash_area *fap, uint32_t off,
350
350
uint32_t align ;
351
351
int rc ;
352
352
353
+ BOOT_LOG_DBG ("boot_write_trailer: for %p at %d, size = %d" ,
354
+ fap , off , inlen );
355
+
353
356
align = flash_area_align (fap );
354
357
align = ALIGN_UP (inlen , align );
355
358
if (align > BOOT_MAX_ALIGN ) {
359
+ /* This should never happen */
360
+ assert (0 );
356
361
return -1 ;
357
362
}
358
363
erased_val = flash_area_erased_val (fap );
@@ -596,6 +601,9 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
596
601
struct boot_swap_state slot_state ;
597
602
int rc ;
598
603
604
+ BOOT_LOG_DBG ("boot_set_next: fa %p active == %d, confirm == %d" ,
605
+ fa , (int )active , (int )confirm );
606
+
599
607
if (active ) {
600
608
/* The only way to set active slot for next boot is to confirm it,
601
609
* as DirectXIP will conclude that, since slot has not been confirmed
@@ -606,6 +614,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
606
614
607
615
rc = boot_read_swap_state (fa , & slot_state );
608
616
if (rc != 0 ) {
617
+ BOOT_LOG_DBG ("boot_set_next: error %d reading state" , rc );
609
618
return rc ;
610
619
}
611
620
@@ -733,6 +742,8 @@ boot_set_confirmed_multi(int image_index)
733
742
734
743
rc = flash_area_open (FLASH_AREA_IMAGE_PRIMARY (image_index ), & fap );
735
744
if (rc != 0 ) {
745
+ BOOT_LOG_DBG ("boot_set_confirmed_multi: error %d opening image %d" ,
746
+ rc , image_index );
736
747
return BOOT_EFLASH ;
737
748
}
738
749
@@ -760,13 +771,14 @@ int
760
771
boot_image_load_header (const struct flash_area * fa_p ,
761
772
struct image_header * hdr )
762
773
{
763
- uint32_t size ;
774
+ uint32_t size = 0 ;
764
775
int rc = flash_area_read (fa_p , 0 , hdr , sizeof * hdr );
765
776
777
+ BOOT_LOG_DBG ("boot_image_load_header: from %p, result %d" , fa_p , rc );
778
+
766
779
if (rc != 0 ) {
767
- rc = BOOT_EFLASH ;
768
780
BOOT_LOG_ERR ("Failed reading image header" );
769
- return BOOT_EFLASH ;
781
+ return BOOT_EFLASH ;
770
782
}
771
783
772
784
if (hdr -> ih_magic != IMAGE_MAGIC ) {
@@ -783,6 +795,8 @@ boot_image_load_header(const struct flash_area *fa_p,
783
795
784
796
if (!boot_u32_safe_add (& size , hdr -> ih_img_size , hdr -> ih_hdr_size ) ||
785
797
size >= flash_area_get_size (fa_p )) {
798
+ BOOT_LOG_ERR ("Image size bigger than designated area: %lu > %lu" ,
799
+ (unsigned long )size , (unsigned long )flash_area_get_size (fa_p ));
786
800
return BOOT_EBADIMAGE ;
787
801
}
788
802
0 commit comments