From 53a92f0ecce72ec92084a23a4f22679d2c01e22a Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 5 Mar 2022 13:52:11 +0000 Subject: 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 --- bootloader/x1000/boot.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'bootloader/x1000/boot.c') 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 @@ #include "system.h" #include "kernel.h" #include "power.h" +#include "linuxboot.h" #include "boot-x1000.h" void boot_rockbox(void) @@ -50,3 +51,47 @@ void reboot(void) system_reboot(); while(1); } + +/* + * WARNING: Original firmware can be finicky. + * Be careful when modifying this code. + */ + +static __attribute__((unused)) +void boot_of_helper(uint32_t addr, uint32_t flash_size, const char* args) +{ + struct uimage_header uh; + size_t img_length; + int handle = load_uimage_flash(addr, flash_size, &uh, &img_length); + if(handle < 0) + return; + + gui_shutdown(); + + x1000_dualboot_load_pdma_fw(); + x1000_dualboot_cleanup(); + x1000_dualboot_init_clocktree(); + x1000_dualboot_init_uart2(); + + x1000_boot_linux(core_get_data(handle), img_length, + (void*)uimage_get_load(&uh), + (void*)uimage_get_ep(&uh), args); +} + +void boot_of_player(void) +{ +#if defined(OF_PLAYER_ADDR) + boot_of_helper(OF_PLAYER_ADDR, OF_PLAYER_LENGTH, OF_PLAYER_ARGS); +#else + splash(HZ, "Not supported"); +#endif +} + +void boot_of_recovery(void) +{ +#if defined(OF_RECOVERY_ADDR) + boot_of_helper(OF_RECOVERY_ADDR, OF_RECOVERY_LENGTH, OF_RECOVERY_ARGS); +#else + splash(HZ, "Not supported"); +#endif +} -- cgit v1.2.3