@@ -722,109 +722,109 @@ bs_slot_info(uint8_t op, char *buf, int len)
722
722
IMAGES_ITER (image_index ) {
723
723
for (slot = 0 ; slot < BOOT_NUM_SLOTS ; slot ++ ) {
724
724
if (slot == 0 ) {
725
- ok = zcbor_map_start_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP ) &&
726
- zcbor_tstr_put_lit (cbor_state , "image" ) &&
727
- zcbor_uint32_put (cbor_state , (uint32_t )image_index ) &&
728
- zcbor_tstr_put_lit (cbor_state , "slots" ) &&
729
- zcbor_list_start_encode (cbor_state , BOOT_NUM_SLOTS );
725
+ ok = zcbor_map_start_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP ) &&
726
+ zcbor_tstr_put_lit (cbor_state , "image" ) &&
727
+ zcbor_uint32_put (cbor_state , (uint32_t )image_index ) &&
728
+ zcbor_tstr_put_lit (cbor_state , "slots" ) &&
729
+ zcbor_list_start_encode (cbor_state , BOOT_NUM_SLOTS );
730
730
731
- if (!ok ) {
732
- goto finish ;
733
- }
731
+ if (!ok ) {
732
+ goto finish ;
734
733
}
734
+ }
735
735
736
- ok = zcbor_map_start_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP ) &&
737
- zcbor_tstr_put_lit (cbor_state , "slot" ) &&
738
- zcbor_uint32_put (cbor_state , slot );
736
+ ok = zcbor_map_start_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP ) &&
737
+ zcbor_tstr_put_lit (cbor_state , "slot" ) &&
738
+ zcbor_uint32_put (cbor_state , slot );
739
739
740
- if (!ok ) {
741
- goto finish ;
742
- }
740
+ if (!ok ) {
741
+ goto finish ;
742
+ }
743
743
744
- area_id = flash_area_id_from_multi_image_slot (image_index , slot );
745
- rc = flash_area_open (area_id , & fap );
744
+ area_id = flash_area_id_from_multi_image_slot (image_index , slot );
745
+ rc = flash_area_open (area_id , & fap );
746
746
747
- if (rc ) {
748
- ok = zcbor_tstr_put_lit (cbor_state , "rc" ) &&
749
- zcbor_int32_put (cbor_state , rc ) &&
750
- zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP );
747
+ if (rc ) {
748
+ ok = zcbor_tstr_put_lit (cbor_state , "rc" ) &&
749
+ zcbor_int32_put (cbor_state , rc ) &&
750
+ zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP );
751
751
752
- if (ok && slot == (BOOT_NUM_SLOTS - 1 )) {
753
- ok = zcbor_list_end_encode (cbor_state , BOOT_NUM_SLOTS ) &&
754
- zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP );
755
- }
752
+ if (ok && slot == (BOOT_NUM_SLOTS - 1 )) {
753
+ ok = zcbor_list_end_encode (cbor_state , BOOT_NUM_SLOTS ) &&
754
+ zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP );
755
+ }
756
+ } else {
757
+ if (sizeof (fap -> fa_size ) == sizeof (uint64_t )) {
758
+ ok = zcbor_tstr_put_lit (cbor_state , "size" ) &&
759
+ zcbor_uint64_put (cbor_state , fap -> fa_size );
756
760
} else {
757
- if (sizeof (fap -> fa_size ) == sizeof (uint64_t )) {
758
- ok = zcbor_tstr_put_lit (cbor_state , "size" ) &&
759
- zcbor_uint64_put (cbor_state , fap -> fa_size );
760
- } else {
761
- ok = zcbor_tstr_put_lit (cbor_state , "size" ) &&
762
- zcbor_uint32_put (cbor_state , fap -> fa_size );
763
- }
761
+ ok = zcbor_tstr_put_lit (cbor_state , "size" ) &&
762
+ zcbor_uint32_put (cbor_state , fap -> fa_size );
763
+ }
764
764
765
- if (!ok ) {
766
- flash_area_close (fap );
767
- goto finish ;
768
- }
765
+ if (!ok ) {
766
+ flash_area_close (fap );
767
+ goto finish ;
768
+ }
769
769
770
- /*
771
- * Check if we support uploading to this slot and if so, return the
772
- * image ID
773
- */
770
+ /*
771
+ * Check if we support uploading to this slot and if so, return the
772
+ * image ID
773
+ */
774
774
#if defined(MCUBOOT_SINGLE_APPLICATION_SLOT )
775
- ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
776
- zcbor_uint32_put (cbor_state , (image_index + 1 ));
775
+ ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
776
+ zcbor_uint32_put (cbor_state , (image_index + 1 ));
777
777
#elif defined(MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD )
778
- ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
779
- zcbor_uint32_put (cbor_state , (image_index * 2 + slot + 1 ));
778
+ ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
779
+ zcbor_uint32_put (cbor_state , (image_index * 2 + slot + 1 ));
780
780
#else
781
- if (slot == 1 ) {
782
- ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
783
- zcbor_uint32_put (cbor_state , (image_index * 2 + 1 ));
784
- }
781
+ if (slot == 1 ) {
782
+ ok = zcbor_tstr_put_lit (cbor_state , "upload_image_id" ) &&
783
+ zcbor_uint32_put (cbor_state , (image_index * 2 + 1 ));
784
+ }
785
785
#endif
786
786
787
- flash_area_close (fap );
787
+ flash_area_close (fap );
788
788
789
- if (!ok ) {
789
+ if (!ok ) {
790
+ goto finish ;
791
+ }
792
+
793
+ ok = zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP );
794
+
795
+ if (!ok ) {
790
796
goto finish ;
791
- }
797
+ }
792
798
793
- ok = zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_SLOTS_MAP );
799
+ if (slot == (BOOT_NUM_SLOTS - 1 )) {
800
+ ok = zcbor_list_end_encode (cbor_state , BOOT_NUM_SLOTS );
794
801
795
802
if (!ok ) {
796
- goto finish ;
803
+ goto finish ;
797
804
}
798
805
799
- if (slot == (BOOT_NUM_SLOTS - 1 )) {
800
- ok = zcbor_list_end_encode (cbor_state , BOOT_NUM_SLOTS );
806
+ if (image_max_sizes [image_index ].calculated == true) {
807
+ ok = zcbor_tstr_put_lit (cbor_state , "max_image_size" ) &&
808
+ zcbor_uint32_put (cbor_state ,
809
+ image_max_sizes [image_index ].max_size );
801
810
802
811
if (!ok ) {
803
812
goto finish ;
804
813
}
805
-
806
- if (image_max_sizes [image_index ].calculated == true) {
807
- ok = zcbor_tstr_put_lit (cbor_state , "max_image_size" ) &&
808
- zcbor_uint32_put (cbor_state ,
809
- image_max_sizes [image_index ].max_size );
810
-
811
- if (!ok ) {
812
- goto finish ;
813
- }
814
- }
815
-
816
- ok = zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP );
817
814
}
818
- }
819
815
820
- if (!ok ) {
821
- goto finish ;
816
+ ok = zcbor_map_end_encode (cbor_state , CBOR_ENTRIES_SLOT_INFO_IMAGE_MAP );
822
817
}
823
818
}
819
+
820
+ if (!ok ) {
821
+ goto finish ;
822
+ }
824
823
}
824
+ }
825
825
826
- ok = zcbor_list_end_encode (cbor_state , MCUBOOT_IMAGE_NUMBER ) &&
827
- zcbor_map_end_encode (cbor_state , 1 );
826
+ ok = zcbor_list_end_encode (cbor_state , MCUBOOT_IMAGE_NUMBER ) &&
827
+ zcbor_map_end_encode (cbor_state , 1 );
828
828
829
829
finish :
830
830
if (!ok ) {
0 commit comments