mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Display FLASH JEDEC ID in status and flash_info (#12051)
This commit is contained in:
parent
103f238eea
commit
bcfe335bd7
3 changed files with 30 additions and 11 deletions
|
@ -2456,8 +2456,8 @@ static void cliFlashInfo(const char *cmdName, char *cmdline)
|
||||||
|
|
||||||
const flashGeometry_t *layout = flashGetGeometry();
|
const flashGeometry_t *layout = flashGetGeometry();
|
||||||
|
|
||||||
cliPrintLinef("Flash sectors=%u, sectorSize=%u, pagesPerSector=%u, pageSize=%u, totalSize=%u",
|
cliPrintLinef("Flash sectors=%u, sectorSize=%u, pagesPerSector=%u, pageSize=%u, totalSize=%u JEDEC ID=0x%08x",
|
||||||
layout->sectors, layout->sectorSize, layout->pagesPerSector, layout->pageSize, layout->totalSize);
|
layout->sectors, layout->sectorSize, layout->pagesPerSector, layout->pageSize, layout->totalSize, layout->jedecId);
|
||||||
|
|
||||||
for (uint8_t index = 0; index < FLASH_MAX_PARTITIONS; index++) {
|
for (uint8_t index = 0; index < FLASH_MAX_PARTITIONS; index++) {
|
||||||
const flashPartition_t *partition;
|
const flashPartition_t *partition;
|
||||||
|
@ -4854,6 +4854,13 @@ static void cliStatus(const char *cmdName, char *cmdline)
|
||||||
cliSdInfo(cmdName, "");
|
cliSdInfo(cmdName, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_FLASH_CHIP
|
||||||
|
const flashGeometry_t *layout = flashGetGeometry();
|
||||||
|
if (layout->jedecId != 0) {
|
||||||
|
cliPrintLinef("FLASH: JEDEC ID=0x%08x %uM", layout->jedecId, layout->totalSize >> 20);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
cliPrint("Arming disable flags:");
|
cliPrint("Arming disable flags:");
|
||||||
armingDisableFlags_e flags = getArmingDisableFlags();
|
armingDisableFlags_e flags = getArmingDisableFlags();
|
||||||
while (flags) {
|
while (flags) {
|
||||||
|
|
|
@ -121,6 +121,9 @@ static bool flashQuadSpiInit(const flashConfig_t *flashConfig)
|
||||||
phase++;
|
phase++;
|
||||||
} while (phase != BAIL && !detected);
|
} while (phase != BAIL && !detected);
|
||||||
|
|
||||||
|
if (detected) {
|
||||||
|
flashDevice.geometry.jedecId = chipID;
|
||||||
|
}
|
||||||
return detected;
|
return detected;
|
||||||
}
|
}
|
||||||
#endif // USE_QUADSPI
|
#endif // USE_QUADSPI
|
||||||
|
@ -134,6 +137,7 @@ void flashPreInit(const flashConfig_t *flashConfig)
|
||||||
|
|
||||||
static bool flashSpiInit(const flashConfig_t *flashConfig)
|
static bool flashSpiInit(const flashConfig_t *flashConfig)
|
||||||
{
|
{
|
||||||
|
bool detected = false;
|
||||||
// Read chip identification and send it to device detect
|
// Read chip identification and send it to device detect
|
||||||
dev = &devInstance;
|
dev = &devInstance;
|
||||||
|
|
||||||
|
@ -179,31 +183,38 @@ static bool flashSpiInit(const flashConfig_t *flashConfig)
|
||||||
|
|
||||||
#ifdef USE_FLASH_M25P16
|
#ifdef USE_FLASH_M25P16
|
||||||
if (m25p16_detect(&flashDevice, chipID)) {
|
if (m25p16_detect(&flashDevice, chipID)) {
|
||||||
return true;
|
detected = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_FLASH_W25M512) || defined(USE_FLASH_W25M)
|
#if defined(USE_FLASH_W25M512) || defined(USE_FLASH_W25M)
|
||||||
if (w25m_detect(&flashDevice, chipID)) {
|
if (!detected && w25m_detect(&flashDevice, chipID)) {
|
||||||
return true;
|
detected = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Newer chips
|
if (!detected) {
|
||||||
chipID = (readIdResponse[1] << 16) | (readIdResponse[2] << 8) | (readIdResponse[3]);
|
// Newer chips
|
||||||
|
chipID = (readIdResponse[1] << 16) | (readIdResponse[2] << 8) | (readIdResponse[3]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_FLASH_W25N01G
|
#ifdef USE_FLASH_W25N01G
|
||||||
if (w25n01g_detect(&flashDevice, chipID)) {
|
if (!detected && w25n01g_detect(&flashDevice, chipID)) {
|
||||||
return true;
|
detected = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_FLASH_W25M02G
|
#ifdef USE_FLASH_W25M02G
|
||||||
if (w25m_detect(&flashDevice, chipID)) {
|
if (!detected && w25m_detect(&flashDevice, chipID)) {
|
||||||
return true;
|
detected = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (detected) {
|
||||||
|
flashDevice.geometry.jedecId = chipID;
|
||||||
|
return detected;
|
||||||
|
}
|
||||||
|
|
||||||
spiPreinitByTag(flashConfig->csTag);
|
spiPreinitByTag(flashConfig->csTag);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -45,6 +45,7 @@ typedef struct flashGeometry_s {
|
||||||
uint32_t totalSize; // This is just sectorSize * sectors
|
uint32_t totalSize; // This is just sectorSize * sectors
|
||||||
uint16_t pagesPerSector;
|
uint16_t pagesPerSector;
|
||||||
flashType_e flashType;
|
flashType_e flashType;
|
||||||
|
uint32_t jedecId;
|
||||||
} flashGeometry_t;
|
} flashGeometry_t;
|
||||||
|
|
||||||
void flashPreInit(const flashConfig_t *flashConfig);
|
void flashPreInit(const flashConfig_t *flashConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue