summaryrefslogtreecommitdiff
path: root/bootloader/x1000.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-07-11 02:32:05 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-07-11 15:39:50 +0100
commit84362141a0d1e33b29d12162caba7537dd5684b8 (patch)
treed966b33e6049cc54abe04d9b66ef0db794ebe948 /bootloader/x1000.c
parente9d228832ccbee7e486c45a51680c6f94ce1ab92 (diff)
downloadrockbox-84362141a0d1e33b29d12162caba7537dd5684b8.tar.gz
rockbox-84362141a0d1e33b29d12162caba7537dd5684b8.zip
x1000: Unified flash bootloader installer
Change-Id: Ib1d41d4e7d663ff8a21eb08108c13568f7408533
Diffstat (limited to 'bootloader/x1000.c')
-rw-r--r--bootloader/x1000.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/bootloader/x1000.c b/bootloader/x1000.c
index 0b28b7449d..2c61773b11 100644
--- a/bootloader/x1000.c
+++ b/bootloader/x1000.c
@@ -48,16 +48,13 @@
48#include "loader_strerror.h" 48#include "loader_strerror.h"
49#include "version.h" 49#include "version.h"
50#include "boot-x1000.h" 50#include "boot-x1000.h"
51#include "installer-x1000.h"
51#include <stddef.h> 52#include <stddef.h>
52#include <stdbool.h> 53#include <stdbool.h>
53#include <string.h> 54#include <string.h>
54#include <stdio.h> 55#include <stdio.h>
55#include <stdarg.h> 56#include <stdarg.h>
56 57
57#ifdef FIIO_M3K
58# include "installer-fiiom3k.h"
59#endif
60
61#if defined(FIIO_M3K) 58#if defined(FIIO_M3K)
62# define BL_RECOVERY BUTTON_VOL_UP 59# define BL_RECOVERY BUTTON_VOL_UP
63# define BL_UP BUTTON_VOL_UP 60# define BL_UP BUTTON_VOL_UP
@@ -68,6 +65,7 @@
68# define BL_DOWN_NAME "VOL-" 65# define BL_DOWN_NAME "VOL-"
69# define BL_SELECT_NAME "PLAY" 66# define BL_SELECT_NAME "PLAY"
70# define BL_QUIT_NAME "POWER" 67# define BL_QUIT_NAME "POWER"
68# define BOOTBACKUP_FILE "/fiiom3k-boot.bin"
71#else 69#else
72# error "Missing keymap!" 70# error "Missing keymap!"
73#endif 71#endif
@@ -387,14 +385,12 @@ void reboot(void)
387 while(1); 385 while(1);
388} 386}
389 387
390/* TODO: clean this up, make the installer generic as well */
391enum { 388enum {
392 INSTALL, 389 INSTALL,
393 BACKUP, 390 BACKUP,
394 RESTORE, 391 RESTORE,
395}; 392};
396 393
397#ifdef FIIO_M3K
398void bootloader_action(int which) 394void bootloader_action(int which)
399{ 395{
400 if(init_disk() != 0) { 396 if(init_disk() != 0) {
@@ -414,14 +410,14 @@ void bootloader_action(int which)
414 410
415 int rc; 411 int rc;
416 switch(which) { 412 switch(which) {
417 case INSTALL: rc = install_boot("/bootloader.m3k"); break; 413 case INSTALL: rc = install_bootloader("/bootloader." BOOTFILE_EXT); break;
418 case BACKUP: rc = backup_boot("/fiiom3k-boot.bin"); break; 414 case BACKUP: rc = backup_bootloader(BOOTBACKUP_FILE); break;
419 case RESTORE: rc = restore_boot("/fiiom3k-boot.bin"); break; 415 case RESTORE: rc = restore_bootloader(BOOTBACKUP_FILE); break;
420 default: return; 416 default: return;
421 } 417 }
422 418
423 static char buf[64]; 419 static char buf[64];
424 snprintf(buf, sizeof(buf), "Failed! Error: %d", rc); 420 snprintf(buf, sizeof(buf), "%s (%d)", installer_strerror(rc), rc);
425 const char* msg1 = rc == 0 ? "Success" : buf; 421 const char* msg1 = rc == 0 ? "Success" : buf;
426 const char* msg2 = "Press " BL_QUIT_NAME " to continue"; 422 const char* msg2 = "Press " BL_QUIT_NAME " to continue";
427 splash2(0, msg1, msg2); 423 splash2(0, msg1, msg2);
@@ -429,13 +425,6 @@ void bootloader_action(int which)
429 button_clear_queue(); 425 button_clear_queue();
430 while(button_get(true) != BL_QUIT); 426 while(button_get(true) != BL_QUIT);
431} 427}
432#else
433void bootloader_action(int which)
434{
435 (void)which;
436 splash(5*HZ, "Not implemented!");
437}
438#endif
439 428
440void bootloader_install(void) 429void bootloader_install(void)
441{ 430{