Using Crossworks with nRF51422 with the new SDK and CMSIS RTX

Comments

4 comments

  • Avatar
    Michael Johnson

    Hi Alexandre,

    I can't find the project file you refer to is it missing from the zip file?

    Regards

    Michael

     

    0
    Comment actions Permalink
  • Avatar
    Alexandre Courtemanche

    Hello Michael, 

    I have made a mistake and archived the file structure without the example project. Here is a archive file with the project file in it. I had to remove a lot of the other files that are usually in the SDK and keep the minimum because of the maximum file size for uploads.

    Thanks for the response,

    Alex

    0
    Comment actions Permalink
  • Avatar
    Michael Johnson

    Hi Alex,

    Stepping through the code I end up in HAL_CM0.s/SVC_Handler and the line of the code

      MRS     R0,PSP                  /* Read PSP */

    puts 0xfffffffc into r0 i.e. the process stack hasn't been initialised.

    This is "called" from rt_CMSIS.c/osTimerCreate because the variable os_running is set to 34 - where did that come from? It's declared rt_CMSIS.c as

    uint8_t os_running;                             // Kernel Running flag

    which means it gets put in the .bss section. This section should be zeroed by the cstartup code but I don't see it in gcc_startup_nrf51.s. I added

        ldr r0, =__bss_start__
        ldr r1, =__bss_end__
        movs r2, #0
    1:
        cmp r0, r1
        beq 2f
        strb r2, [r0]
        adds r0, r0, #1
        b 1b
    2:

    to gcc_startup_nrf51.s and now the code fails in main.c:789

    ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL);

    due the fact that mp_tcb appears not be initialised and also psp is still 0xfffffffc. I suspect that svcKernelInitialize() needs to be called from somewhere before any threads are created.

    Regards

    Michael

    0
    Comment actions Permalink
  • Avatar
    Rols

    I highly recommend NOT using the gcc_startup_nrf51.s if working with CrossWorks, but instead linking in the nRF51_Startup.s and thumb_crt0.s provided as part of the Crossworks NRF51 support package. They properly set up all the sections, configure the heap (if used) correctly and are also a lot easier to understand. 

    0
    Comment actions Permalink

Please sign in to leave a comment.