Add autolaunch updated bootloader (mostly for modchips)

This commit is contained in:
Kostas Missos 2018-08-21 04:41:16 +03:00
parent 5328f89ffe
commit 13a07663ee
3 changed files with 43 additions and 5 deletions

View file

@ -5,6 +5,8 @@ endif
include $(DEVKITARM)/base_rules include $(DEVKITARM)/base_rules
TARGET := hekate TARGET := hekate
BLVERSION_MAJOR := 3
BLVERSION_MINOR := 3
BUILD := build BUILD := build
OUTPUT := output OUTPUT := output
SOURCEDIR = bootloader SOURCEDIR = bootloader
@ -53,6 +55,7 @@ OBJS += $(addprefix $(BUILD)/$(TARGET)/, \
) )
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
CUSTOMDEFINES := -DBLVERSIONMJ=$(BLVERSION_MAJOR) -DBLVERSIONMN=$(BLVERSION_MINOR)
CUSTOMDEFINES := -DMENU_LOGO_ENABLE #-DDEBUG CUSTOMDEFINES := -DMENU_LOGO_ENABLE #-DDEBUG
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES) 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 LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections
@ -76,6 +79,7 @@ $(MODULEDIRS):
$(TARGET).bin: $(BUILD)/$(TARGET)/$(TARGET).elf $(MODULEDIRS) $(TARGET).bin: $(BUILD)/$(TARGET)/$(TARGET).elf $(MODULEDIRS)
$(OBJCOPY) -S -O binary $< $(OUTPUT)/$@ $(OBJCOPY) -S -O binary $< $(OUTPUT)/$@
@printf ICTC$(BLVERSION_MAJOR)$(BLVERSION_MINOR) >> $(OUTPUT)/$@
$(BUILD)/$(TARGET)/$(TARGET).elf: $(OBJS) $(BUILD)/$(TARGET)/$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@ $(CC) $(LDFLAGS) -T $(SOURCEDIR)/link.ld $^ -o $@

View file

@ -59,6 +59,16 @@
#include "ianos/ianos.h" #include "ianos/ianos.h"
#include "utils/dirlist.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. //TODO: ugly.
gfx_ctxt_t gfx_ctxt; gfx_ctxt_t gfx_ctxt;
gfx_con_t gfx_con; gfx_con_t gfx_con;
@ -1721,6 +1731,28 @@ out:
btn_wait(); 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() void ini_list_launcher()
{ {
u8 max_entries = 61; u8 max_entries = 61;
@ -2753,6 +2785,8 @@ extern void pivot_stack(u32 stack_top);
void ipl_main() void ipl_main()
{ {
// Skip config if we just updated the bootloader.
if (*(u32 *)BOOTLOADER_UPDATED_MAGIC_ADDR != BOOTLOADER_UPDATED_MAGIC)
config_hw(); config_hw();
//Pivot the stack so we have enough space. //Pivot the stack so we have enough space.

View file

@ -24,16 +24,16 @@
// Module Callback // Module Callback
typedef void (*cbMainModule_t)(const char *s); typedef void (*cbMainModule_t)(const char *s);
typedef void (*memcpy_t)(void *, void *, size_t); 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_con_t *gfxCon;
gfx_ctxt_t *gfxCtx; gfx_ctxt_t *gfxCtx;
heap_t *sharedHeap; heap_t *sharedHeap;
memcpy_t memcpy; memcpy_t memcpy;
memset_t memset; memset_t memset;
} *pmoduleConfiguration_t; } *bdkParams_t;
// Module Entrypoint // Module Entrypoint
typedef void (*moduleEntrypoint_t)(cbMainModule_t, pmoduleConfiguration_t); typedef void (*moduleEntrypoint_t)(void *, bdkParams_t);