AT32: say RAM size

This commit is contained in:
Andrey Gusakov 2023-11-03 19:10:24 +03:00 committed by rusefillc
parent 0bc66e8273
commit bb161be8e8
3 changed files with 30 additions and 0 deletions

View File

@ -94,6 +94,7 @@ static void sayHello() {
(mcuSerId == 0x0d) ? "AT32F435" : ((mcuSerId == 0x0e) ? "AT32F437" : "UNKNOWN"),
'A' + mcuRevision);
efiPrintf("MCU F_SIZE %d KB", flashSize);
efiPrintf("MCU RAM %d KB", at32GetRamSizeKb());
#else
#define MCU_REVISION_MASK 0xfff
int mcuRevision = DBGMCU->IDCODE & MCU_REVISION_MASK;

View File

@ -65,3 +65,31 @@ int at32GetMcuType(uint32_t id, const char **pn, const char **package, uint32_t
/* unknown */
return -1;
}
int at32GetRamSizeKb(void)
{
uint8_t EOPB0 = *(__IO uint16_t *) (0x1FFFC010);
/* TODO: check inverted value */
switch ((*(__IO uint16_t *) (FLASHSIZE_BASE))) {
case 256:
EOPB0 &= 0x03;
if (EOPB0 == 3)
EOPB0 = 2;
return 512 - (64 * EOPB0);
case 448:
EOPB0 &= 0x07;
if (EOPB0 > 5)
EOPB0 = 5;
return 512 - (64 * EOPB0);
case 1024:
case 4032:
EOPB0 &= 0x07;
if (EOPB0 > 6)
EOPB0 = 6;
return 512 - (64 * EOPB0);
default:
return 0;
}
return 0;
}

View File

@ -78,6 +78,7 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue);
#ifdef AT32F4XX
int at32GetMcuType(uint32_t id, const char **pn, const char **package, uint32_t *flashSize);
int at32GetRamSizeKb(void);
#endif
extern "C"