Hi Ma Hui,
Thank you for help!
I have to use a processor without FlexNVM for quite long time. For now, I need to divide internal NOR flash to program space and data space. I only need two 4 KB data space. They should not be in same sector. EEPROM seems not an option for me since my application will change data space content at run time. For now I have to limit my program and data space to be within 512 KB NOR flash. There is a post in another thread mentioned that FLASHX_FILE_BLOCK may need to be modified. The post is at: Re: Which flash regions can I access with flashx?
The current MQX FLASHX_FILE_BLOCK is defined as (I use TWRK60F120M demo, I will move to our PCB which has a K60 with 512 KB internal NOR flash):
const FLASHX_FILE_BLOCK _bsp_flashx_file_blocks[] = {
{ "bank0", BSP_INTERNAL_FLASH_BASE , BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank1", BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank2", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank3", BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 4 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "" , (uint_32) __FLASHX_START_ADDR, (uint_32) __FLASHX_END_ADDR },
{ NULL , 0, 0 }
};
I don't need bank2 and bank3, I can keep current bank0, but divide bank1 into bank1a, bank1b and bank1c. The bank1a will start at same address as before, but it will end its boundary 0x2000 earlier. bank1b and bank1c will occupy the last 0x2000 space, each of them has 0x1000 space:
const FLASHX_FILE_BLOCK _bsp_flashx_file_blocks[] = {
{ "bank0", BSP_INTERNAL_FLASH_BASE , BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank1a", BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x2000 - 1 },
{ "bank1b", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x2000, BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x1000 - 1 },
{ "bank1c", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x1000, BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank2", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "bank3", BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 4 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },
{ "" , (uint_32) __FLASHX_START_ADDR, (uint_32) __FLASHX_END_ADDR },
{ NULL , 0, 0 }
};
Do you think above definition will work?
I have also studied flash_demo.c. I believe the following #define is generated when the project is created:
#if (BSP_M51EMDEMO || BSP_TWRMCF51MM || BSP_TWRMCF51JE)
#if !BSPCFG_ENABLE_FLASHX2
#error This application requires BSPCFG_ENABLE_FLASHX1 defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
#define FLASH_NAME "flashx2:bank1"
#elif BSP_M54455EVB
#if !BSPCFG_ENABLE_FLASHX0
#error This application requires BSPCFG_ENABLE_FLASHX0 defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
#define FLASH_NAME "flashx0:bank0"
#else
#if !BSPCFG_ENABLE_FLASHX
#error This application requires BSPCFG_ENABLE_FLASHX defined non-zero in user_config.h. Please recompile BSP with this option.
#endif
#define FLASH_NAME "flashx:bank0"
#endif
How to create a project with above #define? Could I do my own #define?
Thank you!
Lisa