This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC2640: Task functions never called

Part Number: CC2640
Other Parts Discussed in Thread: CC2650STK,

Tool/software: Code Composer Studio

Hi,

I'm working on BLE application for cc2640 target.

I'm able to build the app successfully. I could open CCS debug window and app binary is successfully loaded into target via JTAG cable through XDS110 debug probe. 

I'm using TI RTOS  V2.20.01.08, BLE STACK V2.02.01.18, Compiler version V5.2.5

Now, after calling BIOS_start() in my main function, none of the created tasks get run except for the ICall_taskEntry and the Idle task. All other tasks show as "Ready" but never execute .(as shown below)

I couldn't find  what is the problem.

1) Is there any issues with ICall_taskEntry function?
2) Please share pointers to solve this issue.

  • What's the project you started with?
    What modification have you done to the project?
    Can you strip down the code to see after what's added to the project, this happens?
  • Hi,

    Are you able to provide the information I asked?
  •      Hi,

       

    We started with Sensortag_cc2650stk_app which is available as sample BLE app.

    We have implemented Movement sensor GATT profile.

    The main code flow is shown in below image. We have enabled GAP role task and SensorTag application task (Movement sensor).

  • Hi  

    ,

    Can you share some pointers on the code what I attached?

  • Did you modify the content of SensorTag_createTask?

    Did you program the BIM project?

  • Hi,
    1) we have modified the this task's init and task_fxn to manage spi based movement sensor.

    task is successfully created and in ready state. The execution should have gone into task's init function when BIOS_start() is called.

    But the init function is NOT called at all though we have set break point at very first line inside this init function.

    2) We are flashing using FLASHROM.Not with flashOnly_OAD.so we have not programmed BIM project
  • Hi Christin Lee,

    We are struck with this problem and unable proceed further. 

    We need to get some pointers on why the execution has not gone into application Task function (SenTag_taskfxn()) after BIOS_start()

    1) We have increased heap size by 1000 bytes more (Please refer below screenshot). Even then, we are getting same above issue. Is the heap config fine?.

      

    2) The very first line of above screenshot shows importing of cc2640.cfg file. We doubt that this cc2640.cfg file is not getting imported properly. How to check this importing of cc2640.cfg file working fine?.

    3) This cc2640.cfg file is not visible under TOOLS folder of Project Explorer (Please refer below Project explorer window screenshot). We feel that cc2640.cfg is not imported properly. How to make this cc2640.cfg file visible under the TOOLS folder of Project explorer window?

    4) The cc2640.cfg file is not visible under the Project explorer include path as well (please refer below image). Is this okay?. But this cc2640.cfg file is anyway there under this include path when we browse and see via Windows File Manager.



    Thanks in advance
    Regards,
    Roopa Kalmath

  • Hi Roopa,

    Can you enable the heapmgr metrics as per section 9.6 of the guide below
    www.ti.com/.../swru393

    Specifically check for heapmgrMemFail.

    In the test you have run above, you are increasing the BIOS heapsize, which is likely not the cause of your issue. In fact this may make it worse as the BIOS heap size will in fact shrink the ICall heap(if autosized). I would revert this change and perform the test I have recommended above.

    The dual heap architecture is described in section 3.11.4 of the guide above. What is the value of HEAPMGR_SIZE?
  • Hi Sean,

    Thanks for your pointer on checking  heapmgr metrics.

    1) I need to add  ICall_heapGetMetrics() function call in the main function before BIOS_start(), right?. This function will return heapmgrMemFail global variable value, right?. Please suggest suitable location to add this function call.

    2) The HEAPMGR_SIZE size is defined as 2872 in predefined symbols section of project properties. Is this fine?

    3) We will revert the BIOS heap size changes now.


  • Hi Roopa,

    1) You can place heapmgrMemFail right in the CCS watch window, run the processor until you see the hang, hit the pause button, and observe the variables in the watch window. You can also call the function, but this approach is easier.

    2) This is very much use case dependent on what you are doing in your application. The test from #1 will determine if the variable is large enough. You can also try testing with HEAPMGR_SIZE=0. This will give the maximum space between the end of the .bss and the beginning of the CSTACK/HWI STACK to the ICall heap. I suggest doing these tests independently.
  • Hi Sean,

    I have added the heapmgrMemFail in the CCS watch window , and  I ran the processor in the debug mode after run when I paused  in watch window I t is showing variable not found.

    and  it is showing HWI.C FILE .(Hwi exception handler as shown below) I'm not getting what is happening ? and I  set the  HEAPMGR_SIZE to 0.

  • Hi Roopa,

    The watch window is case sensitive, you would need to add the variable as "heapmgrMemFail" exactly, pasting everything between the "" characters. In any case, it does indeed appear that you have encountered an exception.

    Can you follow the steps in the guide that I linked to you under the Deciphering CPU exceptions?
  • Hi  Sean2,

     1) I added the variable  as heapmgrMemFail as you said, then also I'm getting  identifier not found as shown below.

    2) I  went through the deciphering CPU exceptions , the CFSR register  contents is shown below( after run the target)

    I'm not getting what is the wrong can you give some suggestions?

  • Hi Sean2,

    I think I'm having an issue with the Hwi exception handler as shown below. I dont have much knowledge about  this  HWI handler  

    can you give some suggestion  for solving this issue?

    contiune of exception:

  • Hi Sean2,

    We did following 2 tests by having BLINK LED task (BlinkLED_createTask) and ICALL task (ICall_createRemoteTasks).

    1) In main, the BlinkLED_createTask alone is enabled (as per below screen shot image). Here the ICall_createRemoteTasks is commented out. With this, the project is working fine and no exceptions were raised. The CFSR register is set to all 0's (i.e no errors in CFSR).

    Debug window screen shot image:

    2) Next time in main, both BlinkLED_createTask and ICall_createRemoteTasks are enabled (as per below screenshot image). With this, the project is NOT working fine and Hard Fault Exceptions were raised (Please refer screenshot image). In CFSR, the INVSTATE flag is set.

    Debug window image:

    3) With respect to above tests in point 1 and 2, We feel that ICall_createRemoteTasks is having issue and causing exceptions. For your information, we have compiled both app and stack projects successfully. But, we have downloaded only app project out file (sensortag_cc2650stk_app.out) into CC2640 target via XDS110 JTAG debugger probe. We have NOT downloaded stack out file (sensortag_cc2650stk_stack.out) into target. We assumed that app out file is combined with stack out, when we compile app project. Are we doing it correctly?


    Thanks in advance
    Roopa kalmath

  • Hi Roopa,

    UNDEFINSTR and INVSTATE consistent with a device trying to execute an invalid instruction, specifically one that does not have the THUMB bit set. All instructions in CM3 must have this bit set. In general you can get into this state by attempting to execute an invalid function pointer or where the runtime stack has overflow causing an invalid instruction to be loaded.

    >> We have NOT downloaded stack out file (sensortag_cc2650stk_stack.out) into target. We assumed that app out file is combined with stack out, when we compile app project. Are we doing it correctly?

    This is the problem. The stack and app projects compile and link as separate images. In fact, if the ICall task is enabled, then the process will attempt to "jump" into the stack by executing ICALL_STACK0_ADDR as a functon pointer. If you have not loaded the stack project then it will jump to a region of flash without code present (0xFFF...).


    This is covered here:
    www.ti.com/.../swru393

    Section Chapters 2-4 cover the SW architecture, section 2.7 covers how to merge hex files if needed using python.
  • Hi Sean,

    Thanks for your update. This time we have compiled and flashed both app and stack images separately in following order.

    - Built and flash the stack image and then build and flash the app image in this order

    - The ICALL_STACK0_ADDR(0x11001) from ccs_compiler_defines.bcfg matches for both app and stack projects.

    1) In main, BlinkLED_createTask, ICall_createRemoteTasks and GAPRole_createTask are enabled.  We flashed both stack and app images as per above order. With this the project is WORKING FINE without any exceptions. The LED is blinking fine.

    2) In main, BlinkLED_createTask, ICall_createRemoteTasks, GAPRole_createTask and  SensorTag_createTask are enabled (as per below image).  We flashed both stack and app images as per above order. With this the project is NOT running fine, LED is NOT blinking and got Hard Fault exception: FORCED: BUSFAULT: PRECISERR.Data Access Error. Address = 0x10d78.

    We loaded the LR register value ((0xfa07) of this exception which points to Icall_taskentry function as shown in the below image.

    Debug window image:

    Please share some pointers to solve this BUSFAULT:PRECISERR.

  • Hi Sean,

    Finally, We could solve this BUSFAULT:PRECISERR problem. This problem has come mainly due to the app binary flash memory is overlapping with stack binary flash memory area. The app and stack binary size and flash area details are given below:

    App binary flash space :

            Flash start address: 0x0

            App binary size: 66000 bytes

            Flash end address: 0x101D0   (here 1D0 bytes are overlapping onto stack flash space)

    Stack binary flash space :

            Flash start address: 0x11000 (As per ICALL_STACK0_ADDR)

            Stack binary size: 56000 bytes

            Flash end address: 0x1EAC0

    If you carefully see here, the 1D0 bytes are overlapping onto stack flash space. i.e)

    We optimized  the app code size below 66kb so that app binary size is NOT overlapping into stack flash space. i.e) the app binary space is separated from the  stack binary space. With this, we see that the project is working fine and LED is blinking. No exceptions raised.

    1) But We got another problem after overcoming this BUSFAULT error. We see that GAP role task is running fine.  But the GAP advertising is NOT visible to Mobile app. i.e) The Mobile app is NOT listing the BLE device's name and other associated GAP advertising and scan response data.   We suspect, the Flash last page (0x1E000) is overwritten with stack binary and hence the app binary is unable to cleanly keep CCA and CCFG contents on the Flash last page of 0x1E000.

    Am I right?. Please give me some pointers to solve now the GAP advertising NOT visible to Mobile app problem.

    Best regards,

    Roopa

  • Hi Roopa,

    >> If you carefully see here, the 1D0 bytes are overlapping onto stack flash space. i.e)

    The stack linker file (cc26xx_stack.cmd) should align to a flash page and should set ICALL_STACK0_ADDR accordingly based on the last address of the stack.

    If these are out of sync then I would suspect that perhaps the frontier tool didn't run properly on the stack side, can you confirm the following:

    1. Whenever making any changes to the stack, you re-build the stack first and then the app. Using Project > rebuild all?
    2. When doing above, do you notice that the contents of ccs_linker_defines.cmd and ccs_compiler_defines.bcfg have changed?
    3. Validate that the ccs_linker_defines are passed into the linker of the app so that the latest is used?


    >> We see that GAP role task is running fine. But the GAP advertising is NOT visible to Mobile app. i.e) The Mobile app is NOT listing the BLE device's name and other associated GAP advertising and scan response data.

    How are you validating that the GAP is running fine? Do you receive GAPROLE_STARTED event do you ever end up in GAPROLE_ERROR or GAPROLE_WAITING states? What is the state of the device (ROV, etc) if you pause it?

    >> We suspect, the Flash last page (0x1E000) is overwritten with stack binary and hence the app binary is unable to cleanly keep CCA and CCFG contents on the Flash last page of 0x1E000.

    You can verify this by manually inspecting the map file of the application.
  • Hi Sean,

    Thanks for your update.

    >>The stack linker file (cc26xx_stack.cmd) should align to a flash page and should set ICALL_STACK0_ADDR accordingly based on the last address of the stack.

    Here, We see that the ICALL_STACK0_ADDR is NOT defined. But the following key values are defined:

    #define FLASH_START       0x0

    #define RAM_START        0x20000000

    #define RAM_END          0x200048E7

    Please explain more what do you mean by saying stack linker file (cc26xx_stack.cmd) should align to a flash page.

    >> 1. Whenever making any changes to the stack, you re-build the stack first and then the app. Using Project > rebuild all?

    We could successfully rebuild stack project without any errors.

    With app project we see strange behavior. When we build app project, the build is successful. Please refer the below image.

    But when we rebuild app project, the build is NOT successful and getting errors in pem3 file as shown in below image.

    App project Build image:

    App project Rebuild image:

    1) What could be the problem with rebuild option?. 

    With successful build of app and stack project binaries, we flashed both on to the target.

    With this, we see that SensorTag_processAppMsg() is getting called successfully and following AppMsg events are coming
    in following order.
    GAPROLE_STARTED
    GAPROLE_ADVERTISING

    We see that gapRole_processGAPMsg() is getting called successfully and following GAPMsg events are coming
    in following order.
    GAP_DEVICE_INIT_DONE_EVENT
    GAP_ADV_DATA_UPDATE_DONE_EVENT
    GAP_MAKE_DISCOVERABLE_DONE_EVENT

    2) Is this rebuild error causing GAP advertising not visible to Mobile app?. 

    Best regards,
    Roopa



  • Hi roopa,

    >> Here, We see that the ICALL_STACK0_ADDR is NOT defined. But the following key values are defined

    ICALL_STACK0_ADDR should ALWAYS be defined. If it isn't you can get into the situation you described with overlapping hex files.
    have you verified that ccs_linker_defines.cmd is passed into the linker options on CCS? (Project properties --> ARM Linker --> File Search Path)

    At this point is seems something is wrong with the proejct settings. Can you try this again with a fresh install of the SDK as well and try to reproduce this?

    >> Please explain more what do you mean by saying stack linker file (cc26xx_stack.cmd) should align to a flash page.
    From cc26xx_stack.cmd you have the following which will force page alignment.
    GROUP > FLASH(HIGH) align PAGE_SIZE
    {
    EntrySection
    Page alignment between app/stack is required.


    >> 1) What could be the problem with rebuild option

    The issue you have shown is related to files that are generated during the configuro stage at which the kernel is built. This is run as a prebuild step to the application project. Again, it seems that the project settings have somehow been corrupted from the original example. I recommend re-starting fresh.


    >> 2) Is this rebuild error causing GAP advertising not visible to Mobile app?.

    As above, clearly something is wrong in the setup and likely resulting in a non working app.
  • Hi ,

    finally we could solve this problem by identifying followings

    before going to compile both stack and app we need to follow  some rules

    1) ICALL_STACK0_START should ALWAYS be defined in the  cc26xx_app.cmd (as shown in below image)

      

    2) stack always starts after the ICALL_STACK0_ADDR

    3) ccfg (configuration file ) should properly comming out in .out fie

    4) Ensure APP size is less than  ICALL_STACK0_START (view-->memory allocation as ashown below )

    memory allocation for app:

    memory allocation for stack:

    5) STACK need to be flashed first, and then the app need to be compiled and flashed.

    Regards,

    Roopa kalmath