application: only show additional MCU info on DEBUG

This commit is contained in:
King Kévin 2020-06-10 18:02:53 +02:00
parent 9f419e1da0
commit b48c65b5e0
1 changed files with 18 additions and 14 deletions

View File

@ -192,10 +192,22 @@ static void command_help(void* argument)
static void command_version(void* argument)
{
(void)argument; // we won't use the argument
bool fake = false; // if details indicate it's not an STM32
printf("firmware date: %04u-%02u-%02u\n", BUILD_YEAR, BUILD_MONTH, BUILD_DAY); // show firmware build date
puts("chip family: ");
// show flash size
puts("flash size: ");
if (0xffff == DESIG_FLASH_SIZE) {
puts("unknown (probably a defective micro-controller\n");
} else {
printf("%u KB\n", DESIG_FLASH_SIZE);
}
const uint16_t dev_id = DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK;
const uint16_t rev_id = DBGMCU_IDCODE >> 16;
printf("MCUID: DEV_ID=0x%03x REV_ID=0x%04x\n", dev_id, rev_id);
// display device identity
printf("device id: %08x%08x%04x%04x\n", DESIG_UNIQUE_ID2, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID0 & 0xffff, DESIG_UNIQUE_ID0 >> 16);
#if DEBUG
bool fake = false; // if details indicate it's not an STM32
puts("chip family: ");
switch (dev_id) {
case 0: // DBGMCU_IDCODE is only accessible in debug mode (this is a known issue documented in STM32F10xxC/D/E Errata sheet, without workaround)
puts("not readable, retry with debug attached");
@ -262,9 +274,8 @@ static void command_version(void* argument)
fake = true;
break;
}
printf(" (DEV_ID=0x%03x)\n", dev_id);
putc('\n');
puts("chip revision: ");
const uint16_t rev_id = DBGMCU_IDCODE >> 16;
switch (DBGMCU_IDCODE & DBGMCU_IDCODE_DEV_ID_MASK) {
case 0x412:
if (0x1000 == rev_id) {
@ -317,17 +328,9 @@ static void command_version(void* argument)
printf("unknown");
break;
}
printf(" (REV_ID=0x%04x)\n", rev_id);
// show flash size
puts("flash size: ");
if (0xffff == DESIG_FLASH_SIZE) {
puts("unknown (probably a defective micro-controller\n");
} else {
printf("%u KB\n", DESIG_FLASH_SIZE);
}
// display device identity
printf("device id: %08x%08x%04x%04x\n", DESIG_UNIQUE_ID2, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID0 & 0xffff, DESIG_UNIQUE_ID0 >> 16);
putc('\n');
// from RM0091 STM32F0x8 reference manual (not sure if it applies to F1)
puts("manufacturing information:\n");
printf("- X,Y wafer coordinate: %08x\n", DESIG_UNIQUE_ID0);
printf("- lot number: %c%c%c%c%c%c%c\n", DESIG_UNIQUE_ID2 >> 24, DESIG_UNIQUE_ID2 >> 16, DESIG_UNIQUE_ID2 >> 8, DESIG_UNIQUE_ID2 >> 0, DESIG_UNIQUE_ID1 >> 24, DESIG_UNIQUE_ID1 >> 16, DESIG_UNIQUE_ID1 >> 8);
printf("- wafer number: %u\n", DESIG_UNIQUE_ID1 & 0xff);
@ -421,6 +424,7 @@ static void command_version(void* argument)
}
}
printf("this %s to be a genuine STM32\n", fake ? "does not seem" : "seems");
#endif
}
static void command_uptime(void* argument)