From 98d715243a3d806a25ca06c1260d9ea1f7c62d83 Mon Sep 17 00:00:00 2001 From: Kostas Missos Date: Sun, 16 Dec 2018 19:04:46 +0200 Subject: [PATCH] Fixes to update.bin reloc (breaking!) This fixes a regression in chainloading update.bin where the added check for if it's update or not, didn't copy the reloc code. And the calling was not updated to reflect this. Additionally: - Delete the reloc.S relic - Force running config_hw in case we change hw init again in the future. --- Makefile | 1 + bootloader/main.c | 17 +++++++++-------- bootloader/reloc.S | 34 ---------------------------------- 3 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 bootloader/reloc.S diff --git a/Makefile b/Makefile index e7fbc24..4b67210 100755 --- a/Makefile +++ b/Makefile @@ -63,6 +63,7 @@ OBJS += $(addprefix $(BUILD)/$(TARGET)/, \ CUSTOMDEFINES := -DBLVERSIONMJ=$(BLVERSION_MAJOR) -DBLVERSIONMN=$(BLVERSION_MINOR) -DMENU_LOGO_ENABLE #CUSTOMDEFINES += -DDEBUG +# 0: UART_A, 1: UART_B. #CUSTOMDEFINES += -DDEBUG_UART_PORT=0 ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork diff --git a/bootloader/main.c b/bootloader/main.c index e2ca688..f3828bb 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -269,6 +269,7 @@ void check_power_off_from_hos() #define COREBOOT_ADDR (0xD0000000 - 0x100000) void (*ext_payload_ptr)() = (void *)EXT_PAYLOAD_ADDR; +void (*update_ptr)() = (void *)RCM_PAYLOAD_ADDR; void reloc_patcher(u32 payload_size) { @@ -289,7 +290,7 @@ void reloc_patcher(u32 payload_size) } } -#define BOOTLOADER_UPDATED_MAGIC 0x424f4f54 // "BOOT". +#define BOOTLOADER_UPDATED_MAGIC 0x424F4F54 // "BOOT". #define BOOTLOADER_UPDATED_MAGIC_ADDR 0x4003E000 int launch_payload(char *path, bool update) @@ -375,7 +376,10 @@ int launch_payload(char *path, bool update) } // Launch our payload. - (*ext_payload_ptr)(); + if (!update) + (*ext_payload_ptr)(); + else + (*update_ptr)(); } return 1; @@ -959,7 +963,6 @@ void auto_launch_firmware() #endif //MENU_LOGO_ENABLE out: - gfx_clear_grey(&gfx_ctxt, 0x1B); ini_free(&ini_sections); if (h_cfg.autoboot_list) ini_free(&ini_list_sections); @@ -1146,8 +1149,7 @@ extern void pivot_stack(u32 stack_top); void ipl_main() { // Skip config if we just updated the bootloader. - if (*(vu32 *)BOOTLOADER_UPDATED_MAGIC_ADDR != BOOTLOADER_UPDATED_MAGIC) - config_hw(); + config_hw(); //Pivot the stack so we have enough space. pivot_stack(0x90010000); @@ -1164,9 +1166,8 @@ void ipl_main() set_default_configuration(); // Save sdram lp0 config. - if (*(vu32 *)BOOTLOADER_UPDATED_MAGIC_ADDR != BOOTLOADER_UPDATED_MAGIC) - if (ianos_loader(true, "bootloader/sys/libsys_lp0.bso", DRAM_LIB, (void *)sdram_get_params())) - h_cfg.errors |= ERR_LIBSYS_LP0; + if (ianos_loader(true, "bootloader/sys/libsys_lp0.bso", DRAM_LIB, (void *)sdram_get_params())) + h_cfg.errors |= ERR_LIBSYS_LP0; display_init(); diff --git a/bootloader/reloc.S b/bootloader/reloc.S deleted file mode 100644 index acc6d5e..0000000 --- a/bootloader/reloc.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018 naehrwert - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * TODO: the placement of the relocator is a bit fragile atm, maybe we - * should include it in start.S and copy it to some known good - * place in IRAM instead. Basically we want it as far back atm - * as it might be overwritten during relocation. - */ - -.section .text.reloc -.arm - -.globl _reloc_ipl -.type _reloc_ipl, %function -_reloc_ipl: - LDMIA R0!, {R4-R7} - STMIA R1!, {R4-R7} - SUBS R2, #0x10 - BNE _reloc_ipl - BX R3