Hello ,
I am working with k70 micro-controller. How can I relocate a specific code in user define memory location in ROM. I read the application note for linker command file but not getting exactly how to edit .lcf file for creating a memory segment and use it for specific function/code. I need help regarding this.Thank you.
Regards,
Amey Bhopi
hi Amey,
do you use Codewarrior or KDS? if Codewarrior, do you use FSL ARM compiler or GCC compiler?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Amey,
you use CW FSL ARM compiler, please refer this document for lcf configuration:
http://cache.freescale.com/files/soft_dev_tools/doc/app_note/AN4498.pdf
can this help?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Zhang, I have read about "interrupt vector redirection method in Kinetis" which you have posted on community and its very useful.. I am working on k70 with mqx. I am not able to find kinetis_sysinit.c in my project (might be because its not a bareboard project). It would be really helpful for me if you explain where to configure VTOR register in order to relocate vector table. I have copied .lcf file below for your reference. Thank you.
MEMORY
{
vectorrom (RX): ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (R): ORIGIN = 0x00000400, LENGTH = 0x00000020
rom (RX): ORIGIN = 0x00003000, LENGTH = 0x000FD000 # Code + Const data
ram (RW): ORIGIN = 0x70000000, LENGTH = 0x08000000 # DDR2 - RW data
# heap (RW): ORIGIN = 0x73000000, LENGTH = 0x05000000
sram (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x00020000 # SRAM - RW data
# kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)
#end_of_kd (RW): ORIGIN = 0x77FFFFF0, LENGTH = 0x00000000
end_of_kd (RW): ORIGIN = 0x77FFFFF0, LENGTH = 0x00000000
end_of_heap (RW): ORIGIN = 0x77FFFFF0, LENGTH=0x00000000
# Boot stack reused by MQX Kernel data
bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 # Boot stack
end_bstack (RW): ORIGIN = 0x2000FC00, LENGTH = 0x00000000
}
KEEP_SECTION { .vectors_rom, .vectors_ram, .cfmconfig }
SECTIONS
{
__INTERNAL_SRAM_BASE = 0x1FFF0000;
__INTERNAL_SRAM_SIZE = 0x00020000;
__INTERNAL_FLASH_BASE = 0x00000000;
__INTERNAL_FLASH_SIZE = 0x00100000;
__INTERNAL_FLEXNVM_BASE = 0;
__INTERNAL_FLEXNVM_SIZE = 0;
__UNCACHED_DATA_END = 0x2000FFF0;
__EXTERNAL_MRAM_BASE = 0x60000000;
__EXTERNAL_MRAM_SIZE = 0x00080000;
__EXTERNAL_MRAM_ROM_BASE = 0x60000000;
__EXTERNAL_MRAM_ROM_SIZE = 0x00000000;
__EXTERNAL_MRAM_RAM_BASE = 0x60000000;
__EXTERNAL_MRAM_RAM_SIZE = 0x00080000;
__EXTERNAL_DDR2_RAM_BASE = 0x70000000;
__EXTERNAL_DDR2_RAM_SIZE = 0x08000000;
# __heap_addr = 0x73000000;
# __heap_size = 0x05000000;
__EXTERNAL_LCD_BASE = 0x60000000;
__EXTERNAL_LCD_SIZE = 0x1FFFF;
__EXTERNAL_LCD_DC_BASE = 0x60010000;
# MQX link time configurations
__DEFAULT_PROCESSOR_NUMBER = 1;
# __DEFAULT_INTERRUPT_STACK_SIZE = 1024;
__DEFAULT_INTERRUPT_STACK_SIZE = 4096;
__KERNEL_DATA_VERIFY_ENABLE = 0; # Test SDRAM read/write
# Flashx configurations
__FLASHX_SECT_SIZE = 0x1000;
.vectors :
{
__VECTOR_TABLE_ROM_START = .; # Runtime vector table in sram
*(.vectors_rom)
. = ALIGN (0x4);
} > vectorrom
.cfmprotect :
{
*(.cfmconfig)
. = ALIGN (0x4);
} > cfmprotrom
.main_application :
{
*(KERNEL)
*(S_BOOT)
*(IPSUM)
*(.text)
*(.init)
*(.fini)
*(.eini)
*(.ctors)
*(.dtors)
. = ALIGN(0x4);
*(.rodata)
. = ALIGN(0x4);
*(.rdata)
. = ALIGN(0x4);
*(.exception)
. = ALIGN(0x4);
__exception_table_start__ = .;
EXCEPTION
__exception_table_end__ = .;
__sinit__ = .;
STATICINIT
. = ALIGN(0x4);
__COPY_OF_DATA = .;
} > rom
.main_application_data : AT(__COPY_OF_DATA)
{
. = ALIGN(128);
__VECTOR_TABLE_RAM_START = .; # Runtime vector table in sram
*(.vectors_ram)
__START_DATA = .;
*(.data)
__END_DATA = .;
. = ALIGN(0x4);
__START_SDATA = .;
*(.sdata)
__END_SDATA = .;
. = ALIGN(0x4);
__SDA_BASE = .;
__SDA_BASE_ = __SDA_BASE;
. = ALIGN(16);
} > ram
.main_application_bss :
{
. = ALIGN(0x10);
__START_SBSS = .;
*(.sbss)
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
*(.bss)
*(COMMON)
__END_BSS = .;
. = ALIGN(16);
} >> ram
.kernel_data : #AT(ADDR(.main_application_bss) + SIZEOF(.main_application_bss))
{
__KERNEL_DATA_START = ALIGN(0x10);
}
.end_of_kernel_data :
{
__KERNEL_DATA_END = .;
} > end_of_kd
.boot_stack :
{
_stack_end = .;
} > bstack
.end_of_boot_stack :
{
_stack_addr = .;
__SP_INIT = .;
__BOOT_STACK_ADDRESS = .;
} > end_bstack
.sram_data :
{
. = ALIGN(512);
__BDT_BASE = .;
*(.usb_bdt)
__BDT_END = .;
__SRAM_POOL = .;
__UNCACHED_DATA_START = .;
} > sram
# Locate the ROM copy table into ROM after the initialized data
_romp_at = __COPY_OF_DATA + SIZEOF(.main_application_data);
.romp : AT (_romp_at)
{
__S_romp = _romp_at;
WRITEW(__COPY_OF_DATA); #ROM start address
WRITEW(ADDR(.main_application_data)); #RAM start address
WRITEW(SIZEOF(.main_application_data)); #size
WRITEW(0);
WRITEW(0);
WRITEW(0);
} >> ram
_flashx_start = __COPY_OF_DATA + SIZEOF(.main_application_data) + SIZEOF(.romp);
# flashx working area spans across the whole rest of Flash memory
__FLASHX_START_ADDR = ((_flashx_start + __FLASHX_SECT_SIZE - 1) / __FLASHX_SECT_SIZE) * __FLASHX_SECT_SIZE;
__FLASHX_END_ADDR = __INTERNAL_FLASH_BASE + __INTERNAL_FLASH_SIZE;
}
/* EOF */
Hello Zhang My application is flashing from address 0x00000000 I want to change it from eg. 0x00001000 . I have done changes in linker command file but it is not taking effect. Could you please tell me what is happening or is it necessary to do changes in other file also other than linker command file?:smileyplain:
Hello Zhang Actually i was trying with the bare board project with reference to the previous document. Actually i read this application note of lcf but i did not got any solution :smileyconfused: I will try again with this and get back soon. Thank you.:smileygrin:
Could you please refer to the doc below?
https://community.freescale.com/docs/DOC-101433
Fiona Kuang
Technical Information & Commercial Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------