SPI flash sleep if bootloader >= 1.0.0 (#322)
* Retrieve and display bootloader version - Display bootloader version on System Info screen - Enable SPI flash sleep mode if bootloader version >= 1.0.0 * Wait for SPI flash to wakeup before starting OTA DFU
This commit is contained in:
parent
883700fca1
commit
0045fb16b6
|
@ -1,26 +1,36 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
#include "BootloaderVersion.h"
|
#include "BootloaderVersion.h"
|
||||||
|
|
||||||
using namespace Pinetime;
|
using namespace Pinetime;
|
||||||
|
|
||||||
// NOTE : current bootloader does not export its version to the application firmware.
|
// NOTE : version < 1.0.0 of bootloader does not export its version to the application firmware.
|
||||||
|
|
||||||
uint32_t BootloaderVersion::Major() {
|
uint32_t BootloaderVersion::version = 0;
|
||||||
return 0;
|
char BootloaderVersion::versionString[BootloaderVersion::VERSION_STR_LEN] = "0.0.0";
|
||||||
|
|
||||||
|
const uint32_t BootloaderVersion::Major() {
|
||||||
|
return (BootloaderVersion::version >> 16u) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BootloaderVersion::Minor() {
|
const uint32_t BootloaderVersion::Minor() {
|
||||||
return 0;
|
return (BootloaderVersion::version >> 8u) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BootloaderVersion::Patch() {
|
const uint32_t BootloaderVersion::Patch() {
|
||||||
return 0;
|
return BootloaderVersion::version & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* BootloaderVersion::VersionString() {
|
const char* BootloaderVersion::VersionString() {
|
||||||
return "0.0.0";
|
return BootloaderVersion::versionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BootloaderVersion::IsValid() {
|
const bool BootloaderVersion::IsValid() {
|
||||||
return false;
|
return BootloaderVersion::version >= 0x00010000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BootloaderVersion::SetVersion(uint32_t v) {
|
||||||
|
BootloaderVersion::version = v;
|
||||||
|
snprintf(BootloaderVersion::versionString, BootloaderVersion::VERSION_STR_LEN, "%ld.%ld.%ld",
|
||||||
|
BootloaderVersion::Major(), BootloaderVersion::Minor(), BootloaderVersion::Patch());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,15 @@
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
class BootloaderVersion {
|
class BootloaderVersion {
|
||||||
public:
|
public:
|
||||||
static uint32_t Major();
|
static const uint32_t Major();
|
||||||
static uint32_t Minor();
|
static const uint32_t Minor();
|
||||||
static uint32_t Patch();
|
static const uint32_t Patch();
|
||||||
static const char* VersionString();
|
static const char* VersionString();
|
||||||
static bool IsValid();
|
static const bool IsValid();
|
||||||
|
static void SetVersion(uint32_t v);
|
||||||
|
private:
|
||||||
|
static uint32_t version;
|
||||||
|
static constexpr size_t VERSION_STR_LEN = 12;
|
||||||
|
static char versionString[VERSION_STR_LEN];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,11 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) {
|
||||||
NRF_LOG_INFO(
|
NRF_LOG_INFO(
|
||||||
"[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize);
|
"[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize);
|
||||||
|
|
||||||
|
// wait until SystemTask has finished waking up all devices
|
||||||
|
while (systemTask.IsSleeping()) {
|
||||||
|
vTaskDelay(50); // 50ms
|
||||||
|
}
|
||||||
|
|
||||||
dfuImage.Erase();
|
dfuImage.Erase();
|
||||||
|
|
||||||
uint8_t data[] {16, 1, 1};
|
uint8_t data[] {16, 1, 1};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../DisplayApp.h"
|
#include "../DisplayApp.h"
|
||||||
#include "Label.h"
|
#include "Label.h"
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
#include "BootloaderVersion.h"
|
||||||
#include "components/battery/BatteryController.h"
|
#include "components/battery/BatteryController.h"
|
||||||
#include "components/ble/BleController.h"
|
#include "components/ble/BleController.h"
|
||||||
#include "components/brightness/BrightnessController.h"
|
#include "components/brightness/BrightnessController.h"
|
||||||
|
@ -83,17 +84,19 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
|
||||||
lv_label_set_recolor(label, true);
|
lv_label_set_recolor(label, true);
|
||||||
lv_label_set_text_fmt(label,
|
lv_label_set_text_fmt(label,
|
||||||
"#FFFF00 InfiniTime#\n\n"
|
"#FFFF00 InfiniTime#\n\n"
|
||||||
"#444444 Version# %ld.%ld.%ld\n\n"
|
"#444444 Version# %ld.%ld.%ld\n"
|
||||||
"#444444 Short Ref# %s\n\n"
|
"#444444 Short Ref# %s\n"
|
||||||
"#444444 Build date#\n"
|
"#444444 Build date#\n"
|
||||||
"%s\n"
|
"%s\n"
|
||||||
"%s\n",
|
"%s\n\n"
|
||||||
|
"#444444 Bootloader# %s",
|
||||||
Version::Major(),
|
Version::Major(),
|
||||||
Version::Minor(),
|
Version::Minor(),
|
||||||
Version::Patch(),
|
Version::Patch(),
|
||||||
Version::GitCommitHash(),
|
Version::GitCommitHash(),
|
||||||
__DATE__,
|
__DATE__,
|
||||||
__TIME__);
|
__TIME__,
|
||||||
|
BootloaderVersion::VersionString());
|
||||||
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
|
||||||
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
|
||||||
return std::make_unique<Screens::Label>(0, 5, app, label);
|
return std::make_unique<Screens::Label>(0, 5, app, label);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <drivers/Hrs3300.h>
|
#include <drivers/Hrs3300.h>
|
||||||
#include <drivers/Bma421.h>
|
#include <drivers/Bma421.h>
|
||||||
|
|
||||||
|
#include "BootloaderVersion.h"
|
||||||
#include "components/battery/BatteryController.h"
|
#include "components/battery/BatteryController.h"
|
||||||
#include "components/ble/BleController.h"
|
#include "components/ble/BleController.h"
|
||||||
#include "components/ble/NotificationManager.h"
|
#include "components/ble/NotificationManager.h"
|
||||||
|
@ -306,6 +307,9 @@ int main(void) {
|
||||||
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
|
debounceTimer = xTimerCreate("debounceTimer", 200, pdFALSE, (void*) 0, DebounceTimerCallback);
|
||||||
debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
|
debounceChargeTimer = xTimerCreate("debounceTimerCharge", 200, pdFALSE, (void*) 0, DebounceTimerChargeCallback);
|
||||||
|
|
||||||
|
// retrieve version stored by bootloader
|
||||||
|
Pinetime::BootloaderVersion::SetVersion(NRF_TIMER2->CC[0]);
|
||||||
|
|
||||||
lvgl.Init();
|
lvgl.Init();
|
||||||
|
|
||||||
systemTask.Start();
|
systemTask.Start();
|
||||||
|
|
|
@ -73,6 +73,10 @@ namespace Pinetime {
|
||||||
return nimbleController;
|
return nimbleController;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool IsSleeping() const {
|
||||||
|
return isSleeping;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaskHandle_t taskHandle;
|
TaskHandle_t taskHandle;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user