1111#include <esp_spi_flash.h>
1212#include <esp_ota_ops.h>
1313
14- // CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED
15-
1614#define MAX_PARTITIONS (24) // ESP_PARTITION_TABLE_MAX_ENTRIES
1715
1816#define RETRO_GO_IMG_MAGIC "RG_IMG_0"
@@ -91,17 +89,18 @@ static bool parse_file(esp_partition_info_t *partition_table, size_t *num_partit
9189 {
9290 goto fail ;
9391 }
94- // TODO: Also support images that truncate the first 0x1000, just in case
9592 TRY (fread_at (gp_buffer , ESP_PARTITION_TABLE_OFFSET , ESP_PARTITION_TABLE_MAX_LEN , fp ), "File read failed" );
9693 TRY (esp_partition_table_verify ((const esp_partition_info_t * )gp_buffer , true, & _num_partitions ) == ESP_OK , "File is not a valid ESP32 image." );
9794 memcpy (partition_table , gp_buffer , sizeof (esp_partition_info_t ) * _num_partitions );
9895 * num_partitions = _num_partitions ;
9996 return true;
10097fail :
98+ // TODO: Also support images that truncate the first 0x1000, just in case
99+ // TODO: Also support .fw, which should be trivial to parse albeit lacking some meta data
101100 return false;
102101}
103102
104- static bool do_flash (flash_task_t * queue , size_t queue_count , FILE * fp )
103+ static bool process_queue (flash_task_t * queue , size_t queue_count , FILE * fp )
105104{
106105 char message_buffer [256 ];
107106 rg_gui_option_t lines [queue_count + 4 ];
@@ -266,7 +265,7 @@ static bool do_update(const char *filename)
266265
267266 rg_display_clear (C_BLACK );
268267
269- if (!do_flash (queue , queue_count , fp ))
268+ if (!process_queue (queue , queue_count , fp ))
270269 goto fail ;
271270
272271 fclose (fp );
@@ -287,10 +286,8 @@ void app_main(void)
287286 });
288287
289288 gp_buffer = rg_alloc (gp_buffer_size , MEM_FAST );
290- if (!gp_buffer )
291- RG_PANIC ("Memory allocation failed" );
292-
293289 // const char *filename = app->romPath;
290+
294291 while (true)
295292 {
296293 char * filename = rg_gui_file_picker ("Select update" , RG_BASE_PATH_UPDATES , NULL , true, true);
0 commit comments