I am using the LPCXpresso IDE with its SDK about this processor. I know that the maximum size of a sketch is 30kB, but it's Flash is 32k, so there are at least 2k user memory. But in case our sketch is 20k, can we use these 10k, that are provided for the rom memory of the software? I am using the include storage module.
Thank you in advance.
The Flash is indeed 32K, of which the top two sectors (2K) is flashed and locked during production. The bootloader resides there, and the IAP command implementations. It is RO and cannot be altered.
Your program starts at the lowest sector 0, and can fill up to 30K. All flash memory that is not used, can be used for data storage. In your case, with a program pf 20K, you have 10K in FLASH for data storage, and 58 pages of EEPROM data (a little over 3.5K). Since the cost of writing data to FLASH is high, we created the storage module, that does all bit-shifting for you (so all bits are used for data storage), and makes sure that both EEPROM and FLASH memory are used optimally. In addition, it provides hooks so you can implement compression on the data.
The storage module can be tweaked by using diversity settings, which are just defines placed in your applications' app_sel.h. By default, it will use 1K of EEPROM data and all available space in FLASH not used by the bootloader or your program. You can check which tweaks are available by reading <SDK>/docs/firmware.html > Documentation of the high-level abstraction modules > storage: NVM Storage module > Diversity Settings.