Clear a9lh stage2 section & fix compile (#39)

Fixes #40 and #41
This commit is contained in:
MechanicalDragon 2020-05-06 08:52:23 -07:00 committed by GitHub
parent 2d6def3c08
commit 07207a2fb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -25,11 +25,11 @@ INCLUDES := source source/common source/font source/fs source/crypto source/fatf
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork -flto ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -Wextra -Wpedantic -Wcast-align -Wno-main -O2\ CFLAGS := -g -Wall -Wextra -Wpedantic -Wcast-align -Wno-main -O2\
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=gnu11\ -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math -std=gnu11\
$(ARCH) -fno-builtin-memcpy $(ARCH) -fdata-sections -ffunction-sections
CFLAGS += $(INCLUDE) -DARM9 CFLAGS += $(INCLUDE) -DARM9
@ -53,7 +53,7 @@ endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH) ASFLAGS := -g -mcpu=arm946e-s $(ARCH)
LDFLAGS = -T../link.ld -nostartfiles -g $(ARCH) -Wl,-Map,$(TARGET).map LDFLAGS = -T../link.ld -nostartfiles -g $(ARCH) -Wl,-Map,$(TARGET).map
LIBS := LIBS :=

View File

@ -3,6 +3,7 @@
#include "validator.h" #include "validator.h"
#include "unittype.h" #include "unittype.h"
#include "nand.h" #include "nand.h"
#include "sdmmc.h"
#include "ui.h" #include "ui.h"
#include "qff.h" #include "qff.h"
#include "hid.h" #include "hid.h"
@ -17,6 +18,8 @@
#define NAME_FIRMBACKUP INPUT_PATH "/firm%lu_enc.bak" #define NAME_FIRMBACKUP INPUT_PATH "/firm%lu_enc.bak"
#define NAME_SECTORBACKUP INPUT_PATH "/sector0x96_enc.bak" #define NAME_SECTORBACKUP INPUT_PATH "/sector0x96_enc.bak"
#define MAX_STAGE2_SIZE 0x89A00
#define STATUS_GREY -1 #define STATUS_GREY -1
#define STATUS_GREEN 0 #define STATUS_GREEN 0
#define STATUS_YELLOW 1 #define STATUS_YELLOW 1
@ -279,6 +282,11 @@ u32 SafeB9SInstaller(void) {
ShowInstallerStatus(); ShowInstallerStatus();
} }
if (ret != 0) break; if (ret != 0) break;
uint8_t emptyStage2[MAX_STAGE2_SIZE]={0};
// Uninstall a9lh stage 2 always if firm flashed ok
// This prevents false positives in the event of cfw uninstall
ret = sdmmc_nand_writesectors(0x5C000, MAX_STAGE2_SIZE / 0x200, emptyStage2);
if (ret != 0) break;
if ((IS_A9LH && !IS_SIGHAX)) { if ((IS_A9LH && !IS_SIGHAX)) {
snprintf(msgInstall, 64, "0x96 revert..."); snprintf(msgInstall, 64, "0x96 revert...");
ShowInstallerStatus(); ShowInstallerStatus();