mirror of
https://github.com/AuroraWright/SafeA9LHInstaller.git
synced 2025-06-25 21:22:45 +00:00
Add delays when using the MCU, move screen init routines after OTPless install completes
This commit is contained in:
parent
3d477d3565
commit
9898020267
@ -64,14 +64,19 @@ static const u8 sectorHashRetail[SHA_256_HASH_SIZE] = {
|
||||
|
||||
u32 posY;
|
||||
|
||||
void main(void)
|
||||
static void drawTitle(void)
|
||||
{
|
||||
bool isOtpless = ISA9LH && magic == 0xDEADCAFE;
|
||||
|
||||
initScreens();
|
||||
|
||||
posY = drawString(TITLE, 10, 10, COLOR_TITLE);
|
||||
posY = drawString("Thanks to delebile, #cakey and StandardBus", 10, posY + SPACING_Y, COLOR_WHITE);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
bool isOtpless = ISA9LH && magic == 0xDEADCAFE;
|
||||
|
||||
if(!isOtpless) drawTitle();
|
||||
|
||||
if(!sdmmc_sdcard_init(isOtpless))
|
||||
shutdown(1, "Error: failed to initialize SD and NAND");
|
||||
@ -84,11 +89,6 @@ void main(void)
|
||||
posY = drawString("Press any other button to shutdown", 10, posY, COLOR_WHITE);
|
||||
pressed = waitInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
posY = drawString("Finalizing install...", 10, posY + SPACING_Y, COLOR_WHITE);
|
||||
pressed = 0;
|
||||
}
|
||||
|
||||
if(isOtpless || pressed == BUTTON_SELECT) installer(isOtpless);
|
||||
if(pressed == BUTTON_START && ISA9LH) uninstaller();
|
||||
@ -289,6 +289,8 @@ static inline void installer(bool isOtpless)
|
||||
|
||||
writeFirm((u8 *)FIRM0_OFFSET, false, FIRM0_SIZE);
|
||||
|
||||
if(isOtpless) drawTitle();
|
||||
|
||||
shutdown(2, ISA9LH && !isOtpless ? "Update: success!" : "Full install: success!");
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "screen.h"
|
||||
#include "cache.h"
|
||||
#include "utils.h"
|
||||
#include "i2c.h"
|
||||
|
||||
vu32 *arm11Entry = (vu32 *)BRAHMA_ARM11_ENTRY;
|
||||
@ -183,6 +184,8 @@ void initScreens(void)
|
||||
{
|
||||
invokeArm11Function(initSequence);
|
||||
|
||||
wait(3ULL);
|
||||
|
||||
//Turn on backlight
|
||||
i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A);
|
||||
}
|
||||
|
@ -8,33 +8,56 @@
|
||||
#include "cache.h"
|
||||
#include "i2c.h"
|
||||
|
||||
static void startChrono(void)
|
||||
{
|
||||
REG_TIMER_CNT(0) = 0; //67MHz
|
||||
for(u32 i = 1; i < 4; i++) REG_TIMER_CNT(i) = 4; //Count-up
|
||||
|
||||
for(u32 i = 0; i < 4; i++) REG_TIMER_VAL(i) = 0;
|
||||
|
||||
REG_TIMER_CNT(0) = 0x80; //67MHz; enabled
|
||||
for(u32 i = 1; i < 4; i++) REG_TIMER_CNT(i) = 0x84; //Count-up; enabled
|
||||
}
|
||||
|
||||
static u64 chrono(void)
|
||||
{
|
||||
u64 res;
|
||||
for(u32 i = 0; i < 4; i++) res |= REG_TIMER_VAL(i) << (16 * i);
|
||||
|
||||
res /= (TICKS_PER_SEC / 1000);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 waitInput(void)
|
||||
{
|
||||
bool pressedKey = false;
|
||||
u32 key;
|
||||
u32 key,
|
||||
oldKey = HID_PAD;
|
||||
|
||||
//Wait for no keys to be pressed
|
||||
while(HID_PAD);
|
||||
|
||||
do
|
||||
while(!pressedKey)
|
||||
{
|
||||
//Wait for a key to be pressed
|
||||
while(!HID_PAD);
|
||||
|
||||
key = HID_PAD;
|
||||
|
||||
//Make sure it's pressed
|
||||
for(u32 i = 0x13000; i > 0; i--)
|
||||
if(!key) oldKey = key;
|
||||
else if(key != oldKey)
|
||||
{
|
||||
if(key != HID_PAD) break;
|
||||
if(i == 1) pressedKey = true;
|
||||
//Make sure the key is pressed
|
||||
u32 i;
|
||||
for(i = 0; i < 0x13000 && key == HID_PAD; i++);
|
||||
if(i == 0x13000) pressedKey = true;
|
||||
}
|
||||
}
|
||||
while(!pressedKey);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void wait(u64 amount)
|
||||
{
|
||||
startChrono();
|
||||
while(chrono() < amount);
|
||||
}
|
||||
|
||||
void mcuReboot(void)
|
||||
{
|
||||
clearScreens();
|
||||
@ -42,6 +65,8 @@ void mcuReboot(void)
|
||||
//Ensure that all memory transfers have completed and that the data cache has been flushed
|
||||
flushEntireDCache();
|
||||
|
||||
wait(3ULL);
|
||||
|
||||
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2);
|
||||
while(true);
|
||||
}
|
||||
|
@ -21,9 +21,14 @@
|
||||
#define COLOR_RED 0x0000FF
|
||||
#define COLOR_GREEN 0x00FF00
|
||||
|
||||
#define TICKS_PER_SEC 67027964ULL
|
||||
#define REG_TIMER_CNT(i) *(vu16 *)(0x10003002 + 4 * i)
|
||||
#define REG_TIMER_VAL(i) *(vu16 *)(0x10003000 + 4 * i)
|
||||
|
||||
extern u32 posY;
|
||||
|
||||
u32 waitInput(void);
|
||||
void wait(u64 amount);
|
||||
void mcuReboot(void);
|
||||
void inputSequence(void);
|
||||
void shutdown(u32 mode, const char *message);
|
Loading…
x
Reference in New Issue
Block a user