Hi Bugs,
Let me try to explain what I've done with a MCF52259 project and FLASHX.
The linker file defines the memory map with:
___INTERNAL_SRAM_BASE = 0x20000000;
___INTERNAL_SRAM_SIZE = 0x00010000;
___INTERNAL_FLASH_BASE = 0x00000000;
___INTERNAL_FLASH_SIZE = 0x00080000;
___EXTERNAL_MRAM_BASE = 0x10000000;
___EXTERNAL_MRAM_SIZE = 0x00080000;
___EXTERNAL_MRAM_ROM_BASE = 0x10000000;
___EXTERNAL_MRAM_ROM_SIZE = 0x00000000;
___EXTERNAL_MRAM_RAM_BASE = 0x10000000;
___EXTERNAL_MRAM_RAM_SIZE = 0x00080000;
Then later in the linker file the size of the flash we want to control using FLASHX gets defined with:
___FLASHX_START_ADDR = 0x14000;
___FLASHX_END_ADDR = ___INTERNAL_FLASH_BASE + ___INTERNAL_FLASH_SIZE;
___FLASHX_SECT_SIZE = 0x1000;
In the processor bsp header file m52259evb.h there is a default BSPCFG_FLASHX_SIZE. To over ride this in the user_config.h I add:
#define BSPCFG_FLASHX_SIZE 0x6C000 //DES 0x80000 - 0x14000(BootloaderFromUSBStick size) = 0x6C000
#define BSPCFG_ENABLE_FLASHX 1
So the BSPCFG_FLASHX_SIZE is the size of the remaining internal flash above the 0x14000 address. In my application I have a bootloader using 0x0 thru 0x14000.
The bsp loads the flashx drive in init_bsp.c with:
/* install internal flash */
#if BSPCFG_ENABLE_FLASHX
_mcf5225_internal_flash_install("flashx:", BSPCFG_FLASHX_SIZE);
#endif
The flash_mcf5225.h grabs the linker variables and pulls them into the RTOS source code:
#define FLASHX_START_ADDR ((uint_32)__FLASHX_START_ADDR)
#define FLASHX_END_ADDR ((uint_32)__FLASHX_END_ADDR)
#define FLASHX_SECT_SIZE ((uint_32)__FLASHX_SECT_SIZE)
flash_mcf52xx.c has the _mcf5225_internal_flash_install() function that initializes the flashx structure.
Interesting part here is that when you open the flashx device to use it from your application code space:
flash = fopen("flashx:",0); //DES open the flash driver
then the instead of accessing flash starting at 0x14000 thru 0x80000, you access it from 0x0 thru 0x6c000. This was the confusing part for me BTW.
I do believe we could simplify this in the future.
Hope this helps.
Regards,
David