Author: Jean-François Milants <jf@codingfield.com>
Display the SPI flash JEDEC IDs in SystemInformation. This is needed since a new memory chip will be used in future batches of PineTimes.
src/displayapp/DisplayApp.cpp | 7 +++++-- src/displayapp/DisplayApp.h | 4 +++- src/displayapp/DisplayAppRecovery.cpp | 3 ++- src/displayapp/DisplayAppRecovery.h | 4 +++- src/displayapp/screens/SystemInfo.cpp | 11 +++++++++-- src/displayapp/screens/SystemInfo.h | 4 +++- src/drivers/SpiNorFlash.cpp | 10 +++++++--- src/drivers/SpiNorFlash.h | 5 ++++- src/main.cpp | 3 ++-
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index f5a92117c25e682d8e51e44fd7f4f5a7927b965f..394a32393290adf97223b063f05ea0bb60cc1b3e 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -81,7 +81,8 @@ Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::TouchHandler& touchHandler, - Pinetime::Controllers::FS& filesystem) + Pinetime::Controllers::FS& filesystem, + Pinetime::Drivers::SpiNorFlash& spiNorFlash) : lcd {lcd}, touchPanel {touchPanel}, batteryController {batteryController}, @@ -97,6 +98,7 @@ alarmController {alarmController}, brightnessController {brightnessController}, touchHandler {touchHandler}, filesystem {filesystem}, + spiNorFlash {spiNorFlash}, lvgl {lcd, filesystem}, timer(this, TimerCallback), controllers {batteryController, @@ -601,7 +603,8 @@ brightnessController, bleController, watchdog, motionController, - touchPanel); + touchPanel, + spiNorFlash); break; case Apps::FlashLight: currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController); diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 356e490fe4f6e4cdf7ef261622e5a56018b8a827..d443b8b2170012fa67a25acaa8fa6681aed1f283 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -66,7 +66,8 @@ Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::TouchHandler& touchHandler, - Pinetime::Controllers::FS& filesystem); + Pinetime::Controllers::FS& filesystem, + Pinetime::Drivers::SpiNorFlash& spiNorFlash); void Start(System::BootErrors error); void PushMessage(Display::Messages msg); @@ -96,6 +97,7 @@ Pinetime::Controllers::AlarmController& alarmController; Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::TouchHandler& touchHandler; Pinetime::Controllers::FS& filesystem; + Pinetime::Drivers::SpiNorFlash& spiNorFlash; Pinetime::Controllers::FirmwareValidator validator; Pinetime::Components::LittleVgl lvgl; diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index 28892723703be5227afe278137159fff417565da..bcb8db0e9dabf0be0e574b7896c5cb51c548d4de 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -24,7 +24,8 @@ Pinetime::Controllers::MotionController& /*motionController*/, Pinetime::Controllers::AlarmController& /*alarmController*/, Pinetime::Controllers::BrightnessController& /*brightnessController*/, Pinetime::Controllers::TouchHandler& /*touchHandler*/, - Pinetime::Controllers::FS& /*filesystem*/) + Pinetime::Controllers::FS& /*filesystem*/, + Pinetime::Drivers::SpiNorFlash& /*spiNorFlash*/) : lcd {lcd}, bleController {bleController} { } diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index c1bf62430c493d1dbbfbc76fb460883e6ef9cd0e..162ff2575e0f596ff1dbe1dcb66371831b5e43eb 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -18,6 +18,7 @@ namespace Drivers { class St7789; class Cst816S; class Watchdog; + class SpiNorFlash; } namespace Controllers { @@ -59,7 +60,8 @@ Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::TouchHandler& touchHandler, - Pinetime::Controllers::FS& filesystem); + Pinetime::Controllers::FS& filesystem, + Pinetime::Drivers::SpiNorFlash& spiNorFlash); void Start(); void Start(Pinetime::System::BootErrors) { diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 18fb7ad2083446fd392a928c3e5e4965df051b7b..dd39f88ab07e6f8dc4445207de97e398c6391fc5 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -38,7 +38,8 @@ Pinetime::Controllers::BrightnessController& brightnessController, const Pinetime::Controllers::Ble& bleController, const Pinetime::Drivers::Watchdog& watchdog, Pinetime::Controllers::MotionController& motionController, - const Pinetime::Drivers::Cst816S& touchPanel) + const Pinetime::Drivers::Cst816S& touchPanel, + const Pinetime::Drivers::SpiNorFlash& spiNorFlash) : app {app}, dateTimeController {dateTimeController}, batteryController {batteryController}, @@ -47,6 +48,7 @@ bleController {bleController}, watchdog {watchdog}, motionController {motionController}, touchPanel {touchPanel}, + spiNorFlash {spiNorFlash}, screens {app, 0, {[this]() -> std::unique_ptr<Screen> { @@ -186,10 +188,12 @@ lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); const auto& bleAddr = bleController.Address(); + auto spiFlashId = spiNorFlash.GetIdentification(); lv_label_set_text_fmt(label, "#808080 BLE MAC#\n" - " %02x:%02x:%02x:%02x:%02x:%02x" + " %02x:%02x:%02x:%02x:%02x:%02x\n" "\n" + "#808080 SPI Flash# %02x-%02x-%02x\n" "\n" "#808080 Memory heap#\n" " #808080 Free# %d\n" @@ -202,6 +206,9 @@ bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0], + spiFlashId.manufacturer, + spiFlashId.type, + spiFlashId.density, xPortGetFreeHeapSize(), xPortGetMinimumEverFreeHeapSize(), mallocFailedCount, diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index 199af51e70a13e0bbbf195d6e6739430800f1748..3129c46320acd1288c3a496438c91ca2eae173b7 100644 --- a/src/displayapp/screens/SystemInfo.h +++ b/src/displayapp/screens/SystemInfo.h @@ -29,7 +29,8 @@ Pinetime::Controllers::BrightnessController& brightnessController, const Pinetime::Controllers::Ble& bleController, const Pinetime::Drivers::Watchdog& watchdog, Pinetime::Controllers::MotionController& motionController, - const Pinetime::Drivers::Cst816S& touchPanel); + const Pinetime::Drivers::Cst816S& touchPanel, + const Pinetime::Drivers::SpiNorFlash& spiNorFlash); ~SystemInfo() override; bool OnTouchEvent(TouchEvents event) override; @@ -42,6 +43,7 @@ const Pinetime::Controllers::Ble& bleController; const Pinetime::Drivers::Watchdog& watchdog; Pinetime::Controllers::MotionController& motionController; const Pinetime::Drivers::Cst816S& touchPanel; + const Pinetime::Drivers::SpiNorFlash& spiNorFlash; ScreenList<5> screens; diff --git a/src/drivers/SpiNorFlash.cpp b/src/drivers/SpiNorFlash.cpp index 56a8aabd9a674df646f3781ff869561a9bbe16b8..3bc45ccad2224a03e3aa8223448eea914a395b5b 100644 --- a/src/drivers/SpiNorFlash.cpp +++ b/src/drivers/SpiNorFlash.cpp @@ -10,7 +10,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} { } void SpiNorFlash::Init() { - device_id = ReadIdentificaion(); + device_id = ReadIdentification(); NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d", device_id.manufacturer, device_id.type, @@ -32,7 +32,7 @@ static constexpr uint8_t cmdSize = 4; uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03}; uint8_t id = 0; spi.Read(reinterpret_cast<uint8_t*>(&cmd), cmdSize, &id, 1); - auto devId = device_id = ReadIdentificaion(); + auto devId = device_id = ReadIdentification(); if (devId.type != device_id.type) { NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed"); } else { @@ -41,7 +41,7 @@ } NRF_LOG_INFO("[SpiNorFlash] Wakeup") } -SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() { +SpiNorFlash::Identification SpiNorFlash::ReadIdentification() { auto cmd = static_cast<uint8_t>(Commands::ReadIdentification); Identification identification; spi.Read(&cmd, 1, reinterpret_cast<uint8_t*>(&identification), sizeof(Identification)); @@ -145,3 +145,7 @@ b += toWrite; len -= toWrite; } } + +SpiNorFlash::Identification SpiNorFlash::GetIdentification() const { + return device_id; +} diff --git a/src/drivers/SpiNorFlash.h b/src/drivers/SpiNorFlash.h index 8a063fea73bbf0fe18917525f9672ad78d40476b..028f92b404e1cd169c40b98ecd1e23c98c7968b7 100644 --- a/src/drivers/SpiNorFlash.h +++ b/src/drivers/SpiNorFlash.h @@ -20,7 +20,6 @@ uint8_t type = 0; uint8_t density = 0; }; - Identification ReadIdentificaion(); uint8_t ReadStatusRegister(); bool WriteInProgress(); bool WriteEnabled(); @@ -33,6 +32,8 @@ uint8_t ReadSecurityRegister(); bool ProgramFailed(); bool EraseFailed(); + Identification GetIdentification() const; + void Init(); void Uninit(); @@ -40,6 +41,8 @@ void Sleep(); void Wakeup(); private: + Identification ReadIdentification(); + enum class Commands : uint8_t { PageProgram = 0x02, Read = 0x03, diff --git a/src/main.cpp b/src/main.cpp index ee6a6d3de5c600b8bab5ba846a30893d2edd0e0c..ab50fa74a2ccd387cbcf6ab28ee51666f2ce3cf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,7 +123,8 @@ motionController, alarmController, brightnessController, touchHandler, - fs); + fs, + spiNorFlash); Pinetime::System::SystemTask systemTask(spi, spiNorFlash,