Hi
I would like to test the USB bootloader on my TWR-K60D100M+TWR-SER. I'm using CW 10.2 and MQX 3.8.
I have the AN 4368 and the associated example projects (kinetis_k60 and mfs_usb_twrk60n512). The good think is that I can compile both examples w/o errors. The bootloader itself is running too and it is possible to insert an USB stick and to get an image copied (mfs_usb_twrk60n512). But the copied image doesn't work. I only get the message "User application is running..." but nothing happens.
The strange thing is that if I'm using the pre-compiled example (mfs_usb_twrk60n512) everything is working well. This leads me to the conclusion that the bootloader itself is ok.
I changed the applications intflash.lcf file to
MEMORY
{
vectorrom (RX): ORIGIN = 0x00010000, LENGTH = 0x00000400
# cfmprotrom (R): ORIGIN = 0x00010400, LENGTH = 0x00000020
rom (RX): ORIGIN = 0x00010420, LENGTH = 0x0006FBE0 # Code + Const data
ram (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x00020000 # SRAM - RW data
...
What do I miss???
Thank you
Mario
Hi Mario,
It is also necessary to set #define MQX_ROM_VECTORS 0 in user_config.h and recompile MQX libraries.
BR,
Carlos
Hi Carlos
I set the #define MQX_ROM_VECTORS 0 in user_config.h and I recompiled my libs (bsp, psp, shell and example). It doesn't work.
I had a look into the S19 file and I think this looks good - at least it starts at address 0x10000:
S0 030000FC
S3 51 00010000 FFFB 0020 9183 0100 FD730100FD730100FD730100FD730100FD73010000000000000000000000 .... 30100FD7301009D
...
Debugging the bootloader I can see the addresses from above again:
New_sp = IMAGE_ADDR[0]; --> 0x2000FBFF | |
New_pc = IMAGE_ADDR[1]; --> 0x00018391 |
The assembler code uses this addresses and jumps to the given memory location where some code is executed. But not mine which should show some printf's...
Other ideas?
Thank you
Mario
Hi Mario, I'm having the same problem as you. Did you figure out the issue?
Hi Angelo
Can you describe your problems?
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?
Hi Benitoar
Sorry for the late answer. I had a similar problem but I couldnt remember the solution. Have a look at this thread: _sched_start_internal crash (svc). I installed the new interrupt handler that is described here: A Processor Expert Component to Help with Hard Faults | MCU on Eclipse. (I only used the interrupt handler). After trapping into the interrupt this handler shows the pc of the problematic code in register r1, Using the disassembly view of the debugger you can find the source line.
If I remember right in my case the initialization of dma failed somehow.
I hope that helps
Mario