Also move the arm11 init to the end of the install
This commit is contained in:
parent
445d22db97
commit
d95851286c
7
Makefile
7
Makefile
@ -16,6 +16,7 @@ revision := $(shell git describe --tags --match v[0-9]* --abbrev=8 | sed 's/-[0-
|
|||||||
|
|
||||||
dir_source := source
|
dir_source := source
|
||||||
dir_loader := loader
|
dir_loader := loader
|
||||||
|
dir_arm11 := arm11
|
||||||
dir_cakehax := CakeHax
|
dir_cakehax := CakeHax
|
||||||
dir_cakebrah := CakeBrah
|
dir_cakebrah := CakeBrah
|
||||||
dir_build := build
|
dir_build := build
|
||||||
@ -30,7 +31,7 @@ objects= $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
|||||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||||
|
|
||||||
bundled = $(dir_build)/loader.bin.o
|
bundled = $(dir_build)/loader.bin.o $(dir_build)/arm11.bin.o
|
||||||
|
|
||||||
define bin2o
|
define bin2o
|
||||||
bin2s $< | $(AS) -o $(@)
|
bin2s $< | $(AS) -o $(@)
|
||||||
@ -56,6 +57,7 @@ release: $(dir_out)/$(name)$(revision).7z
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@$(MAKE) -C $(dir_loader) clean
|
@$(MAKE) -C $(dir_loader) clean
|
||||||
|
@$(MAKE) -C $(dir_arm11) clean
|
||||||
@$(MAKE) $(FLAGS) -C $(dir_cakehax) clean
|
@$(MAKE) $(FLAGS) -C $(dir_cakehax) clean
|
||||||
@$(MAKE) $(FLAGS) -C $(dir_cakebrah) clean
|
@$(MAKE) $(FLAGS) -C $(dir_cakebrah) clean
|
||||||
@rm -rf $(dir_out) $(dir_build)
|
@rm -rf $(dir_out) $(dir_build)
|
||||||
@ -90,6 +92,9 @@ $(dir_build)/%.bin.o: $(dir_build)/%.bin
|
|||||||
$(dir_build)/loader.bin: $(dir_loader) $(dir_build)
|
$(dir_build)/loader.bin: $(dir_loader) $(dir_build)
|
||||||
@$(MAKE) -C $<
|
@$(MAKE) -C $<
|
||||||
|
|
||||||
|
$(dir_build)/arm11.bin: $(dir_arm11) $(dir_build)
|
||||||
|
@$(MAKE) -C $<
|
||||||
|
|
||||||
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
|
$(dir_build)/memory.o $(dir_build)/strings.o: CFLAGS += -O3
|
||||||
$(dir_build)/installer.o: CFLAGS += -DTITLE="\"$(name) $(revision)\""
|
$(dir_build)/installer.o: CFLAGS += -DTITLE="\"$(name) $(revision)\""
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ OC := arm-none-eabi-objcopy
|
|||||||
name := $(shell basename $(CURDIR))
|
name := $(shell basename $(CURDIR))
|
||||||
|
|
||||||
dir_source := source
|
dir_source := source
|
||||||
dir_arm11 := arm11
|
|
||||||
dir_build := build
|
dir_build := build
|
||||||
dir_out := ../$(dir_build)
|
dir_out := ../$(dir_build)
|
||||||
|
|
||||||
@ -26,37 +25,19 @@ objects = $(patsubst $(dir_source)/%.s, $(dir_build)/%.o, \
|
|||||||
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
$(patsubst $(dir_source)/%.c, $(dir_build)/%.o, \
|
||||||
$(call rwildcard, $(dir_source), *.s *.c)))
|
$(call rwildcard, $(dir_source), *.s *.c)))
|
||||||
|
|
||||||
bundled = $(dir_build)/arm11.bin.o
|
|
||||||
|
|
||||||
define bin2o
|
|
||||||
bin2s $< | $(AS) -o $(@)
|
|
||||||
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> $(dir_build)/bundled.h
|
|
||||||
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> $(dir_build)/bundled.h
|
|
||||||
endef
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(dir_out)/$(name).bin
|
all: $(dir_out)/$(name).bin
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@$(MAKE) -C $(dir_arm11) clean
|
|
||||||
@rm -rf $(dir_build)
|
@rm -rf $(dir_build)
|
||||||
|
|
||||||
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
|
$(dir_out)/$(name).bin: $(dir_build)/$(name).elf
|
||||||
$(OC) -S -O binary $< $@
|
$(OC) -S -O binary $< $@
|
||||||
|
|
||||||
$(dir_build)/$(name).elf: $(bundled) $(objects)
|
$(dir_build)/$(name).elf: $(objects)
|
||||||
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
$(LINK.o) -T linker.ld $(OUTPUT_OPTION) $^
|
||||||
|
|
||||||
$(dir_build)/%.bin.o: $(dir_build)/%.bin
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
$(dir_build)/arm11.bin: $(dir_arm11)
|
|
||||||
@mkdir -p "$(@D)"
|
|
||||||
@$(MAKE) -C $<
|
|
||||||
|
|
||||||
$(dir_build)/memory.o: CFLAGS += -O3
|
|
||||||
|
|
||||||
$(dir_build)/%.o: $(dir_source)/%.c
|
$(dir_build)/%.o: $(dir_source)/%.c
|
||||||
@mkdir -p "$(@D)"
|
@mkdir -p "$(@D)"
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
||||||
|
@ -20,27 +20,10 @@
|
|||||||
* Notices displayed by works containing it.
|
* Notices displayed by works containing it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "memory.h"
|
#include "types.h"
|
||||||
#include "../build/bundled.h"
|
|
||||||
|
|
||||||
#define A11_PAYLOAD_LOC 0x1FFF4C80 //Keep in mind this needs to be changed in the ld script for arm11 too
|
|
||||||
#define A11_ENTRYPOINT 0x1FFFFFF8
|
|
||||||
|
|
||||||
static inline void ownArm11(void)
|
|
||||||
{
|
|
||||||
memcpy((void *)A11_PAYLOAD_LOC, arm11_bin, arm11_bin_size);
|
|
||||||
|
|
||||||
*(vu32 *)A11_ENTRYPOINT = 1;
|
|
||||||
*(vu32 *)0x1FFAED80 = 0xE51FF004;
|
|
||||||
*(vu32 *)0x1FFAED84 = A11_PAYLOAD_LOC;
|
|
||||||
*(vu8 *)0x1FFFFFF0 = 2;
|
|
||||||
while(*(vu32 *)A11_ENTRYPOINT != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
ownArm11();
|
|
||||||
|
|
||||||
vu32 *payloadAddress = (vu32 *)0x23F00000;
|
vu32 *payloadAddress = (vu32 *)0x23F00000;
|
||||||
payloadAddress[1] = 0xDEADCAFE;
|
payloadAddress[1] = 0xDEADCAFE;
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* memory.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "memory.h"
|
|
||||||
|
|
||||||
void memcpy(void *dest, const void *src, u32 size)
|
|
||||||
{
|
|
||||||
u8 *destc = (u8 *)dest;
|
|
||||||
const u8 *srcc = (const u8 *)src;
|
|
||||||
|
|
||||||
for(u32 i = 0; i < size; i++)
|
|
||||||
destc[i] = srcc[i];
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* memory.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
void memcpy(void *dest, const void *src, u32 size);
|
|
@ -64,9 +64,9 @@ static const u8 sectorHashRetail[SHA_256_HASH_SIZE] = {
|
|||||||
|
|
||||||
u32 posY;
|
u32 posY;
|
||||||
|
|
||||||
static void drawTitle(void)
|
static void drawTitle(bool isOtpless)
|
||||||
{
|
{
|
||||||
initScreens();
|
initScreens(isOtpless);
|
||||||
|
|
||||||
posY = drawString(TITLE, 10, 10, COLOR_TITLE);
|
posY = drawString(TITLE, 10, 10, COLOR_TITLE);
|
||||||
posY = drawString("Thanks to delebile, #cakey and StandardBus", 10, posY + SPACING_Y, COLOR_WHITE);
|
posY = drawString("Thanks to delebile, #cakey and StandardBus", 10, posY + SPACING_Y, COLOR_WHITE);
|
||||||
@ -76,7 +76,7 @@ void main(void)
|
|||||||
{
|
{
|
||||||
bool isOtpless = ISA9LH && magic == 0xDEADCAFE;
|
bool isOtpless = ISA9LH && magic == 0xDEADCAFE;
|
||||||
|
|
||||||
if(!isOtpless) drawTitle();
|
if(!isOtpless) drawTitle(false);
|
||||||
|
|
||||||
if(!sdmmc_sdcard_init(isOtpless))
|
if(!sdmmc_sdcard_init(isOtpless))
|
||||||
shutdown(1, "Error: failed to initialize SD and NAND");
|
shutdown(1, "Error: failed to initialize SD and NAND");
|
||||||
@ -289,7 +289,7 @@ static inline void installer(bool isOtpless)
|
|||||||
|
|
||||||
writeFirm((u8 *)FIRM0_OFFSET, false, FIRM0_SIZE);
|
writeFirm((u8 *)FIRM0_OFFSET, false, FIRM0_SIZE);
|
||||||
|
|
||||||
if(isOtpless) drawTitle();
|
if(isOtpless) drawTitle(true);
|
||||||
|
|
||||||
shutdown(2, ISA9LH && !isOtpless ? "Update: success!" : "Full install: success!");
|
shutdown(2, ISA9LH && !isOtpless ? "Update: success!" : "Full install: success!");
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,23 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
#include "../build/bundled.h"
|
||||||
|
|
||||||
vu32 *arm11Entry = (vu32 *)BRAHMA_ARM11_ENTRY;
|
vu32 *arm11Entry = (vu32 *)BRAHMA_ARM11_ENTRY;
|
||||||
|
|
||||||
|
static inline void ownArm11(void)
|
||||||
|
{
|
||||||
|
memcpy((void *)A11_PAYLOAD_LOC, arm11_bin, arm11_bin_size);
|
||||||
|
|
||||||
|
*arm11Entry = 1;
|
||||||
|
*(vu32 *)0x1FFAED80 = 0xE51FF004;
|
||||||
|
*(vu32 *)0x1FFAED84 = A11_PAYLOAD_LOC;
|
||||||
|
*(vu8 *)0x1FFFFFF0 = 2;
|
||||||
|
while(*arm11Entry != 0);
|
||||||
|
}
|
||||||
|
|
||||||
static void invokeArm11Function(void (*func)())
|
static void invokeArm11Function(void (*func)())
|
||||||
{
|
{
|
||||||
*arm11Entry = (u32)func;
|
*arm11Entry = (u32)func;
|
||||||
@ -74,7 +87,7 @@ void clearScreens(void)
|
|||||||
invokeArm11Function(ARM11);
|
invokeArm11Function(ARM11);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initScreens(void)
|
void initScreens(bool isOtpless)
|
||||||
{
|
{
|
||||||
void __attribute__((naked)) initSequence(void)
|
void __attribute__((naked)) initSequence(void)
|
||||||
{
|
{
|
||||||
@ -182,10 +195,12 @@ void initScreens(void)
|
|||||||
|
|
||||||
if(!ARESCREENSINITED)
|
if(!ARESCREENSINITED)
|
||||||
{
|
{
|
||||||
invokeArm11Function(initSequence);
|
|
||||||
|
|
||||||
wait(3ULL);
|
wait(3ULL);
|
||||||
|
|
||||||
|
if(isOtpless) ownArm11();
|
||||||
|
|
||||||
|
invokeArm11Function(initSequence);
|
||||||
|
|
||||||
//Turn on backlight
|
//Turn on backlight
|
||||||
i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A);
|
i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#define ARESCREENSINITED (PDN_GPU_CNT != 1)
|
#define ARESCREENSINITED (PDN_GPU_CNT != 1)
|
||||||
|
|
||||||
#define BRAHMA_ARM11_ENTRY 0x1FFFFFF8
|
#define BRAHMA_ARM11_ENTRY 0x1FFFFFF8
|
||||||
|
#define A11_PAYLOAD_LOC 0x1FFF4C80
|
||||||
#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)();
|
#define WAIT_FOR_ARM9() *arm11Entry = 0; while(!*arm11Entry); ((void (*)())*arm11Entry)();
|
||||||
|
|
||||||
#define SCREEN_TOP_WIDTH 400
|
#define SCREEN_TOP_WIDTH 400
|
||||||
@ -48,4 +49,4 @@ static struct fb {
|
|||||||
} *const fb = (struct fb *)0x23FFFE00;
|
} *const fb = (struct fb *)0x23FFFE00;
|
||||||
|
|
||||||
void clearScreens(void);
|
void clearScreens(void);
|
||||||
void initScreens(void);
|
void initScreens(bool isOtpless);
|
@ -65,8 +65,6 @@ void mcuReboot(void)
|
|||||||
//Ensure that all memory transfers have completed and that the data cache has been flushed
|
//Ensure that all memory transfers have completed and that the data cache has been flushed
|
||||||
flushEntireDCache();
|
flushEntireDCache();
|
||||||
|
|
||||||
wait(3ULL);
|
|
||||||
|
|
||||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
||||||
while(true);
|
while(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user