@@ -134,8 +134,9 @@ STATIC char *updater_read_file (const char *file_path, vstr_t *vstr) {
134134 return vstr -> buf ;
135135}
136136
137- void update_to_factory_partition (void ) {
137+ bool update_to_factory_partition (void ) {
138138
139+ // Size of the image used in 1.18.2r7 version
139140 updater_data .size = (1536 * 1024 );
140141 updater_data .offset = IMG_FACTORY_OFFSET ;
141142 updater_data .offset_start_upd = updater_data .offset ;
@@ -144,10 +145,12 @@ void update_to_factory_partition(void) {
144145
145146 // erase the first 2 sectors
146147 if (ESP_OK != spi_flash_erase_sector (updater_data .offset / SPI_FLASH_SEC_SIZE )) {
147- ESP_LOGE (TAG , "Erasing first sector failed!\n" );
148+ ESP_LOGE (TAG , "Copying image from OTA_0 partition to Factory partition failed, erasing first sector failed!\n" );
149+ return false;
148150 }
149151 if (ESP_OK != spi_flash_erase_sector ((updater_data .offset + SPI_FLASH_SEC_SIZE ) / SPI_FLASH_SEC_SIZE )) {
150- ESP_LOGE (TAG , "Erasing second sector failed!\n" );
152+ ESP_LOGE (TAG , "Copying image from OTA_0 partition to Factory partition failed, erasing second sector failed!\n" );
153+ return false;
151154 }
152155
153156 uint32_t bytes_read = 0 ;
@@ -158,11 +161,14 @@ void update_to_factory_partition(void) {
158161 updater_spi_flash_read (IMG_UPDATE1_OFFSET_OLD + bytes_read , buf , SPI_FLASH_SEC_SIZE , false);
159162 bytes_read += SPI_FLASH_SEC_SIZE ;
160163 if (false == updater_write (buf , SPI_FLASH_SEC_SIZE )){
161- printf ("update_to_factory_partition, updater_write returned FALSE\n" );
164+ ESP_LOGE (TAG , "Copying image from OTA_0 partition to Factory partition failed!\n" );
165+ return false;
162166 }
163167 }
164168
165169 updater_finish ();
170+
171+ return true;
166172}
167173
168174bool updater_start (void ) {
0 commit comments