PAN1026 SDK without RTOS

Hi,

I want to create a SDK for PAN1026 without RTOS. This should be used for the microcontrollers with less memory.

Could you please guide me in the right direction?

8replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Are you looking forward to use both Bluetooth Classic and Bluetooth Low Energy?

    The Toshiba Bluetooth SDK for PAN1026 contains everything that is needed to make use of both the Bluetooth Classic and Bluetooth Low Energy features in a single application.

    It can be used on controllers with an operating system or in a microcontroller configuration without any operating system ("bare metal").

    Naturally the Bluetooth SDK consumes memory and processing power on the host processor.

    But in my opinion there is nothing you can do about it.

    Even if you start with a small re-implementation of the features that are used for one specific use-case. If you later add more code for other use-cases the re-implementation will grow in size until it reaches the implementation of the Bluetooth SDK. At that point nothing is gained any more.

     

    If you are looking for a significantly reduced memory consumption on the microcontroller and do not need Bluetooth Classic, then using a module like PAN1760A is the solution.

    It allows to run all Bluetooth processing directly on the module ("standalone mode") and the UART is used for custom communication between the microcontroller and the application running on the module.

    The trade off is that you need to develop a custom firmware for the PAN1760A, instead of working with your microcontroller alone.

    Reply Like
  • Thank you Michael for quick and detailed response.

    1. The Toshiba Bluetooth SDK for PAN1026 has all example projects with RTOS. The example projects are only using 1 task to perform its Bluetooth functionality. So we can definitely make a bare metal code out of it. But SDK also have a lot of code related to events. I believe these events would be generated by RTOS scheduler. I want to avoid all the code related to RTOS scheduler. I also read your response related to other PAN10126 posts. You have mentioned a document "software_manual_for_system_integration.pdf" to write a OS free code for Toshiba Bluetooth stack. Could you please share a link for this document?

    2. The SDK does not have any example code without OS. Although, it does have dummy projects which is without OS but I would be required to implement all the stub functions. I would really appreciate, If you can share an basic example code for PAN1026 without OS.

    3. As you mentioned, "It can be used on controllers with an operating system or in a microcontroller configuration without any operating system ("bare metal")."

    Could you please refer me a document to configure SDK for bare metal?

    I hope my understanding in point 1 is correct.

     

    Also, Could you please tell me the maximum memory usage by SDK with a bare simple application.

    1. with BT

    2. with BTE.

    3. with both feature enabled.

    Reply Like
  • But SDK also have a lot of code related to events. I believe these events would be generated by RTOS scheduler. I want to avoid all the code related to RTOS scheduler.

    The RTOS events and queues are used to transfer data or information from the interrupt handlers to the processing main loop.

    For example, the UART interrupt handler collects all bytes that are received and puts them into a receive queue for later processing.

    Handling the UART in the processing main loop is usually not feasible, because there is a high risk of losing data.

    Even when you run bare metal, you need some mechanism to forward data or information from interrupt handlers to the processing main loop, for example an interrupt-safe ringbuffer implementation.

    The Bluetooth SDK does not make any assumption how you handle this at all. Only the sample code is structured in such a way to make use of the RTOS features. You are free to do it differently.

    You have mentioned a document "software_manual_for_system_integration.pdf" to write a OS free code for Toshiba Bluetooth stack. Could you please share a link for this document?

    This document has been merged into the main documentation bluetooth_sdk_developers_guide_v3_4_1.pdf under chapter 7 Bluetooth Driver Integration & Porting

    Reply Like
  • The SDK does not have any example code without OS. Although, it does have dummy projects which is without OS but I would be required to implement all the stub functions. I would really appreciate, If you can share an basic example code for PAN1026 without OS

    The integration heavily depends on the platform, for example the host processor that is chosen. So it is basically impossible to provide a generic non-os sample project for PAN1026 that is actually working to some extend.

    As explained in chapter 7 Bluetooth Driver Integration & Porting the way to go is to include all necessary Bluetooth SDK files and all stub functions first, and then make the project compile & link again.

    Afterwards the data transmission / UART stub functions have to be implemented and the module initialisation can be done already.

    I have done this for both OS and non-OS platforms already and confirm that this approach is working.

    Reply Like
  • As you mentioned, "It can be used on controllers with an operating system or in a microcontroller configuration without any operating system ("bare metal")."

    Could you please refer me a document to configure SDK for bare metal?

    As explained in the previous post, the Bluetooth SDK does not rely on an OS. All porting is done via the porting layers which are provided as stub functions.

    The bluetooth_sdk_developers_guide_v3_4_1.pdf explains which files to use in a textual form, but it is easier to open one of the sample projects within IAR that fits your use-case and extract all the included C files from there.

    Also, Could you please tell me the maximum memory usage by SDK with a bare simple application.

    1. with BT

    2. with BTE.

    3. with both feature enabled.

    This heavily depends on the microcontroller you are using. For a standard Cortex-M3 microcontroller the Bluetooth SDK consumes about 25-35kB with both features enabled.

    You can reduce the memory usage for BT-only and BLE-only a little bit, but this needs time and effort.

    Reply Like
  • Michael Hunold 

    Hi Michael,

    Thank you for the quick response to the my last post.

    I am in process of porting Toshiba Bluetooth stack without RTOS for one of the Panasonic 8-bit controller with 64K ROM and 4K RAM. This controller does not support freeRTOS.

    Michael Hunold said:
    As explained in chapter 7 Bluetooth Driver Integration & Porting the way to go is to include all necessary Bluetooth SDK files and all stub functions first, and then make the project compile & link again.

     I am following chapter 7 for porting to new controller. However, I am facing issues like:

    1. For SPP communication, we need to implement stub function for unexpected events. As I am not using RTOS and heap memory being less, I cannot dynamically create buffer for storing unexpected events. I believe the maximum size for an unexpected events is appox. 500bytes. The demo example can support up to 16 unexpected events. So as a solution to this I thought of creating a static buffer for only 1 unexpected event of size 500bytes and support only 1 unexpected event.

      Could you please confirm if my understanding is correct and please suggest it this can be done in a better way?

    2. For timer start and stop stub functions, I am supposed to create timer Handler using RTOS and when this timer expires I am supposed to add the function associated with timer to a queue that will be called from the main function.

    Could you guide me a solution for this activity without using RTOS and dynamic memory allocation?

    Reply Like
  • 1. For SPP communication, we need to implement stub function for unexpected events. As I am not using RTOS and heap memory being less, I cannot dynamically create buffer for storing unexpected events. I believe the maximum size for an unexpected events is appox. 500bytes. The demo example can support up to 16 unexpected events. So as a solution to this I thought of creating a static buffer for only 1 unexpected event of size 500bytes and support only 1 unexpected event.

      Could you please confirm if my understanding is correct and please suggest it this can be done in a better way?

    The firmware of PAN1026 works asynchronously. When a request is sent, it can happen that an unrelated or unexpected event is returned before the response comes. The application must be able to store this event and process later.

    Because Bluetooth BR SPP only supports one connection at a time, the simple unexpected event mechanism is used. The application can simply store the unexpected events and later inject them in the main loop again.

    16 unexpected events is probably too high, because so many operations can not be ongoing that may create unexpected events. The most likely cause for an unexpected event is a sudden disconnect event or sniff / subrating events, but can also be a data receive event. This is why each buffer for one event must be 543 + 16 bytes, because 543 is the maximum length of data that can be transferred.

    The problem is that when you miss an important event like a disconnect event, then your application logic gets screwed up.

    So the recommendation is to have enough buffers for unexpected events and I suggest to have at least 2.

    Furthermore, whenever you receive an additional unexpected event and cannot store it any more, your application needs to be aware that this might screw up the application logic in the Bluetooth SDK. You will then have to find a suitable action, for example, to disconnect the connection and start again.

    However, please be aware that the Bluetooth LE part of the Bluetooth SDK has some memory requirements as well.

    The unexpected event handling for Bluetooth LE is completely done within the Bluetooth SDK. It is more complicated, because for devices like PAN1760A multiple connections may be open and unexpected events can happen on any of them.

    Please carefully check struct tcu_gap_buffer tcu_gap_buff in tcu_internal.c and all other static allocations in that file.

    Even though for PAN1026 MAX_BUFFER_SIZE_BLE is 132 and the maximum number of connections is 1, the amount of data that is allocated there may be huge.

    In any case 4kB of RAM is a very tough requirement for the Bluetooth SDK to fit into.

    2. For timer start and stop stub functions, I am supposed to create timer Handler using RTOS and when this timer expires I am supposed to add the function associated with timer to a queue that will be called from the main function.

    Could you guide me a solution for this activity without using RTOS and dynamic memory allocation?

    You don't need dynamic memory allocation for timers, they just make things easier.

    A common solution is to implement a simple ringbuffer or linked list which can hold enough timers, for example 16. This can use a static allocation.

    Whenever a timer is set, add a new timer with the expire time to the ringbuffer or linked list.

    Whenever your main loop is executed and a timer tick has passed, go through the elements in the ringbuffer and decrease the expiry time by the amount of time that has passed.

    Whenever a expiry time drops to 0, execute the callback function that is attached to the timer.

    Reply Like
  • Shivam Gupta said:
    t he demo example can support up to 16 unexpected events. So as a solution to this I thought of creating a static buffer for only 1 unexpected event of size 500bytes and support only 1 unexpected event.

    Could you please confirm if my understanding is correct and please suggest it this can be done in a better way?

    2. For timer start and stop stub functions, I am supposed to create timer Handler using RTOS and when this timer expires I am supposed to add the function associated with timer to a queue that will be called from the main function.

    Could you guide me a solution

     

    The Toshiba Bluetooth SDK for PAN1026 includes everything this is wished to utilize each the Bluetooth traditional and Bluetooth Low electricity features in a single utility.

    it can be used on controllers with an working system or in a microcontroller configuration without any operating gadget ("bare metal").

    clearly the Bluetooth SDK consumes reminiscence and processing energy on the host processor.

    Reply Like
reply to topic
Like Follow
  • Status Answered
  • 8 days agoLast active
  • 8Replies
  • 143Views
  • 5 Following