Problems going from K60 Tower to MK60DN512VLQ10 on custom board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems going from K60 Tower to MK60DN512VLQ10 on custom board

1,132 Views
chinniwhites
Contributor II

I am using MQX4.1 and CW10.6 and recently made a custom board using MK60DN512VLQ10.  I did all my program dev on K60 tower module.  I switched processor used under bsp using processorexpert.  I changed the I/O around so there was no conflicts, everything compiles, no issues.  I can load the program successfully but only by using the flash file to target using PE multilink - Run and debug methods dont work.  After program loads, I reboot my device and the led that is always supposed to come on never does, no lights come on Ethernet Jack when cable is plugged in, no signs of life, etc.  I am sure it may be hardware issue, but just wanted to double check that there is not a setting I am missing in CW10.6/PE/MQX that says load program out of a particular area that changed going from tower to custom board.

Thanks in advance!

0 Kudos
6 Replies

619 Views
RadekS
NXP Employee
NXP Employee

When you use PE for basic modification at new BSP, clock settings from PE “overwrite” MQX clock settings (more details in: Freescale_MQX_4_1\doc\tools\cw\MQX_Howto_Setup_Kinetis_Clock_UsingPE.pdf). However current pins configuration is typically modified when you install any MQX driver and this will probably overwrite your PE configuration. Please check mainly init_gpio.c file in your BSP source directory. You can see here pin configurations for various hardware modules. I would like to recommend modifications in this file according your board configuration.

If you want use some of PE drivers, you have to modify MQX drivers by PE code (or use directly MQX_Lite).

However from you description (debugging isn’t possible) it really looks like some hardware issue – probably in clock domain.

I suppose that you used TWR-K60D100M as pattern for your BSP, correct?

Could you please check whether you used clock source (crystal/oscillator) with the same/similar parameters? Could you please check by oscilloscope whether crystal/oscillator runs?

You can try placing here your schematic and I will check it for any obvious or potential issues.


Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

619 Views
chinniwhites
Contributor II

Thanks for Reply!

I fought through some issues but still do not have running board. I was finally able to debug and seen my code gets stuck in a while loop in cpu.c due to incorrect clock settings.  I do not have external osc on custom board, so I change clock config to use FEI and problem seem to go away.  Now, I debug and get stuck in mqx.c line 386.  Comments on mqx_exit functions say:

It is important to ensure that the environment (boot call stack) the

* MQX is returning to is in the consistent state. This is not provided by

* distributed MQX BSPs, because the boot stack is reused (rewritten) by MQX

* Kernel data. Set the boot stack outside of Kernel data section to support

* correct _mqx_exit() functionality.

How do I set the boot stack outside of the Kernal data???

#if MQX_EXIT_ENABLED || MQX_CRIPPLED_EVALUATION

    kernel_data->USERS_ERROR = error;

    if (kernel_data->EXIT_HANDLER) {

        (*kernel_data->EXIT_HANDLER)();

    }/* Endif */

    MQX_LONGJMP( _mqx_exit_jump_buffer_internal, 1 );

#else

    while (TRUE) {          <-----line 386

    } /* Endwhile */

#endif

} /* Endbody */

0 Kudos

619 Views
RadekS
NXP Employee
NXP Employee

Yes I agree that this description isn’t very clear, but it is simple.

You code call function for exit from mqx code.

There are two options how to continue after MQX exit:

  1. You can stay in endless loop as in your case.
  2. You can start execute any other code (if MQX_EXIT_ENABLED || MQX_CRIPPLED_EVALUATION), but in this case you have to specify which code has to be executed (e.g. some baremetal code, bootloader, …). So, you can specify _mqx_exit_jump_buffer_internal as address where starts code which has to be executed when MQX ends.

Of course, this is absolutely out of control of MQX which already ends.

0 Kudos

619 Views
chinniwhites
Contributor II

Is the calling of _mqx_exit function happening in error or is this normal MQX operation to call this function?  How do I fix?

I change MQX_EXIT_ENABLED to 1 in small_ram_config.h and now I am stuck here in _arm_end.c:

/*

*    _ExitProcess

*

*/

extern void _ExitProcess(int status) _EWL_WEAK;

extern void _ExitProcess(int status)

{

#if defined(__SEMIHOSTING)

    sys_exit(status);

#endif

    while (1);

}

pastedImage_0.png

0 Kudos

619 Views
RadekS
NXP Employee
NXP Employee

_mqx_exit is standard function which is used in both cases.

You can call _mqx_exit when MQX finish his work and there isn’t any task for executing like in case of bootloader (_mqx_exit(0), This will cause exit bootloader mqx app and execute the new image).

Or, you can call _mqx_exit in case of any fatal error (e.g. _mqx_exit(1), in case of out of memory issue).

__arm_end.c is file from CW arm library, and it works likewise as in _mqx_exit however this is next step after _mqx_exit function. I suppose that you don’t have any other code except your MQX application, therefore you should search what cause call of _mqx_exit function in your case.

If you are not able debug it step by step, you can search using of _mqx_exit function in MQX directory and your project and use breakpoints for revelation of place where code calls _mqx_exit function.

Other way is create breakpoint at begin of _mqx_exit and look at call stack for search from where this function is called.

0 Kudos

619 Views
chinniwhites
Contributor II

I choose FBI for clock config and I no longer have the mqx exit issue.  Now I have the same exact issue as mentioned in this post here:MQX BSP Port CodeWarrior Debug Issue : problem is there doesnt seem to be answer to what fixed...

Execution starts at the program entry point in boot.S. The following lines of code are stepped through:

  1.         /* disable interrupts and clear pending flags */ 
  2.         ldr r0, =0xe000e180     /* NVIC_ICER0 - Interrupt Clear-Enable Registers */ 
  3.         ldr r1, =0xe000e280     /* NVIC_ICPR0 - Interrupt Clear-Pending Registers */ 
  4.         ldr r2, =0xffffffff 
  5.         mov r3, #
  6.  
  7.  
  8. ASM_LABEL(_boot_loop) 
  9.         cbz r3, _boot_loop_end 
  10.         str r2, [r0], #4        /* NVIC_ICERx - clear enable IRQ register */ 
  11.         str r2, [r1], #4        /* NVIC_ICPRx - clear pending IRQ register */ 
  12.         sub r3, r3, #
  13.         b _boot_loop 
  14.  
  15.  
  16. ASM_LABEL(_boot_loop_end) 
  17.  
  18.  
  19.         /* prepare process stack pointer */ 
  20.         mrs r0, MSP 
  21.         msr PSP, r0 
  22.  
  23.  
  24.         /* switch to proccess stack (PSP) */ 
  25.         mrs r0, CONTROL 
  26.         orr r0, r0, #
  27.         msr CONTROL, r0 
  28.         isb #15 

After line 20 in the above segment code jumps to line 3 in the following:

  1. #if defined(__CODEWARRIOR__) 
  2.         ASM_EXTERN(__thumb_startup) 
  3.         b ASM_PREFIX(__thumb_startup) 
  4. #elif defined(TOOLCHAIN_GCC_CW) 
  5.         /* call startup from EWL library */ 
  6.         ASM_EXTERN(__thumb_startup) 
  7.         b ASM_PREFIX(__thumb_startup) 
  8. #elif defined(__IAR_SYSTEMS_ICC__)  || defined (__IASMARM__) 
  9.         ASM_EXTERN(__iar_program_start) 
  10.         b ASM_PREFIX(__iar_program_start) 

After this the execution jumps to startup.c inside asm void __thumb_startup(void). The _bl_init_registers fall through fine. After that the call to _bl_init_hardware takes the control to comp.c __init_hardware(void) and from there to init_hw.c and from there to CPU.c __pe_hardware_initialize(void). The following lines of code execute there:

  1. void __pe_initialize_hardware(void
  2.   /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/ 
  3.  
  4.  
  5.   /*** ### MK60DN512ZVMD10 "Cpu" init code ... ***/ 
  6.   /*** PE initialization code after reset ***/ 
  7.   /* SIM_SCGC6: RTC=1 */ 
  8.   SIM_SCGC6 |= (uint32_t)0x20000000UL;                      
  9.   if ((RTC_CR & RTC_CR_OSCE_MASK) == 0u) { /* Only if the OSCILLATOR is not already enabled */ 
  10.     /* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0 */ 
  11.     RTC_CR &= (uint32_t)~0x3C00UL;                     
  12.     /* RTC_CR: OSCE=1 */ 
  13.     RTC_CR |= (uint32_t)0x0100UL;                      
  14.     /* RTC_CR: CLKO=0 */ 
  15.     RTC_CR &= (uint32_t)~0x0200UL;                     
  16.   } 
  17.   /* Disable the WDOG module */ 
  18.   /* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */ 
  19.   WDOG_UNLOCK = (uint16_t)0xC520U;     /* Key 1 */ 

At line 18 of the above segment on trying to step through it the control goes back to the first line of the boot.S segment of code given above and execution follows the same chain infinitely from there.

0 Kudos