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.

CC1352P: port ti ble5stack to zephyr project

Part Number: CC1352P
Other Parts Discussed in Thread: CC2651P3, CC2651R3

Hi

I'm working on this project BLE support. as you see, we are using Zephyr Project to realize our idea.

https://github.com/beagleboard/beagleconnect

There are two ways that we can think of to implement BLE functionality support on Zephyr.

  • Directly using Simplelink RF API, ported from MAC layer, using Zephyr's BLE protocol stack.

Although this approach requires a very large amount of work, we have still made some attempts. Here is some of the work we have done in our team, you can see that there can only be partial broadcast functionality and it is very difficult for us to proceed further. The main reason is that zephyr's BLE stacks are not designed for TI's MCUs, they are more suitable for Nordic's MCUs with more than 128K RAM. The CC1352P only has 80K of RAM, so it's hard to go in this direction.

https://github.com/cfriedt/zephyr-old/tree/simplelink-ble-for-zephyr/subsys/bluetooth/controller/ll_sw/ti

 https://github.com/leadercxn/zephyr/tree/cc135x_ble

  • Starting from the HCI layer, top layer applications use the Zephyr feature.

It may be more appropriate to start here, we have seen many implementations in the Zephyr Project, such as the esp32, stm32wb, and even the nrf53 series, which should be a more appropriate line.

https://github.com/zephyrproject-rtos/zephyr/tree/main/drivers/bluetooth/hci

We even see that you have made some guidance in the official documentation. These diagrams are very useful and explain very clearly what to do.

https://software-dl.ti.com/simplelink/esd/simplelink_cc13x2_26x2_sdk/5.20.00.52/exports/docs/ble5stack/ble_user_guide/html/ble-mesh/ti-zephyr-overview.html

But when we started in this direction, I found that the TI ble5stack was strongly bound to the TI RTOS and could not be ported to a third-party RTOS.

simplelink_cc13x2_26x2_sdk_5_20_00_52/source/ti/ble5stack/icall/src/icall.c

./rom/enc_lib/cc26xx_ecc_rom_api.a
./rom/r2/rt_init/rt7M_tl.a
./libraries/cc1352p/OneLib.a
./libraries/cc1352p/StackWrapper.a
./libraries/cc13x2r1/OneLib.a
./libraries/cc13x2r1/StackWrapper.a
./libraries/cc2651p3/OneLib.a
./libraries/cc2651p3/StackWrapper.a
./libraries/cc26x2r1/OneLib.a
./libraries/cc26x2r1/StackWrapper.a
./libraries/cc2651r3/OneLib.a
./libraries/cc2651r3/StackWrapper.a

/* Note that a static variable can be used to contain critical section
 * state since heapmgr.h template ensures that there is no nested
 * lock call. */
static ICall_CSState ICall_heapCSState;
#if defined(HEAPMGR_CONFIG) && ((HEAPMGR_CONFIG == 0) || (HEAPMGR_CONFIG == 0x80))
#include <rtos_heaposal.h>
#elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 1) || (HEAPMGR_CONFIG == 0x81))
#include <rtos_heapmem.h>
#elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 2) || (HEAPMGR_CONFIG == 0x82))
#include <rtos_heaptrack.h>
#else
#include <rtos_heaposal.h>
#endif

1, Can you provide code examples to verify the diagrams in your official documentation?

2, If 1 can't help us,  How we can get TI BLE3STACK to unbind with TI RTOS, we can use Zephyr RTOS as the kernel for the protocol stack to run.

3, If we want to realize our ideas, what better suggestions do you have? 

  • Hi Baozhu,

    I am assigning this to an expert now.

    Best

    Nate

  • Hey Baozhu,

    This is quite the interesting and challenging project you've got started!

    You've hit the main points already and thought through the challenges to use Zephyr's BLE stack on our devices. Please note that there aren't any examples of this end case, and it's not available in the SDK either, so I can only help you from a birds-eye without specific details.

    1, Can you provide code examples to verify the diagrams in your official documentation?

    The simple_mesh_node examples were designed to leverage the Zephyr Mesh stack. This is likely the closest starting point available in the SDK to your end application. This example was designed for nodes using Bluetooth mesh. More specifically, a porting layer was added so that we may use the higher level stack functionality that Zephyr Mesh provides, while using the TI BLE5 Stack's lower layers to do the rest. If you import simple_mesh_node you should be able to refer to Mesh>ti>ble for the porting side.

    2, If 1 can't help us,  How we can get TI BLE3STACK to unbind with TI RTOS, we can use Zephyr RTOS as the kernel for the protocol stack to run.

    You can try to remove the dependencies on TIRTOS manually, this will be a large effort. You would have to rework the heap tracking as it's done by the heap manager, like you've pointed out.

    3, If we want to realize our ideas, what better suggestions do you have? 

    Another option is to use our host_test project and implement a two chip solution, using another device as the host where you can use the Zephyr Bluetooth LE stack and use the HCI layer to talk to the MCU.

  • You can try to remove the dependencies on TIRTOS manually, this will be a large effort. You would have to rework the heap tracking as it's done by the heap manager, like you've pointed out.

    Thank you for your support and let's start from here. Zephyr RTOS has a good heap manager. Unbundling TI-RTOS is the biggest work inside this project.

    As you can see, I have no way to see the source code for the following binary. I have no way to know which TI RTOS APIs it uses. Can you output a list of all TI RTOS APIs that are not open for code used in BLE5Stack? 

    ./rom/enc_lib/cc26xx_ecc_rom_api.a
    ./rom/r2/rt_init/rt7M_tl.a
    ./libraries/cc1352p/OneLib.a
    ./libraries/cc1352p/StackWrapper.a

  • Hey Baozhu,

    I do see inside the example directory for the CC26X2 there is a freertos version of multi_role.c. You can refer to this as this sounds like what you are looking for. Perhaps you can start here and see if this is a workable place to start.

  • Hi Ammar,

    I don't find any FreeRTOS code in multi_role folder. what kind of SDK do you use?

    baozhu@bz:~/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52$ find ./ -name multi_role.c
    ./examples/rtos/LP_CC1352P7_4/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P_2_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC26X2R1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC2652R7/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC2652RB/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P_4_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352R1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC1352P7_1/ble5stack/multi_role/Application/multi_role.c
    baozhu@bz:~/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52$ cd ./examples/rtos/CC26X2R1_LAUNCHXL/ble5stack/multi_role/
    baozhu@bz:~/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/examples/rtos/CC26X2R1_LAUNCHXL/ble5stack/multi_role$ grep -nr freertos .
    baozhu@bz:~/ti/simplelink_cc13x2_26x2_sdk_5_20_00_52/examples/rtos/CC26X2R1_LAUNCHXL/ble5stack/multi_role$ 
    
    

  • It's available in the latest SDK, 5.30: https://www.ti.com/tool/SIMPLELINK-CC13XX-CC26XX-SDK.

    Note: the SDK was just renamed in 5.30 so for further updates to the SDK please refer to the above SDK link.

  • Hi Ammar,

    Merry Christmas!

    I don't see any difference between the 5.30 and 5.20 versions. There still no FreeRTOS code in multi_role folder.

    baozhu@bz:~/ti/simplelink_cc13xx_cc26xx_sdk_5_30_01_01$ find ./ -name multi_role.c
    ./examples/rtos/LP_CC1352P7_4/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P_2_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC26X2R1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC2652R7/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC2652RB/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352P_4_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/CC1352R1_LAUNCHXL/ble5stack/multi_role/Application/multi_role.c
    ./examples/rtos/LP_CC1352P7_1/ble5stack/multi_role/Application/multi_role.c
    baozhu@bz:~/ti/simplelink_cc13xx_cc26xx_sdk_5_30_01_01$ grep -nr freertos ./examples/rtos/CC1352P1_LAUNCHXL/ble5stack/multi_role 
    baozhu@bz:~/ti/simplelink_cc13xx_cc26xx_sdk_5_30_01_01$ 
    

  • Hm, I'm not sure what we're missing. Here is the full path to the freertos configuration:

    C:\ti\simplelink_cc13xx_cc26xx_sdk_5_30_01_01\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\multi_role\freertos

    To be clear, there isn't a separate project for freertos, the project maintains the same project files. Inside multi_role.c for example, you should see #ifdefs for FREERTOS that you can follow.

  • Hi,

    I just search multi_role in the CC1352P folder.  But you point out it stays in CC26X2R1. What's the BLE difference between  CC1352P and CC26X2R1?  Are they compatible?

  • Hey,

    There's a related post here that explains the difference between the boards. In terms of code regarding BLE, there should be minimal differences at the application layer going from one to the next. The intent here is to use the CC26X2R1 as a reference to help you get started in your project.