diff --git a/application.c b/application.c index d99d274..499ec8b 100644 --- a/application.c +++ b/application.c @@ -193,16 +193,34 @@ static void command_version(void* argument) { (void)argument; // we won't use the argument printf("firmware date: %04u-%02u-%02u\n", BUILD_YEAR, BUILD_MONTH, BUILD_DAY); // show firmware build date - // get device identifier (DEV_ID) - // 0x412: low-density, 16-32 kB flash - // 0x410: medium-density, 64-128 kB flash - // 0x414: high-density, 256-512 kB flash - // 0x430: XL-density, 768-1024 kB flash - // 0x418: connectivity puts("device family: "); switch (DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK) { - case 0: // this is a known issue document in STM32F10xxC/D/E Errata sheet, without workaround - puts("unreadable\n"); + case 0: // DBGMCU_IDCODE is only accessible in debug mode (this is a known issue documented in STM32F10xxC/D/E Errata sheet, without workaround) + if ((*(uint32_t*)0x1FFFF000 & 0xFFFE0000) == 0x20000000) { // non-connectivity system memory start detected (MSP address pointing to SRAM + switch (DESIG_FLASH_SIZE) { + case 16: + case 32: + puts("low-density\n"); + break; + case 64: + case 128: + puts("medium-density\n"); + break; + case 256: + case 512: + puts("high-density\n"); + break; + case 768: + case 1024: + puts("XL-density\n"); + break; + default: + printf("unknown\n"); + break; + } + } else { // connectivity system memory start is at 0x1FFFB000 + puts("connectivity\n"); + } break; case 0x412: puts("low-density\n"); @@ -220,7 +238,7 @@ static void command_version(void* argument) puts("connectivity\n"); break; default: - puts("unknown\n"); + printf("unknown (0x%04x)\n", DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK); break; } // show flash size