Display the SPI flash JEDEC IDs in SystemInformation.

This is needed since a new memory chip will be used in future batches of PineTimes.
This commit is contained in:
Jean-François Milants 2024-07-23 19:27:19 +02:00 committed by JF
parent 53dc9dafe7
commit 3a0d673df4
9 changed files with 38 additions and 13 deletions

View File

@ -81,7 +81,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::AlarmController& alarmController,
Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::TouchHandler& touchHandler,
Pinetime::Controllers::FS& filesystem) Pinetime::Controllers::FS& filesystem,
Pinetime::Drivers::SpiNorFlash& spiNorFlash)
: lcd {lcd}, : lcd {lcd},
touchPanel {touchPanel}, touchPanel {touchPanel},
batteryController {batteryController}, batteryController {batteryController},
@ -97,6 +98,7 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
brightnessController {brightnessController}, brightnessController {brightnessController},
touchHandler {touchHandler}, touchHandler {touchHandler},
filesystem {filesystem}, filesystem {filesystem},
spiNorFlash {spiNorFlash},
lvgl {lcd, filesystem}, lvgl {lcd, filesystem},
timer(this, TimerCallback), timer(this, TimerCallback),
controllers {batteryController, controllers {batteryController,
@ -601,7 +603,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
bleController, bleController,
watchdog, watchdog,
motionController, motionController,
touchPanel); touchPanel,
spiNorFlash);
break; break;
case Apps::FlashLight: case Apps::FlashLight:
currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController); currentScreen = std::make_unique<Screens::FlashLight>(*systemTask, brightnessController);

View File

@ -66,7 +66,8 @@ namespace Pinetime {
Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::AlarmController& alarmController,
Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::TouchHandler& touchHandler,
Pinetime::Controllers::FS& filesystem); Pinetime::Controllers::FS& filesystem,
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
void Start(System::BootErrors error); void Start(System::BootErrors error);
void PushMessage(Display::Messages msg); void PushMessage(Display::Messages msg);
@ -96,6 +97,7 @@ namespace Pinetime {
Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::BrightnessController& brightnessController;
Pinetime::Controllers::TouchHandler& touchHandler; Pinetime::Controllers::TouchHandler& touchHandler;
Pinetime::Controllers::FS& filesystem; Pinetime::Controllers::FS& filesystem;
Pinetime::Drivers::SpiNorFlash& spiNorFlash;
Pinetime::Controllers::FirmwareValidator validator; Pinetime::Controllers::FirmwareValidator validator;
Pinetime::Components::LittleVgl lvgl; Pinetime::Components::LittleVgl lvgl;

View File

@ -24,7 +24,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::AlarmController& /*alarmController*/, Pinetime::Controllers::AlarmController& /*alarmController*/,
Pinetime::Controllers::BrightnessController& /*brightnessController*/, Pinetime::Controllers::BrightnessController& /*brightnessController*/,
Pinetime::Controllers::TouchHandler& /*touchHandler*/, Pinetime::Controllers::TouchHandler& /*touchHandler*/,
Pinetime::Controllers::FS& /*filesystem*/) Pinetime::Controllers::FS& /*filesystem*/,
Pinetime::Drivers::SpiNorFlash& /*spiNorFlash*/)
: lcd {lcd}, bleController {bleController} { : lcd {lcd}, bleController {bleController} {
} }

View File

@ -18,6 +18,7 @@ namespace Pinetime {
class St7789; class St7789;
class Cst816S; class Cst816S;
class Watchdog; class Watchdog;
class SpiNorFlash;
} }
namespace Controllers { namespace Controllers {
@ -59,7 +60,8 @@ namespace Pinetime {
Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::AlarmController& alarmController,
Pinetime::Controllers::BrightnessController& brightnessController, Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::TouchHandler& touchHandler, Pinetime::Controllers::TouchHandler& touchHandler,
Pinetime::Controllers::FS& filesystem); Pinetime::Controllers::FS& filesystem,
Pinetime::Drivers::SpiNorFlash& spiNorFlash);
void Start(); void Start();
void Start(Pinetime::System::BootErrors) { void Start(Pinetime::System::BootErrors) {

View File

@ -38,7 +38,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
const Pinetime::Controllers::Ble& bleController, const Pinetime::Controllers::Ble& bleController,
const Pinetime::Drivers::Watchdog& watchdog, const Pinetime::Drivers::Watchdog& watchdog,
Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::MotionController& motionController,
const Pinetime::Drivers::Cst816S& touchPanel) const Pinetime::Drivers::Cst816S& touchPanel,
const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
: app {app}, : app {app},
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
batteryController {batteryController}, batteryController {batteryController},
@ -47,6 +48,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
watchdog {watchdog}, watchdog {watchdog},
motionController {motionController}, motionController {motionController},
touchPanel {touchPanel}, touchPanel {touchPanel},
spiNorFlash {spiNorFlash},
screens {app, screens {app,
0, 0,
{[this]() -> std::unique_ptr<Screen> { {[this]() -> std::unique_ptr<Screen> {
@ -186,10 +188,12 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label, true); lv_label_set_recolor(label, true);
const auto& bleAddr = bleController.Address(); const auto& bleAddr = bleController.Address();
auto spiFlashId = spiNorFlash.GetIdentification();
lv_label_set_text_fmt(label, lv_label_set_text_fmt(label,
"#808080 BLE MAC#\n" "#808080 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x" " %02x:%02x:%02x:%02x:%02x:%02x\n"
"\n" "\n"
"#808080 SPI Flash# %02x-%02x-%02x\n"
"\n" "\n"
"#808080 Memory heap#\n" "#808080 Memory heap#\n"
" #808080 Free# %d\n" " #808080 Free# %d\n"
@ -202,6 +206,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
bleAddr[2], bleAddr[2],
bleAddr[1], bleAddr[1],
bleAddr[0], bleAddr[0],
spiFlashId.manufacturer,
spiFlashId.type,
spiFlashId.density,
xPortGetFreeHeapSize(), xPortGetFreeHeapSize(),
xPortGetMinimumEverFreeHeapSize(), xPortGetMinimumEverFreeHeapSize(),
mallocFailedCount, mallocFailedCount,

View File

@ -29,7 +29,8 @@ namespace Pinetime {
const Pinetime::Controllers::Ble& bleController, const Pinetime::Controllers::Ble& bleController,
const Pinetime::Drivers::Watchdog& watchdog, const Pinetime::Drivers::Watchdog& watchdog,
Pinetime::Controllers::MotionController& motionController, Pinetime::Controllers::MotionController& motionController,
const Pinetime::Drivers::Cst816S& touchPanel); const Pinetime::Drivers::Cst816S& touchPanel,
const Pinetime::Drivers::SpiNorFlash& spiNorFlash);
~SystemInfo() override; ~SystemInfo() override;
bool OnTouchEvent(TouchEvents event) override; bool OnTouchEvent(TouchEvents event) override;
@ -42,6 +43,7 @@ namespace Pinetime {
const Pinetime::Drivers::Watchdog& watchdog; const Pinetime::Drivers::Watchdog& watchdog;
Pinetime::Controllers::MotionController& motionController; Pinetime::Controllers::MotionController& motionController;
const Pinetime::Drivers::Cst816S& touchPanel; const Pinetime::Drivers::Cst816S& touchPanel;
const Pinetime::Drivers::SpiNorFlash& spiNorFlash;
ScreenList<5> screens; ScreenList<5> screens;

View File

@ -10,7 +10,7 @@ SpiNorFlash::SpiNorFlash(Spi& spi) : spi {spi} {
} }
void SpiNorFlash::Init() { void SpiNorFlash::Init() {
device_id = ReadIdentificaion(); device_id = ReadIdentification();
NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d", NRF_LOG_INFO("[SpiNorFlash] Manufacturer : %d, Memory type : %d, memory density : %d",
device_id.manufacturer, device_id.manufacturer,
device_id.type, device_id.type,
@ -32,7 +32,7 @@ void SpiNorFlash::Wakeup() {
uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03}; uint8_t cmd[cmdSize] = {static_cast<uint8_t>(Commands::ReleaseFromDeepPowerDown), 0x01, 0x02, 0x03};
uint8_t id = 0; uint8_t id = 0;
spi.Read(reinterpret_cast<uint8_t*>(&cmd), cmdSize, &id, 1); 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) { if (devId.type != device_id.type) {
NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed"); NRF_LOG_INFO("[SpiNorFlash] ID on Wakeup: Failed");
} else { } else {
@ -41,7 +41,7 @@ void SpiNorFlash::Wakeup() {
NRF_LOG_INFO("[SpiNorFlash] Wakeup") NRF_LOG_INFO("[SpiNorFlash] Wakeup")
} }
SpiNorFlash::Identification SpiNorFlash::ReadIdentificaion() { SpiNorFlash::Identification SpiNorFlash::ReadIdentification() {
auto cmd = static_cast<uint8_t>(Commands::ReadIdentification); auto cmd = static_cast<uint8_t>(Commands::ReadIdentification);
Identification identification; Identification identification;
spi.Read(&cmd, 1, reinterpret_cast<uint8_t*>(&identification), sizeof(Identification)); spi.Read(&cmd, 1, reinterpret_cast<uint8_t*>(&identification), sizeof(Identification));
@ -145,3 +145,7 @@ void SpiNorFlash::Write(uint32_t address, const uint8_t* buffer, size_t size) {
len -= toWrite; len -= toWrite;
} }
} }
SpiNorFlash::Identification SpiNorFlash::GetIdentification() const {
return device_id;
}

View File

@ -20,7 +20,6 @@ namespace Pinetime {
uint8_t density = 0; uint8_t density = 0;
}; };
Identification ReadIdentificaion();
uint8_t ReadStatusRegister(); uint8_t ReadStatusRegister();
bool WriteInProgress(); bool WriteInProgress();
bool WriteEnabled(); bool WriteEnabled();
@ -33,6 +32,8 @@ namespace Pinetime {
bool ProgramFailed(); bool ProgramFailed();
bool EraseFailed(); bool EraseFailed();
Identification GetIdentification() const;
void Init(); void Init();
void Uninit(); void Uninit();
@ -40,6 +41,8 @@ namespace Pinetime {
void Wakeup(); void Wakeup();
private: private:
Identification ReadIdentification();
enum class Commands : uint8_t { enum class Commands : uint8_t {
PageProgram = 0x02, PageProgram = 0x02,
Read = 0x03, Read = 0x03,

View File

@ -123,7 +123,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
alarmController, alarmController,
brightnessController, brightnessController,
touchHandler, touchHandler,
fs); fs,
spiNorFlash);
Pinetime::System::SystemTask systemTask(spi, Pinetime::System::SystemTask systemTask(spi,
spiNorFlash, spiNorFlash,