Skip to content

Commit

Permalink
[bootloader] Mark Epsilon 20.3 as safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaya-Cout committed Feb 17, 2023
1 parent c0d9980 commit 1067216
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 71 deletions.
2 changes: 1 addition & 1 deletion apps/on_boarding/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool App::processEvent(Ion::Events::Event e) {
if (e == Ion::Events::Home) {
return true;
}
if (e == Ion::Events::OnOff) {
if (e == Ion::Events::OnOff && !GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
Ion::Power::standby(); // Force a core reset to exit
}
return ::App::processEvent(e);
Expand Down
4 changes: 2 additions & 2 deletions bootloader/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void Boot::patchKernel(const Slot & s) {
data[origin_isr + sizeof(uint32_t) * 6 + 1] = ptr[1];
data[origin_isr + sizeof(uint32_t) * 6 + 2] = ptr[2];
data[origin_isr + sizeof(uint32_t) * 6 + 3] = ptr[3];

// data[origin_isr + sizeof(uint32_t) * 5] = ptr[0]; // MemManage
// data[origin_isr + sizeof(uint32_t) * 5 + 1] = ptr[1];
// data[origin_isr + sizeof(uint32_t) * 5 + 2] = ptr[2];
Expand All @@ -107,7 +107,7 @@ void Boot::bootSlot(Bootloader::Slot s) {
if (!s.userlandHeader()->isOmega() && !s.userlandHeader()->isUpsilon()) {
// We are trying to boot epsilon, so we check the version and show an advertisement if needed
const char * version = s.userlandHeader()->version();
const char * min = "20.0.0";
const char * min = "20.3.1";
int versionSum = Utility::versionSum(version, strlen(version));
int minimalVersionTrigger = Utility::versionSum(min, strlen(min));
if (versionSum >= minimalVersionTrigger) {
Expand Down
133 changes: 67 additions & 66 deletions bootloader/drivers/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void initClocks() {
ahb1enr.setGPIOCEN(true);
ahb1enr.setGPIODEN(true);
ahb1enr.setGPIOEEN(true);
ahb1enr.setDMA2EN(true);
ahb1enr.setDMA2EN(false);
RCC.AHB1ENR()->set(ahb1enr);

// AHB2 bus
Expand All @@ -282,16 +282,16 @@ void initClocks() {
RCC.AHB3ENR()->setFSMCEN(true);

// APB1 bus
// We're using TIM3 for the LEDs
RCC.APB1ENR()->setTIM3EN(true);
// We're using TIM3 for the LEDs (disabled to stick with E16+ Bootloader)
/*RCC.APB1ENR()->setTIM3EN(true); */
RCC.APB1ENR()->setPWREN(true);
RCC.APB1ENR()->setRTCAPB(true);

// APB2 bus
class RCC::APB2ENR apb2enr(0); // Reset value
apb2enr.setADC1EN(true);
apb2enr.setSYSCFGEN(true);
apb2enr.setUSART6EN(true); // TODO required if building bench target only?
apb2enr.setUSART6EN(false); // TODO required if building bench target only? (disabled to stick with E16+ Bootloader)
RCC.APB2ENR()->set(apb2enr);

// Configure clocks in sleep mode
Expand All @@ -300,86 +300,86 @@ void initClocks() {
ahb1lpenr.setGPIOALPEN(true); // Enable IO port A for Charging/USB plug/Keyboard pins
ahb1lpenr.setGPIOBLPEN(true); // Enable IO port B for LED pins
ahb1lpenr.setGPIOCLPEN(true); // Enable IO port C for LED/Keyboard pins
ahb1lpenr.setGPIODLPEN(false); // Disable IO port D (LCD...)
ahb1lpenr.setGPIODLPEN(true); // Enable IO port D (LCD...)
ahb1lpenr.setGPIOELPEN(true); // Enable IO port E for Keyboard/Battery pins
ahb1lpenr.setGPIOFLPEN(false); // Disable IO port F
ahb1lpenr.setGPIOGLPEN(false); // Disable IO port G
ahb1lpenr.setGPIOHLPEN(false); // Disable IO port H
ahb1lpenr.setGPIOILPEN(false); // Disable IO port I
ahb1lpenr.setCRCLPEN(false);
ahb1lpenr.setFLITFLPEN(false);
ahb1lpenr.setSRAM1LPEN(false);
ahb1lpenr.setDMA1LPEN(false);
ahb1lpenr.setDMA2LPEN(false);
ahb1lpenr.setAXILPEN(false);
ahb1lpenr.setSRAM2LPEN(false);
ahb1lpenr.setBKPSRAMLPEN(false);
ahb1lpenr.setDTCMLPEN(false);
ahb1lpenr.setOTGHSLPEN(false);
ahb1lpenr.setOTGHSULPILPEN(false);
ahb1lpenr.setGPIOFLPEN(true); // Enable IO port F
ahb1lpenr.setGPIOGLPEN(true); // Enable IO port G
ahb1lpenr.setGPIOHLPEN(true); // Enable IO port H
ahb1lpenr.setGPIOILPEN(true); // Enable IO port I
ahb1lpenr.setCRCLPEN(true);
ahb1lpenr.setFLITFLPEN(true);
ahb1lpenr.setSRAM1LPEN(true);
ahb1lpenr.setDMA1LPEN(true);
ahb1lpenr.setDMA2LPEN(true);
ahb1lpenr.setAXILPEN(true);
ahb1lpenr.setSRAM2LPEN(true);
ahb1lpenr.setBKPSRAMLPEN(true);
ahb1lpenr.setDTCMLPEN(true);
ahb1lpenr.setOTGHSLPEN(true);
ahb1lpenr.setOTGHSULPILPEN(true);
RCC.AHB1LPENR()->set(ahb1lpenr);

// AHB2 peripheral clock enable in low-power mode register
class RCC::AHB2LPENR ahb2lpenr(0x000000F1); // Reset value
ahb2lpenr.setOTGFSLPEN(false);
ahb2lpenr.setRNGLPEN(false);
ahb2lpenr.setAESLPEN(false);
ahb2lpenr.setOTGFSLPEN(true);
ahb2lpenr.setRNGLPEN(true);
ahb2lpenr.setAESLPEN(true);
RCC.AHB2LPENR()->set(ahb2lpenr);

// AHB3 peripheral clock enable in low-power mode register
class RCC::AHB3LPENR ahb3lpenr(0x00000003); // Reset value
ahb3lpenr.setFMCLPEN(false);
ahb3lpenr.setQSPILPEN(false);
ahb3lpenr.setFMCLPEN(true);
ahb3lpenr.setQSPILPEN(true);
RCC.AHB3LPENR()->set(ahb3lpenr);

// APB1 peripheral clock enable in low-power mode register
class RCC::APB1LPENR apb1lpenr(0xFFFFCBFF); // Reset value
apb1lpenr.setTIM2LPEN(false);
apb1lpenr.setTIM2LPEN(true);
apb1lpenr.setTIM3LPEN(true); // Enable TIM3 in sleep mode for LEDs
apb1lpenr.setTIM4LPEN(false);
apb1lpenr.setTIM5LPEN(false);
apb1lpenr.setTIM6LPEN(false);
apb1lpenr.setTIM7LPEN(false);
apb1lpenr.setTIM12LPEN(false);
apb1lpenr.setTIM13LPEN(false);
apb1lpenr.setTIM14LPEN(false);
apb1lpenr.setRTCAPBLPEN(false);
apb1lpenr.setWWDGLPEN(false);
apb1lpenr.setSPI2LPEN(false);
apb1lpenr.setSPI3LPEN(false);
apb1lpenr.setUSART2LPEN(false);
apb1lpenr.setUSART3LPEN(false);
apb1lpenr.setI2C1LPEN(false);
apb1lpenr.setI2C2LPEN(false);
apb1lpenr.setI2C3LPEN(false);
apb1lpenr.setCAN1LPEN(false);
apb1lpenr.setPWRLPEN(false);
apb1lpenr.setLPTIM1LPEN(false);
apb1lpenr.setUSART4LPEN(false);
apb1lpenr.setUSART5LPEN(false);
apb1lpenr.setOTGHSLPEN(false);
apb1lpenr.setOTGHSULPILPEN(false);
apb1lpenr.setTIM4LPEN(true);
apb1lpenr.setTIM5LPEN(true);
apb1lpenr.setTIM6LPEN(true);
apb1lpenr.setTIM7LPEN(true);
apb1lpenr.setTIM12LPEN(true);
apb1lpenr.setTIM13LPEN(true);
apb1lpenr.setTIM14LPEN(true);
apb1lpenr.setRTCAPBLPEN(true);
apb1lpenr.setWWDGLPEN(true);
apb1lpenr.setSPI2LPEN(true);
apb1lpenr.setSPI3LPEN(true);
apb1lpenr.setUSART2LPEN(true);
apb1lpenr.setUSART3LPEN(true);
apb1lpenr.setI2C1LPEN(true);
apb1lpenr.setI2C2LPEN(true);
apb1lpenr.setI2C3LPEN(true);
apb1lpenr.setCAN1LPEN(true);
apb1lpenr.setPWRLPEN(true);
apb1lpenr.setLPTIM1LPEN(true);
apb1lpenr.setUSART4LPEN(true);
apb1lpenr.setUSART5LPEN(true);
apb1lpenr.setOTGHSLPEN(true);
apb1lpenr.setOTGHSULPILPEN(true);
RCC.APB1LPENR()->set(apb1lpenr);

// APB2 peripheral clock enable in low-power mode register
class RCC::APB2LPENR apb2lpenr(0x04F77F33); // Reset value
apb2lpenr.setTIM1LPEN(false);
apb2lpenr.setTIM8LPEN(false);
apb2lpenr.setUSART1LPEN(false);
apb2lpenr.setUSART6LPEN(false);
apb2lpenr.setADC1LPEN(false);
apb2lpenr.setSPI1LPEN(false);
apb2lpenr.setSPI4LPEN(false);
apb2lpenr.setSYSCFGLPEN(false);
apb2lpenr.setTIM9LPEN(false);
apb2lpenr.setTIM10LPEN(false);
apb2lpenr.setTIM11LPEN(false);
apb2lpenr.setSPI5LPEN(false);
apb2lpenr.setSDMMC2LPEN(false);
apb2lpenr.setADC2LPEN(false);
apb2lpenr.setADC3LPEN(false);
apb2lpenr.setSAI1LPEN(false);
apb2lpenr.setSAI2LPEN(false);
apb2lpenr.setTIM1LPEN(true);
apb2lpenr.setTIM8LPEN(true);
apb2lpenr.setUSART1LPEN(true);
apb2lpenr.setUSART6LPEN(true);
apb2lpenr.setADC1LPEN(true);
apb2lpenr.setSPI1LPEN(true);
apb2lpenr.setSPI4LPEN(true);
apb2lpenr.setSYSCFGLPEN(true);
apb2lpenr.setTIM9LPEN(true);
apb2lpenr.setTIM10LPEN(true);
apb2lpenr.setTIM11LPEN(true);
apb2lpenr.setSPI5LPEN(true);
apb2lpenr.setSDMMC2LPEN(true);
apb2lpenr.setADC2LPEN(true);
apb2lpenr.setADC3LPEN(true);
apb2lpenr.setSAI1LPEN(true);
apb2lpenr.setSAI2LPEN(true);
RCC.APB2LPENR()->set(apb2lpenr);
}

Expand All @@ -399,6 +399,7 @@ void shutdownClocks(bool keepLEDAwake) {
class RCC::AHB1ENR ahb1enr(0x00100000); // Reset value
if (keepLEDAwake) {
apb1enr.setTIM3EN(true);
apb1enr.setTIM5EN(true);
ahb1enr.setGPIOBEN(true);
}
RCC.APB1ENR()->set(apb1enr);
Expand Down
4 changes: 2 additions & 2 deletions bootloader/interface/static/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Bootloader {
class Messages {
public:
constexpr static const char * mainTitle = "Upsilon Calculator";

// Home menu
constexpr static const char * homeTitle = "Select a slot";

Expand Down Expand Up @@ -72,7 +72,7 @@ class Messages {
constexpr static const char * aboutMessage4 = "and select the OS";
constexpr static const char * aboutMessage5 = "to boot.";

constexpr static const char * bootloaderVersion = "Version 1.0.2 - FREED0M.20";
constexpr static const char * bootloaderVersion = "Version 1.0.3 - FREED0M.20.3";

//USB NAMES
constexpr static const char * usbUpsilonBootloader = "Upsilon Bootloader";
Expand Down
1 change: 1 addition & 0 deletions ion/src/device/regs/rcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class RCC {
public:
using Register32::Register32;
REGS_BOOL_FIELD(TIM3EN, 1);
REGS_BOOL_FIELD(TIM5EN, 3);
REGS_BOOL_FIELD(RTCAPB, 10);
REGS_BOOL_FIELD(SPI3EN, 15);
REGS_BOOL_FIELD(USART3EN, 18);
Expand Down
1 change: 1 addition & 0 deletions ion/src/device/shared/regs/rcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class RCC {
public:
using Register32::Register32;
REGS_BOOL_FIELD(TIM3EN, 1);
REGS_BOOL_FIELD(TIM5EN, 3);
REGS_BOOL_FIELD(RTCAPB, 10);
REGS_BOOL_FIELD(SPI3EN, 15);
REGS_BOOL_FIELD(USART3EN, 18);
Expand Down

0 comments on commit 1067216

Please sign in to comment.