mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 03:11:16 +00:00
Add autolaunch updated bootloader (mostly for modchips)
This commit is contained in:
parent
5328f89ffe
commit
13a07663ee
3 changed files with 43 additions and 5 deletions
4
Makefile
4
Makefile
|
@ -5,6 +5,8 @@ endif
|
|||
include $(DEVKITARM)/base_rules
|
||||
|
||||
TARGET := hekate
|
||||
BLVERSION_MAJOR := 3
|
||||
BLVERSION_MINOR := 3
|
||||
BUILD := build
|
||||
OUTPUT := output
|
||||
SOURCEDIR = bootloader
|
||||
|
@ -53,6 +55,7 @@ OBJS += $(addprefix $(BUILD)/$(TARGET)/, \
|
|||
)
|
||||
|
||||
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
||||
CUSTOMDEFINES := -DBLVERSIONMJ=$(BLVERSION_MAJOR) -DBLVERSIONMN=$(BLVERSION_MINOR)
|
||||
CUSTOMDEFINES := -DMENU_LOGO_ENABLE #-DDEBUG
|
||||
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES)
|
||||
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections
|
||||
|
@ -76,6 +79,7 @@ $(MODULEDIRS):
|
|||
|
||||
$(TARGET).bin: $(BUILD)/$(TARGET)/$(TARGET).elf $(MODULEDIRS)
|
||||
$(OBJCOPY) -S -O binary $< $(OUTPUT)/$@
|
||||
@printf ICTC$(BLVERSION_MAJOR)$(BLVERSION_MINOR) >> $(OUTPUT)/$@
|
||||
|
||||
$(BUILD)/$(TARGET)/$(TARGET).elf: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@
|
||||
|
|
|
@ -59,6 +59,16 @@
|
|||
#include "ianos/ianos.h"
|
||||
#include "utils/dirlist.h"
|
||||
|
||||
#ifndef BLVERSIONMJ
|
||||
#define BLVERSIONMJ 9
|
||||
#endif
|
||||
#ifndef BLVERSIONMN
|
||||
#define BLVERSIONMN 9
|
||||
#endif
|
||||
|
||||
#define BOOTLOADER_UPDATED_MAGIC_ADDR 0x4003E000
|
||||
#define BOOTLOADER_UPDATED_MAGIC 0x424f4f54
|
||||
|
||||
//TODO: ugly.
|
||||
gfx_ctxt_t gfx_ctxt;
|
||||
gfx_con_t gfx_con;
|
||||
|
@ -1721,6 +1731,28 @@ out:
|
|||
btn_wait();
|
||||
}
|
||||
|
||||
void auto_launch_update()
|
||||
{
|
||||
FIL fp;
|
||||
if (*(vu32 *)BOOTLOADER_UPDATED_MAGIC_ADDR == BOOTLOADER_UPDATED_MAGIC)
|
||||
*(vu32 *)BOOTLOADER_UPDATED_MAGIC_ADDR = 0;
|
||||
else
|
||||
{
|
||||
if (sd_mount())
|
||||
{
|
||||
if (f_open(&fp, "bootloader/update.bin", FA_READ))
|
||||
return;
|
||||
else
|
||||
{
|
||||
f_close(&fp);
|
||||
*(vu32 *)BOOTLOADER_UPDATED_MAGIC_ADDR = BOOTLOADER_UPDATED_MAGIC;
|
||||
//launch_payload("bootloader/update.bin", true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ini_list_launcher()
|
||||
{
|
||||
u8 max_entries = 61;
|
||||
|
@ -2753,7 +2785,9 @@ extern void pivot_stack(u32 stack_top);
|
|||
|
||||
void ipl_main()
|
||||
{
|
||||
config_hw();
|
||||
// Skip config if we just updated the bootloader.
|
||||
if (*(u32 *)BOOTLOADER_UPDATED_MAGIC_ADDR != BOOTLOADER_UPDATED_MAGIC)
|
||||
config_hw();
|
||||
|
||||
//Pivot the stack so we have enough space.
|
||||
pivot_stack(0x90010000);
|
||||
|
|
|
@ -24,16 +24,16 @@
|
|||
// Module Callback
|
||||
typedef void (*cbMainModule_t)(const char *s);
|
||||
typedef void (*memcpy_t)(void *, void *, size_t);
|
||||
typedef void (*memset_t)(void *test, int, size_t);
|
||||
typedef void (*memset_t)(void *, int, size_t);
|
||||
|
||||
typedef struct moduleConfiguration_t
|
||||
typedef struct _bdkParams_t
|
||||
{
|
||||
gfx_con_t *gfxCon;
|
||||
gfx_ctxt_t *gfxCtx;
|
||||
heap_t *sharedHeap;
|
||||
memcpy_t memcpy;
|
||||
memset_t memset;
|
||||
} *pmoduleConfiguration_t;
|
||||
} *bdkParams_t;
|
||||
|
||||
// Module Entrypoint
|
||||
typedef void (*moduleEntrypoint_t)(cbMainModule_t, pmoduleConfiguration_t);
|
||||
typedef void (*moduleEntrypoint_t)(void *, bdkParams_t);
|
||||
|
|
Loading…
Reference in a new issue