1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 13:52:06 +00:00

Fix payload launching (thanks @huhen)

This commit is contained in:
Such Meme, Many Skill 2019-08-17 12:56:48 +02:00
parent ada4fd2c7f
commit a094ac4496

View file

@ -20,9 +20,9 @@ extern boot_cfg_t b_cfg;
extern bool sd_mount(); extern bool sd_mount();
extern void sd_unmount(); extern void sd_unmount();
int launch_payload(char *path, int update){ int launch_payload(char *path, bool update)
if (!update) {
gfx_clear_grey(0x1B); if (!update) gfx_clear_grey(0x1B);
gfx_con_setpos(0, 0); gfx_con_setpos(0, 0);
if (!path) if (!path)
return 1; return 1;
@ -30,10 +30,10 @@ int launch_payload(char *path, int update){
if (sd_mount()){ if (sd_mount()){
FIL fp; FIL fp;
if (f_open(&fp, path, FA_READ)){ if (f_open(&fp, path, FA_READ)){
EPRINTF("Payload missing!\n");
return 2; return 2;
} }
// Read and copy the payload to our chosen address
void *buf; void *buf;
u32 size = f_size(&fp); u32 size = f_size(&fp);
@ -44,16 +44,15 @@ int launch_payload(char *path, int update){
if (f_read(&fp, buf, size, NULL)){ if (f_read(&fp, buf, size, NULL)){
f_close(&fp); f_close(&fp);
return 3; return 3;
} }
f_close(&fp); f_close(&fp);
free(path);
sd_unmount();
if (size < 0x30000){ if (size < 0x30000){
if (update)
memcpy((u8 *)(RCM_PAYLOAD_ADDR + PATCHED_RELOC_SZ), &b_cfg, sizeof(boot_cfg_t)); // Transfer boot cfg.
else
reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10)); reloc_patcher(PATCHED_RELOC_ENTRY, EXT_PAYLOAD_ADDR, ALIGN(size, 0x10));
reconfig_hw_workaround(false, byte_swap_32(*(u32 *)(buf + size - sizeof(u32)))); reconfig_hw_workaround(false, byte_swap_32(*(u32 *)(buf + size - sizeof(u32))));
@ -68,7 +67,6 @@ int launch_payload(char *path, int update){
msleep(100); msleep(100);
// Launch our payload.
if (!update) if (!update)
(*ext_payload_ptr)(); (*ext_payload_ptr)();
else { else {