stuck on boot.S MQX-SDK with Processo Expert

cancel
Showing results for 
Search instead for 
Did you mean: 

stuck on boot.S MQX-SDK with Processo Expert

Jump to solution
751 Views
holyhope
Contributor III

Hi to all!

i have a problem: I'm using FRDM-K64 with MQX-SDK 1.0.0. I develop with KDS 1.1.1

I created a new project with Processor Expert and add MQX component

All work well, now I tryied to use printf adding #include <stdio.h> and move the UART0 from prin 14-15 to pin 16-17, I recompile all and when debug the default breackpoint stop on main.c at   PE_low_level_init(); I try to run but it stop in the file:

boot.S

on line:

ldr r0, =NVIC_ICER0


and when I press "go" my code run and return to this point...

I try to delete the include and printf reference and restore original pin on 14-15 for UART0

my boot.S (never modified):

#include "asm_mac.h"

#include "mqx_cnfg.h"

#include "types.inc"

#include "psp_prv.inc"

#define __ASM__

#include "psp_cpu.h"

#undef __ASM__

    ASM_COMP_SPECIFIC_DIRECTIVES

    ASM_CODE_SECTION(.text)

    SET_FUNCTION_ALIGNMENT

    ASM_PUBLIC(__boot)

/*FUNCTION*-------------------------------------------------------------------

Function Name    : __boot

Returned Value   :

Comments         : startup sequence

END*-----------------------------------------------------------------------*/

ASM_EQUATE(NVIC_ICER0, 0xE000E180)

ASM_EQUATE(NVIC_ICPR0, 0xE000E280)

    ASM_PUBLIC_BEGIN(__boot)

    ASM_PUBLIC_FUNC(__boot)

ASM_LABEL(__boot)

#if MQX_AUX_CORE

        msr MSP, r0

        isb #15

#endif

        /* Disable interrupts and clear pending flags */

        ldr r0, =NVIC_ICER0

        ldr r1, =NVIC_ICPR0

        ldr r2, =0xFFFFFFFF

        mov r3, #8

ASM_LABEL(_boot_loop)

        cbz r3, _boot_loop_end

        str r2, [r0], #4        /* NVIC_ICERx - clear enable IRQ register */

        str r2, [r1], #4        /* NVIC_ICPRx - clear pending IRQ register */

        sub r3, r3, #1

        b _boot_loop

ASM_LABEL(_boot_loop_end)

        /* Prepare process stack pointer */

        mrs r0, MSP

        msr PSP, r0

        /* Switch to proccess stack (PSP) */

        mrs r0, CONTROL

        orr r0, r0, #2

        msr CONTROL, r0

        isb #15

#if MQXCFG_ENABLE_FP && PSP_HAS_FPU

        /* CPACR is located at address 0xE000ED88 */

        LDR.W   R0, =0xE000ED88

        /* Read CPACR */

        LDR     R1, [R0]

        /* Set bits 20-23 to enable CP10 and CP11 coprocessors */

        ORR     R1, R1, #(0xF << 20)

        /* Write back the modified value to the CPACR */

        STR     R1, [R0]

        /* turn off fpu register stacking in exception entry */

        ldr r0, =0xE000EF34     /* FPCCR */

        mov r1, #0

        str r1, [r0]

#endif

        /* Perform toolchain startup routines */

        ASM_EXTERN(toolchain_startup)

        b ASM_PREFIX(toolchain_startup)

    ASM_PUBLIC_END(__boot)


        ASM_ALIGN(4)

        ASM_END

when I compile I have a problem on PSP with asm volatile and I change two line in file "psp_supp.c" in this way:


uint16_t _psp_swap2byte(uint16_t n)

{

    uint16_t ret;

    //asm volatile ("rev16 %0, %1" :"=r" (ret):"r" (n));

    __ASM volatile("rev16 %0, %1" :"=r" (ret):"r" (n));

    return(ret);

}

/*!

* \brief Swap 4 bytes

*

* \param n

*

* \return uint32_t

*/

uint32_t _psp_swap4byte(uint32_t n)

{

    uint32_t ret;

    //asm volatile ("rev %0, %1" :"=r" (ret):"r" (n));

    __ASM volatile("rev %0, %1" :"=r" (ret):"r" (n));

    return(ret);

}

but after this modify the compile work and my code run, the problem occours when I try to use printf...

What i can do?!

Many thanks

0 Kudos
1 Solution
103 Views
RadekS
NXP Employee
NXP Employee

Problem is probably in point that you call OSA interface (API between SDK and operating system) prior you initialize MQX.

It seems that UART_DRV_Init() function is generated for calling it from operating system.

I suppose that boot.S is here innocently. It is just result of MCU reset.

Here is instruction how to partially drive Processor expert code generation however I suppose, that it will not help you directly:

http://mcuoneclipse.com/2012/03/23/disable-my-code-generation/


Have a great day,
RadekS

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

View solution in original post

0 Kudos
4 Replies
103 Views
holyhope
Contributor III

Hi found a new information:

It seem that the problem present when I add an UART with ProcessorExpert.

I added the UART 1 RX (PTC3) and TX (PTC4), I generate code and compile and work

I added a component (from components library) of type "fsl_uart", add baudrate 115200 I generate code and compile and BLOCK! Do not work! Stuck on boot.S .... note that i never use any function, I only create the UART1

If I remove "uartCom1:fsl_uart", generate code, compile and... WORK!


I analize the code, the problem is when the driver initialize the UART.

comment/uncomment this instruction:

  UART_DRV_Init(FSL_UARTCOM1,&uartCom1_State,&uartCom1_InitConfig0);


the code work and do not work (note: the code stuck ot not stuck in boot.S... UART1 function are not tested, maybe without init UART not work but the code do not stuck un boot.S).


In this procedure the code is:


uart_status_t UART_DRV_Init(uint32_t instance, uart_state_t * uartStatePtr,

                            const uart_user_config_t * uartUserConfig)

{

    assert(uartStatePtr && uartUserConfig);

    assert(instance < HW_UART_INSTANCE_COUNT);

    uint32_t baseAddr = g_uartBaseAddr[instance];

    uint32_t uartSourceClock;

    /* Exit if current instance is already initialized. */

    if (g_uartStatePtr[instance])

    {

        return kStatus_UART_Initialized;

    }

    /* Clear the state structure for this instance. */

    memset(uartStatePtr, 0, sizeof(uart_state_t));

    /* Save runtime structure pointer.*/

    g_uartStatePtr[instance] = uartStatePtr;

    /* Un-gate UART module clock */

    CLOCK_SYS_EnableUartClock(instance);

    /* Initialize UART to a known state. */

    UART_HAL_Init(baseAddr);

    /* Create Semaphore for txIrq and rxIrq. */

    OSA_SemaCreate(&uartStatePtr->txIrqSync, 0);

    OSA_SemaCreate(&uartStatePtr->rxIrqSync, 0);

[....] MANY OTHER CODE... [...]

    return kStatus_UART_Success;

}


and when execute:


OSA_SemaCreate(&uartStatePtr->txIrqSync, 0);


the code will stuck in boot.S

I check in confg in MQX_KDSK and I not found info aboiut semaphore, I foun LW_semaphore but nothing about normal sempahore.

there is somthing that I must do?

I try to use not MQW and the code work... Problem maybe is when I use both MQX_KDSK and UART1, in initialization there is the problem... I try to move the init code in a task of MQX and the code execute correctly... But anytime I generate code I  must move the init code in a task... And i suppose that if I create another component the problem still occours with that init procedure ...

Why? Anyone have some idea?

Many thanks,

MAssimiliano

0 Kudos
104 Views
RadekS
NXP Employee
NXP Employee

Problem is probably in point that you call OSA interface (API between SDK and operating system) prior you initialize MQX.

It seems that UART_DRV_Init() function is generated for calling it from operating system.

I suppose that boot.S is here innocently. It is just result of MCU reset.

Here is instruction how to partially drive Processor expert code generation however I suppose, that it will not help you directly:

http://mcuoneclipse.com/2012/03/23/disable-my-code-generation/


Have a great day,
RadekS

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

View solution in original post

0 Kudos
103 Views
holyhope
Contributor III

Ok maybe it is correct,

Now I'm using FreeRTOS because there are many other several problem that i discover on MQX beta version for KSDK.

That problem seems not present on FreeRTOS

0 Kudos
103 Views
RadekS
NXP Employee
NXP Employee

Note:

OSA layer is here as interface between various systems and SDK code.

One of systems is also baremetal (without operating system).

You can look at c:\Freescale\KSDK_1.0.0\platform\osa\src\.. files. There you can see that OSA has different files with OSA implementation for every system.

You can check fsl_os_abstraction.h file. Here you can see, that fsl_os_abstraction_bm.h will be included when you don’t define any of followed macros: FSL_RTOS_MQX, FSL_RTOS_FREE_RTOS, FSL_RTOS_UCOSII, FSL_RTOS_UCOSIII

So, OSA should work even when you decide not use any operating system. I suppose that previous issue was caused by any error in these macros.

0 Kudos