Disable sleep mode on the SPI NOR Flash when the version is unknown. This is because the current bootloader (which does not exposes its version) cannot initialize the chip when it's in sleep mode.
This feature will be re-enabled when the bootloader expses it's version.
This commit is contained in:
parent
ab7acd0f07
commit
1bb2eb9dcd
26
src/BootloaderVersion.cpp
Normal file
26
src/BootloaderVersion.cpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <cstdint>
|
||||
#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;
|
||||
}
|
12
src/BootloaderVersion.h
Normal file
12
src/BootloaderVersion.h
Normal file
|
@ -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();
|
||||
};
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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<uint8_t>(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() {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <drivers/InternalFlash.h>
|
||||
#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:
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user