I'm trying to determine the total RAM and ROM usage of my project, and I came across the memory_regions.scat file generated by Keil, which looks like this:
memory_regions.scat
/* generated memory regions file - do not edit */ #define RAM_START 0x22000000 #define RAM_LENGTH 0xE0000 #define FLASH_START 0x02000000 #define FLASH_LENGTH 0x1F8000 #define DATA_FLASH_START 0x27000000 #define DATA_FLASH_LENGTH 0x3000 #define OPTION_SETTING_START 0x0300A100 #define OPTION_SETTING_LENGTH 0x100 #define OPTION_SETTING_S_START 0x0300A200 #define OPTION_SETTING_S_LENGTH 0x100 #define OPTION_SETTING_DATA_FLASH_S_START 0x27030080 #define OPTION_SETTING_DATA_FLASH_S_LENGTH 0x800 #define ID_CODE_START 0x00000000 #define ID_CODE_LENGTH 0x0 #define SDRAM_START 0x68000000 #define SDRAM_LENGTH 0x8000000 #define QSPI_FLASH_START 0x60000000 #define QSPI_FLASH_LENGTH 0x0 #define OSPI_DEVICE_0_START 0x80000000 #define OSPI_DEVICE_0_LENGTH 0x10000000 #define OSPI_DEVICE_1_START 0x90000000 #define OSPI_DEVICE_1_LENGTH 0x10000000 #define ITCM_START 0x00000000 #define ITCM_LENGTH 0x10000 #define DTCM_START 0x20000000 #define DTCM_LENGTH 0x10000 #define NS_OFFSET_START 0x10000000 #define NS_OFFSET_LENGTH 0x0
I was wondering if I can use this to calculate the total RAM and ROM like this:
ROM / Flash = FLASH_LENGTH + DATA_FLASH_LENGTH = 0x1F8000 + 0x3000 = 0x1FB000 (approx. 2028 KB)
FLASH_LENGTH
DATA_FLASH_LENGTH
RAM = RAM_LENGTH + ITCM_LENGTH + DTCM_LENGTH = 0xE0000 + 0x10000 + 0x10000 = 0x100000 (1024 KB)
RAM_LENGTH
ITCM_LENGTH
DTCM_LENGTH
Is this approach valid? Also, it would be great if there's any documentation that explains which regions are used for ROM, RAM, etc., in the memory_regions.scat file.
Thanks in advance!
Look at how the regions are defined in the scatter file, which should enable you to read these off directly.
Very broadly speaking, LOAD region(s) equates to Flash - being where things reside at reset.
Non-root EXECUTION regions equate to RAM, being where things reside at main().
Scatterloading is thoroughly documented here:
https://developer.arm.com/documentation/101754/0624/armlink-Reference/Scatter-loading-Features