Hi,
I have been working in a program for K60 with CW10.2 and MQX3.8
I'm working with a bootloader based in example AN4368SW Rev2 (I want to share something: if someone want to us it, disconnect "Enable Exceptions" i Build properties/language). The problem is that the app that this bootloder loads uses interrupts, when I execute the program without bootloader all goes well, but when the bootloader, that uses his own vectors.c for using USB, executes the app at memory 10000h all goes well except there are no interrupts, no USB, no UART, nothing.
I'm using:
#define MQX_ROM_VECTORS 0 in PSP and Builded it
SCB_VTOR = (uint32_t)0x1FFF0000; To redirect Vector Table in the APP
Linked:
MEMORY
{
vectorrom (RX): ORIGIN = 0x00010000, LENGTH = 0x0000400
data14000000 (RW) : ORIGIN = 0x14000000, LENGTH = 0x00001000
rom (RX): ORIGIN = 0x00010410, LENGTH = 0x0006FBF0 # Code + Const data
vectorram (RWX) : ORIGIN = 0x1FFF0000, LENGTH = 0x0000418
ram (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x0001FC00 # SRAM - RW data
# kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)
end_of_kd (RW): ORIGIN = 0x2000FFF0, LENGTH = 0x00000000
# Boot stack reused by MQX Kernel data
bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 # Boot stack
end_bstack (RW): ORIGIN = 0x2000FBFF, LENGTH = 0x00000000
}
My question is:
How I allocate vector table to 0x1FFF0000, I thougt that this is automatic when changing "#define MQX_ROM_VECTORS 0" and "SCB_VTOR" but seems that no. I need to use the standard MQX Vector Table for my app becouse I need some drivers in it. it seems that bootloader is initializing with his vector table and that after that the desired Vector table is not being redirected or have not been allocated perhaps, dont know.
Please, any help will be welcome.
Sorry for my posible english errors, I'm from Barcelona, SPAIN. jejeje
Hola Cristobal
By default, MQX allocates the vector table at the first address of the flash memory, 0x0000-0000, so it is necessary to reallocate the vector table. You need to modify the intflash.lcf linker file in order to move the code section (vectorrom, cfmprotrom and rom memory segments) to the user application region. This file is located at the next path
\Freescale_MQX_4_0\mqx\source\bsp\CUSTOM_BOARD\cw
After that, you need to re-build all the libraries (BSP, PSP, etc)
I want to believe that this appnote can be a guideline for developing your bootloader:
http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4367.pdf
This appnote describes how to add the FNET bootloader to Kinetis projects. There is a section that includes adding it to the MQX linker which is the section that I believe you will find useful.
Espero que esto te ayude.
Saludos
Soledad
I've tried two diferent ways of having the bootloader executing my app:
Code in the first lines of my app:
1. Using the table allocated in RAM:
#define MQX_ROM_VECTORS 0 in PSP and Builded it
SCB_VTOR = (uint32_t)0x1FFF0000; To redirect Vector Table in the APP
2: Using the table in FLASH (10000h): // I read that Kinetis can have more than once in flash so I test it
#define MQX_ROM_VECTORS 1 in PSP and Builded it
SCB_VTOR = (uint32_t)0x00010000; To redirect Vector Table in the APP
The application boots perfectly but the problem is the same, the vector table is where it has to be but my interruptions don't affect to it. Seems that the Bootloader has not let free the interrupts handl for the app to use it.
In the bootloader I'm using CPSID to disable interruptions before jumping to the application. That's enough?
asm ("CPSID i"); // Disable interrupts
asm // Code to jump to the application
{
ldr r4,=New_sp
ldr sp, [r4]
ldr r4,=New_pc
ldr r5, [r4]
blx r5
}
Gracias por tu atención.
Hola Soledad,
I think that the table is relocated the problem is that the system is not using it. If I use in the beginning of my app "SCB_VTOR = (uint32_t)0x1FFF0000;" it runs but interrupts don't go. If I change the line to 0x10000 for example, the app don't run at all. I use a local modified copy of intflash.lcf with all that you comment but the problem of the interrupts have me stucked.
Some code of my app (the bootloader runs it at direction 10000h)
My .lcf file:
KEEP_SECTION { .vectortable }
MEMORY
{
vectorrom (RX): ORIGIN = 0x00010000, LENGTH = 0x0000400
#cfmprotrom (RX): ORIGIN = 0x00010400, LENGTH = 0x00000010
data14000000 (RW) : ORIGIN = 0x14000000, LENGTH = 0x00001000
rom (RX): ORIGIN = 0x00010410, LENGTH = 0x0006FBF0 # Code + Const data
vectorram (RWX) : ORIGIN = 0x1FFF0000, LENGTH = 0x0000418
ram (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x0001FC00 # SRAM - RW data
# kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)
end_of_kd (RW): ORIGIN = 0x2000FFF0, LENGTH = 0x00000000
# Boot stack reused by MQX Kernel data
bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 # Boot stack
end_bstack (RW): ORIGIN = 0x2000FBFF, LENGTH = 0x00000000
}
my .xmap file:
# .vectorrom
#>00010000 ___VECTOR_ROM (linker command file)
# .vectors
#>00010000 __VECTOR_TABLE_ROM_START (linker command file)
00010000 00000400 .vectors_rom rom_vector (bsp_twrk60n512_d.a vectors.o )
00010000 00000000 .vectors_rom .vectors_rom (bsp_twrk60n512_d.a vectors.o )
# .main_application
00010410 00000000 KERNEL _sched_start_internal (psp_twrk60n512_d.a dispatch.o )
...
# .main_application_data
#>1FFF0000 __VECTOR_TABLE_RAM_START (linker command file)
1FFF0000 00000418 .vectors_ram ram_vector (bsp_twrk60n512_d.a vectors.o )
1FFF0000 00000000 .vectors_ram .vectors_ram (bsp_twrk60n512_d.a vectors.o )
#>1FFF0600 __BDT_BASE (linker command file)
1FFF0600 00000000 .usb_bdt .usb_bdt (usb_hdk_twrk60n512_d.a khci.o )
1FFF0600 00000200 .usb_bdt bdt (usb_hdk_twrk60n512_d.a khci.o )
#>1FFF0800 __BDT_END (linker command file)
#>1FFF0800 __START_DATA (linker command file)
...
# Memory map:
v_addr p_addr size name
00010000 00010000 00000000 .vectorrom vectorrom
00010000 00010000 00000400 .vectors vectorrom
14000000 14000000 00001000 data14000000
00010410 00010410 0002363C .main_application rom
1FFF0000 1FFF0000 00000418 vectorram
1FFF0000 00033A4C 00002D40 .main_application_data ram
1FFF2D40 1FFF2D40 0000AC00 .main_application_bss ram
1FFFD940 1FFFD940 00000000 .kernel_data ram
2000FFF0 2000FFF0 00000000 .end_of_kernel_data end_of_kd
2000FA00 2000FA00 00000000 .boot_stack bstack
2000FBFF 2000FBFF 00000000 .end_of_boot_stack end_bstack
2000FBFF 0003678C 00000018 .romp end_bstack
# Link start time: Thu Feb 20 10:32:27 2014
# Link end time: Thu Feb 20 10:32:28 2014
Need to solve it as soon as posible, thanks for your attention.