Hi:
I have developed a BootLoader based on Application Note AN-4368.
The BootLoader works: I can load a simple application with interrupts and vectors in Flash.
The problem arises when I try to load a Bootable MQX-based program:
I modified the Linker Command File…
(${MQX_ROOT_DIR}\lib\DLG_V2.cw10gcc\debug\bsp\BootIntFlash.ld)
MEMORY
{
vectorrom (RX): ORIGIN = 0x0000C000, LENGTH = 0x00000410
/* cfmprotrom (R): ORIGIN = 0x00000400, LENGTH = 0x00000020 */
rom (RX): ORIGIN = 0x0000C420, LENGTH = (0x0007FFFF-0xC420) /* Code + Const data */
ram (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 = 0x2000FFF0, LENGTH = 0x00000000
/* Boot stack reused by MQX Kernel data */
bstack (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200 /* Boot stack */
end_bstack (RW): ORIGIN = 0x2000FC00, LENGTH = 0x00000000 /* Boot stack end address requires 4B alignment */
}
SECTIONS
{
__INTERNAL_SRAM_BASE = 0x1FFF0000;
__INTERNAL_SRAM_SIZE = 0x00020000;
__INTERNAL_FLASH_BASE = 0x00000000;
__INTERNAL_FLASH_SIZE = 0x00080000;
__INTERNAL_FLEXNVM_BASE = 0;
__INTERNAL_FLEXNVM_SIZE = 0;
__EXTERNAL_MRAM_BASE = 0x70000000;
__EXTERNAL_MRAM_SIZE = 0x00080000;
__EXTERNAL_MRAM_ROM_BASE = 0x70000000;
__EXTERNAL_MRAM_ROM_SIZE = 0x00000000;
__EXTERNAL_MRAM_RAM_BASE = 0x70000000;
__EXTERNAL_MRAM_RAM_SIZE = 0x00080000;
__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;
__KERNEL_DATA_VERIFY_ENABLE = 0; /* Test SDRAM read/write */
/* Flashx configurations */
__FLASHX_SECT_SIZE = 0x800;
.vectors :
{
__vector_table = .;
__VECTOR_TABLE_ROM_START = __vector_table;
KEEP(*(.vectors_rom))
. = ALIGN (0x4);
} > vectorrom
/*
.cfmprotect :
{
KEEP(*(.cfmconfig))
. = ALIGN (0x4);
} > cfmprotrom
*/
I modified the user_config.h (MQX_ROM_VECTOR false).
After problems with the WatchDog and other components in PE…
Finally The BootLoader Starts, check the existence off user App, Read The initial Stack and Program Counter and Jumps to execute de user App.
The Call Stack is this (user App Code):
PRB_MQX41 ATTACH [CodeWarrior]
ARM Processors, PRB_MQX41.elf (Suspended)
Thread [ID: 0x0] (Suspended)
4 (AsmSection)() dispatch.S:95 0x0000c420
3 _mqx() mqx.c:342 0x0001089e
2 main() mqx_main.c:67 0x00014494
1 __thumb_startup() __arm_start.c:279 0x00020eec
C:\DLG_V54\PRB_MQX41\DLG_V2_Boot\PRB_MQX41.elf (10/6/14 5:39 PM)
The user App completes all the steps in the function _mqx (), the last call in this function is “_sched_start_internal ()”;
The first instruction in “_sched_start_internal () is, svc SVC_RUN_SCHED
(formerly SWI) is “Supervisor Call”
The SVC vector (11) is at Offset 2c. In the ram_vector the vector points to 0xc455 (_svc_handler) but the processor Reset in this instruction…
… This is my ram_vector
ram_vector 0x1fff0000 0x1fff0000
[0 ... 99] 0x1fff0000
[0] 0x2000fc00 0x1fff0000
[1] 0x0000d6fd 0x1fff0004
[2] 0x0001438d 0x1fff0008
[3] 0x0001438d 0x1fff000c
[4] 0x0001438d 0x1fff0010
[5] 0x0001438d 0x1fff0014
[6] 0x0001438d 0x1fff0018
[7] 0x00000000 0x1fff001c
[8] 0x00000000 0x1fff0020
[9] 0x00000000 0x1fff0024
[10] 0x00000000 0x1fff0028
[11] 0x0000c455 0x1fff002c
[12] 0x0001438d 0x1fff0030
[13] 0x00000000 0x1fff0034
… this is the listing..
0000c454 <_svc_handler>:
END * ------------------------------------------------ ------------------------- * /
ASM_PUBLIC_BEGIN (_svc_handler)
ASM_PUBLIC_FUNC (_svc_handler)
ASM_LABEL (_svc_handler)
i cpsid.n
C454: i cpsid B672
tst lr, # 0x4 / * test EXC_RETURN number in LR bit 2 * /
C456: 0f04 f01e tst.w lr, # 4
ite eq / * if zero (equal) then * /
c45a: ite bf0c eq
mrseq r1, MSP / * Main Stack was used, put MSP in R1 * /
c45c: f3ef mrseq 8108 r1, MSP
mrsne r1, PSP / * else, Process Stack was used, put PSP in R1 * /
C460: 8109 f3ef mrsne r1, PSP
…and the VTOR register is 0x1ffff0000
In the bit Fields presentation 0x3ffe00
¿Any Idea?