summaryrefslogtreecommitdiff
path: root/bootloader/x1000/boot.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-05 13:52:11 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-24 23:40:07 +0000
commit53a92f0ecce72ec92084a23a4f22679d2c01e22a (patch)
treee235961945c6eb329f2f176384e74b969c2be64a /bootloader/x1000/boot.c
parent9bde653410e83d5e97729aef212341f3cde790bc (diff)
downloadrockbox-53a92f0ecce72ec92084a23a4f22679d2c01e22a.tar.gz
rockbox-53a92f0ecce72ec92084a23a4f22679d2c01e22a.zip
x1000: bootloader: add original firmware boot capability
Adds the ability to boot the OF's player or recovery kernels from the bootloader. Works on Shanling Q1 but broken on the FiiO M3K (kernel hang) so leave it disabled for the M3K. Change-Id: I26b973fba1c22afb906a78865963a96dd2107932
Diffstat (limited to 'bootloader/x1000/boot.c')
-rw-r--r--bootloader/x1000/boot.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/bootloader/x1000/boot.c b/bootloader/x1000/boot.c
index 6719375151..ca69e2e057 100644
--- a/bootloader/x1000/boot.c
+++ b/bootloader/x1000/boot.c
@@ -24,6 +24,7 @@
24#include "system.h" 24#include "system.h"
25#include "kernel.h" 25#include "kernel.h"
26#include "power.h" 26#include "power.h"
27#include "linuxboot.h"
27#include "boot-x1000.h" 28#include "boot-x1000.h"
28 29
29void boot_rockbox(void) 30void boot_rockbox(void)
@@ -50,3 +51,47 @@ void reboot(void)
50 system_reboot(); 51 system_reboot();
51 while(1); 52 while(1);
52} 53}
54
55/*
56 * WARNING: Original firmware can be finicky.
57 * Be careful when modifying this code.
58 */
59
60static __attribute__((unused))
61void boot_of_helper(uint32_t addr, uint32_t flash_size, const char* args)
62{
63 struct uimage_header uh;
64 size_t img_length;
65 int handle = load_uimage_flash(addr, flash_size, &uh, &img_length);
66 if(handle < 0)
67 return;
68
69 gui_shutdown();
70
71 x1000_dualboot_load_pdma_fw();
72 x1000_dualboot_cleanup();
73 x1000_dualboot_init_clocktree();
74 x1000_dualboot_init_uart2();
75
76 x1000_boot_linux(core_get_data(handle), img_length,
77 (void*)uimage_get_load(&uh),
78 (void*)uimage_get_ep(&uh), args);
79}
80
81void boot_of_player(void)
82{
83#if defined(OF_PLAYER_ADDR)
84 boot_of_helper(OF_PLAYER_ADDR, OF_PLAYER_LENGTH, OF_PLAYER_ARGS);
85#else
86 splash(HZ, "Not supported");
87#endif
88}
89
90void boot_of_recovery(void)
91{
92#if defined(OF_RECOVERY_ADDR)
93 boot_of_helper(OF_RECOVERY_ADDR, OF_RECOVERY_LENGTH, OF_RECOVERY_ARGS);
94#else
95 splash(HZ, "Not supported");
96#endif
97}