Skip to content

Commit

Permalink
update espflasher
Browse files Browse the repository at this point in the history
changes by Willy-JL
  • Loading branch information
xMasterX committed May 15, 2024
1 parent 91b7fb2 commit a3e4906
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 35 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
129 changes: 94 additions & 35 deletions non_catalog_apps/esp_flasher/scenes/esp_flasher_scene_quick.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#include "../esp_flasher_app_i.h"

// DO NOT use as an example, you should split into different scene files for each screen
// To keep in a single file, this is setup in an unusual and confusing way
// You can find more info in comments throughout

// There's one entry for each item on quick flash menu
// Following each one, there are its submenu items
// Not all boards support automatic bootmode, so here we separate into those that do and don't
enum QuickState {
QuickStart,
QuickBootS2,
QuickBootS2_Marauder,
QuickBootS2_Blackmagic,
QuickBootWROOM,
QuickBootWROOM_Marauder,
QuickS2Boot,
QuickS2Boot_Marauder,
QuickS2Boot_Blackmagic,
QuickWROOMBoot,
QuickWROOMBoot_Marauder,
QuickS3Boot,
QuickS3Boot_Marauder,
QuickWROOM,
QuickWROOM_Marauder,
QuickS2,
QuickS2_Marauder,
QuickS2_Blackmagic,
QuickS3,
QuickS3_Marauder,
};

void esp_flasher_scene_quick_submenu_callback(void* context, uint32_t index) {
Expand All @@ -27,21 +38,36 @@ void esp_flasher_scene_quick_on_enter(void* context) {
Submenu* submenu = app->submenu;
uint32_t state = scene_manager_get_scene_state(app->scene_manager, EspFlasherSceneQuick);

// State indicates the currently selected (or activated) item
// So map quick flash menu values to show the quick flash menu
// And map submenu values to show corresponding submenu
switch(state) {
case QuickStart:
case QuickBootS2:
case QuickBootWROOM:
case QuickS2Boot:
case QuickWROOMBoot:
case QuickS3Boot:
case QuickWROOM:
case QuickS2:
case QuickS3:
submenu_set_header(submenu, "Choose Board:");
submenu_add_item(
submenu,
"Flipper WiFi Board / Xeon",
QuickBootS2,
"Flipper WiFi Devboard",
QuickS2Boot,
esp_flasher_scene_quick_submenu_callback,
app);
submenu_add_item(
submenu, "Multi-Fucc", QuickBootWROOM, esp_flasher_scene_quick_submenu_callback, app);
submenu,
"ESP32-WROOM (bootloader)",
QuickWROOMBoot,
esp_flasher_scene_quick_submenu_callback,
app);
submenu_add_item(
submenu,
"ESP32-S3 (bootloader)",
QuickS3Boot,
esp_flasher_scene_quick_submenu_callback,
app);
submenu_add_item(
submenu,
"Other ESP32-WROOM",
Expand All @@ -50,32 +76,44 @@ void esp_flasher_scene_quick_on_enter(void* context) {
app);
submenu_add_item(
submenu, "Other ESP32-S2", QuickS2, esp_flasher_scene_quick_submenu_callback, app);
submenu_add_item(
submenu, "Other ESP32-S3", QuickS3, esp_flasher_scene_quick_submenu_callback, app);
break;
case QuickBootS2_Marauder:
case QuickBootS2_Blackmagic:
case QuickS2Boot_Marauder:
case QuickS2Boot_Blackmagic:
case QuickS2_Marauder:
case QuickS2_Blackmagic:
submenu_set_header(submenu, "Choose Firmware:");
submenu_add_item(
submenu,
"Marauder (has Evil Portal)",
state > QuickS2 ? QuickS2_Marauder : QuickBootS2_Marauder,
state > QuickS2 ? QuickS2_Marauder : QuickS2Boot_Marauder,
esp_flasher_scene_quick_submenu_callback,
app);
submenu_add_item(
submenu,
"Black Magic",
state > QuickS2 ? QuickS2_Blackmagic : QuickBootS2_Blackmagic,
state > QuickS2 ? QuickS2_Blackmagic : QuickS2Boot_Blackmagic,
esp_flasher_scene_quick_submenu_callback,
app);
break;
case QuickBootWROOM_Marauder:
case QuickWROOMBoot_Marauder:
case QuickWROOM_Marauder:
submenu_set_header(submenu, "Choose Firmware:");
submenu_add_item(
submenu,
"Marauder (has Evil Portal)",
state > QuickWROOM ? QuickWROOM_Marauder : QuickBootWROOM_Marauder,
state > QuickWROOM ? QuickWROOM_Marauder : QuickWROOMBoot_Marauder,
esp_flasher_scene_quick_submenu_callback,
app);
break;
case QuickS3Boot_Marauder:
case QuickS3_Marauder:
submenu_set_header(submenu, "Choose Firmware:");
submenu_add_item(
submenu,
"Marauder (has Evil Portal)",
state > QuickS3 ? QuickS3_Marauder : QuickS3Boot_Marauder,
esp_flasher_scene_quick_submenu_callback,
app);
break;
Expand All @@ -97,49 +135,63 @@ bool esp_flasher_scene_quick_on_event(void* context, SceneManagerEvent event) {
consumed = true;

bool enter_bootloader = false;
const char* boot = NULL; // 0x1000
bool s3 = false;
const char* boot = NULL; // 0x1000 (or 0x0 on S3)
const char* part = NULL; // 0x8000
const char* app0 = NULL; // 0xE000
const char* firm = NULL; // 0x10000

switch(event.event) {
case QuickBootS2:
case QuickBootWROOM:
case QuickS2Boot:
case QuickWROOMBoot:
case QuickS3Boot:
case QuickWROOM:
case QuickS2:
case QuickS3:
// Select first item of submenu
scene_manager_set_scene_state(
app->scene_manager, EspFlasherSceneQuick, event.event + 1);
scene_manager_next_scene(app->scene_manager, EspFlasherSceneQuick);
return consumed;

case QuickBootS2_Marauder:
case QuickS2Boot_Marauder:
enter_bootloader = true;
/* fallthrough */
case QuickS2_Marauder:
boot = APP_ASSETS_PATH("marauder/S2/esp32_marauder.ino.bootloader.bin");
boot = APP_ASSETS_PATH("marauder/s2/esp32_marauder.ino.bootloader.bin");
part = APP_ASSETS_PATH("marauder/esp32_marauder.ino.partitions.bin");
app0 = APP_ASSETS_PATH("marauder/boot_app0.bin");
firm = APP_ASSETS_PATH("marauder/S2/esp32_marauder.flipper.bin");
firm = APP_ASSETS_PATH("marauder/s2/esp32_marauder.flipper.bin");
break;

case QuickBootS2_Blackmagic:
case QuickS2Boot_Blackmagic:
enter_bootloader = true;
/* fallthrough */
case QuickS2_Blackmagic:
boot = APP_ASSETS_PATH("blackmagic/bootloader.bin");
part = APP_ASSETS_PATH("blackmagic/partition-table.bin");
firm = APP_ASSETS_PATH("blackmagic/blackmagic.bin");
boot = APP_ASSETS_PATH("blackmagic/s2/bootloader.bin");
part = APP_ASSETS_PATH("blackmagic/s2/partition-table.bin");
firm = APP_ASSETS_PATH("blackmagic/s2/blackmagic.bin");
break;

case QuickBootWROOM_Marauder:
case QuickWROOMBoot_Marauder:
enter_bootloader = true;
/* fallthrough */
case QuickWROOM_Marauder:
boot = APP_ASSETS_PATH("marauder/WROOM/esp32_marauder.ino.bootloader.bin");
boot = APP_ASSETS_PATH("marauder/wroom/esp32_marauder.ino.bootloader.bin");
part = APP_ASSETS_PATH("marauder/esp32_marauder.ino.partitions.bin");
app0 = APP_ASSETS_PATH("marauder/boot_app0.bin");
firm = APP_ASSETS_PATH("marauder/wroom/esp32_marauder.dev_board_pro.bin");
break;

case QuickS3Boot_Marauder:
enter_bootloader = true;
/* fallthrough */
case QuickS3_Marauder:
s3 = true;
boot = APP_ASSETS_PATH("marauder/s3/esp32_marauder.ino.bootloader.bin");
part = APP_ASSETS_PATH("marauder/esp32_marauder.ino.partitions.bin");
app0 = APP_ASSETS_PATH("marauder/boot_app0.bin");
firm =
APP_ASSETS_PATH("marauder/WROOM/esp32_marauder.dev_board_pro.bin");
firm = APP_ASSETS_PATH("marauder/s3/esp32_marauder.multiboardS3.bin");
break;

default:
Expand All @@ -157,6 +209,7 @@ bool esp_flasher_scene_quick_on_event(void* context, SceneManagerEvent event) {
app->bin_file_path_app_b[0] = '\0';
app->bin_file_path_custom[0] = '\0';

app->selected_flash_options[SelectedFlashS3Mode] = s3;
if(boot) {
app->selected_flash_options[SelectedFlashBoot] = true;
strncpy(app->bin_file_path_boot, boot, sizeof(app->bin_file_path_boot));
Expand All @@ -181,14 +234,20 @@ bool esp_flasher_scene_quick_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(app->scene_manager, EspFlasherSceneConsoleOutput);
} else if(event.type == SceneManagerEventTypeBack) {
uint32_t state = scene_manager_get_scene_state(app->scene_manager, EspFlasherSceneQuick);
if(state > QuickS2)
// Pressing back from submenu, check if in submenu, select corresponding item in quick flash menu
if(state > QuickS3)
state = QuickS3;
else if(state > QuickS2)
state = QuickS2;
else if(state > QuickWROOM)
state = QuickWROOM;
else if(state > QuickBootWROOM)
state = QuickBootWROOM;
else if(state > QuickBootS2)
state = QuickBootS2;
else if(state > QuickS3Boot)
state = QuickS3Boot;
else if(state > QuickWROOMBoot)
state = QuickWROOMBoot;
else if(state > QuickS2Boot)
state = QuickS2Boot;
// If pressing back from quick flash menu (not submenu), state will not matter
scene_manager_set_scene_state(app->scene_manager, EspFlasherSceneQuick, state);
}

Expand Down

0 comments on commit a3e4906

Please sign in to comment.