diff --git a/src/BootloaderVersion.cpp b/src/BootloaderVersion.cpp new file mode 100644 index 00000000..8555593f --- /dev/null +++ b/src/BootloaderVersion.cpp @@ -0,0 +1,26 @@ +#include +#include "BootloaderVersion.h" + +using namespace Pinetime; + +// NOTE : current bootloader does not export its version to the application firmware. + +uint32_t BootloaderVersion::Major() { + return 0; +} + +uint32_t BootloaderVersion::Minor() { + return 0; +} + +uint32_t BootloaderVersion::Patch() { + return 0; +} + +const char *BootloaderVersion::VersionString() { + return "0.0.0"; +} + +bool BootloaderVersion::IsValid() { + return false; +} diff --git a/src/BootloaderVersion.h b/src/BootloaderVersion.h new file mode 100644 index 00000000..c7fcbd98 --- /dev/null +++ b/src/BootloaderVersion.h @@ -0,0 +1,12 @@ +#pragma once + +namespace Pinetime { + class BootloaderVersion { + public: + static uint32_t Major(); + static uint32_t Minor(); + static uint32_t Patch(); + static const char* VersionString(); + static bool IsValid(); + }; +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd37810f..af0b110e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -322,6 +322,7 @@ list(APPEND IMAGE_FILES ) list(APPEND SOURCE_FILES + BootloaderVersion.cpp logging/NrfLogger.cpp displayapp/DisplayApp.cpp displayapp/screens/Screen.cpp @@ -397,6 +398,7 @@ list(APPEND GRAPHICS_SOURCE_FILES ) set(INCLUDE_FILES + BootloaderVersion.h logging/Logger.h logging/NrfLogger.h displayapp/DisplayApp.h diff --git a/src/drivers/SpiNorFlash.cpp b/src/drivers/SpiNorFlash.cpp index 351a9dfc..bd24834e 100644 --- a/src/drivers/SpiNorFlash.cpp +++ b/src/drivers/SpiNorFlash.cpp @@ -12,7 +12,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi{spi} { void SpiNorFlash::Init() { device_id = ReadIdentificaion(); - NRF_LOG_INFO("[SPI FLASH] Manufacturer : %d, Memory type : %d, memory density : %d", device_id.manufacturer, device_id.type, device_id.density); + NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d", device_id.manufacturer, device_id.type, device_id.density); } void SpiNorFlash::Uninit() { @@ -22,7 +22,7 @@ void SpiNorFlash::Uninit() { void SpiNorFlash::Sleep() { auto cmd = static_cast(Commands::DeepPowerDown); spi.Write(&cmd, sizeof(uint8_t)); - NRF_LOG_INFO("[FLASH] Sleep") + NRF_LOG_INFO("[SpiNorFlash] Sleep") } void SpiNorFlash::Wakeup() { @@ -38,7 +38,7 @@ void SpiNorFlash::Wakeup() { else { NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: %d", id); } - NRF_LOG_INFO("[FLASH] Wakeup") + NRF_LOG_INFO("[SpiNorFlash] Wakeup") } SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() { diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 3efe21b8..dac4ce29 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -13,6 +13,7 @@ #include #include "main.h" #include "components/ble/NimbleController.h" +#include "../BootloaderVersion.h" using namespace Pinetime::System; @@ -161,7 +162,11 @@ void SystemTask::Work() { ReloadIdleTimer(); break; case Messages::OnDisplayTaskSleeping: - spiNorFlash.Sleep(); + if(BootloaderVersion::IsValid()) { + // First versions of the bootloader do not expose their version and cannot initialize the SPI NOR FLASH + // if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions. + spiNorFlash.Sleep(); + } lcd.Sleep(); touchPanel.Sleep();