How to create BLE project with KW36?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create BLE project with KW36?

2,540 Views
chintan
Contributor III

Hello,

I am new to using the KW36 MCU and want to create a project with BLE support. I have refer the examples of bluetooth from its SDK, but it's all related to OSA task. And also the size of the output file is more as per my requirement. I did not getting idea how to create it.

I want to create a project without using OSA task. Kindly guide me how to create the simple BLE project with KW36 MCU?

Thank you.

Labels (1)
Tags (4)
14 Replies

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan, I hope you're doing well!

 

While it is possible to use the BLE stack without an OS Abstraction Layer, we do not recommend following this development path, and we do not support this implementation.

 

I'm sorry for the inconveniences this may cause.

 

Still, I recommend taking a look at the BLE Application Developer's User Guide, and the provided BLE Bare Metal examples included in the SDK. It's important to note, however, that even the bare metal examples use OS Abstraction.

 

Path to BLE Application Developer's User Guide:

<…\SDK_2.2.1_FRDM-KW36\docs\wireless\Bluetooth\Bluetooth Low Energy Application Developer's Guide.pdf>

Path to BLE examples:

<…\SDK_2.2.1_FRDM-KW36\boards\frdmkw36\wireless_examples\bluetooth>

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Yes fine and hope you are doing well!

Thanks for reply.

Yes, we have gone through the document before asking this question. But it also guiding to make project with OSA layer.

Why do you not recommend  to use BLE stack without OS Abstraction layer? What are the drawbacks for the same?

Is there any way to reduce the size of the project with OSA layer? The output file size is much larger than the average  flash size of the micro-controller.

Thank you.

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

Our BLE stack is pre-certified, meaning that, if no changes are made to the stack itself, it doesn't have to go through the certification process again. If the OS Abstraction layer is removed, you'd need to make some considerable changes to the stack itself, losing the pre-certification in the process.

 

Because of the strict timing constraints that the BLE specification establishes, as well as task management and configurations, it is strongly encouraged that, when implementing the BLE stack into a project, some kind of OS Abstraction layer is implemented as well.

 

To help reduce the stack's footprint on memory, there are some steps that could be followed instead of removing the OS Abstraction layer. Depending on your application, you could remove the peripheral or central device type libraries from your code. You could also try optimizing the individual source files of your application.

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for reply.

I tried to reduce the size of output file by removing the peripheral type libraries but it will not affecting on the size of file. Currently I am working on BLE Beacon example project.The (.bin) file size of the project is showing 510 KB after building the first time. Then I removed the peripherals for I2C, LPUART and also removed framework of Keyboard and LED and then again build the same project. Still it shows the 510 KB size of (.bin) file. After removing this peripherals and frameworks code is working properly and I can also observe the Beacon on IOT application without LED indication.

In my project I want to use the CAN, BLE, SPI peripherals. If current file is 510 KB and I will add the code for CAN module it will goes to more than 512 KB which will more than the flash size.

Kindly guide that how can I reduce the file size of the output file.

Thank you.

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

Could you please take a look at section 9.8 of the Bluetooth Low Energy Application Developer's Guide to see if you successfully configured the use of the alternative libraries instead of the combined Central and Peripheral Host Stack library?

 

If it still doesn't reduce the size of your output file, could you please try optimizing your individual application source files? If you're using MCUXpresso, you can choose the optimization level for your source files by right clicking the file in the project explorer, opening the file's properties, going into the Build Settings, and changing the optimization level.

 

It's important to note, however, that only your application files can be optimized, as, if other BLE files are optimized, it could interfere with the BLE functions.

 

Please let me know if you still have issues reducing the size of your output file.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for reply.

Yes, I go through the Section 9.8 of Bluetooth Low Energy Application Developer's Guide and found only Peripheral Host library is used in our application. After this I build the project again and it showing the same as size as 510 KB.

Then, I changed the Optimization level of the application source file (beacon.c and beacon.h). But no change in the size of output file.

For your information, I am using MCUXpresso IDE and Creating the SDK example of Beacon project by click on Import SDK example. I am also attaching the images which shows the included library files and Optimization level while Debug or Release.

Library.JPG

                                                            Library Settings

OptimizationWhileDebug.JPG

                                                   Optimization Level While Debug

OptimizationWhileRelease.JPG                                                   Optimization Level While Release

I tried by Excluding the unwanted files/folder from Peripheral and Framework folder. But it will not affect on size.

Then I tried by Deleting the unwanted files/folder from Peripheral and Framework folder. But still it will not affect on size.

Kindly guide what am I missing in removing process to reduce the size.

Thank you.

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

The Bluetooth Low Energy Release Notes document included with the KW36Z's SDK has memory footprint information for all of the included examples. For reference, here is the footprint information for the BLE Beacon example:

 pastedImage_2.png

The path for the document is:

 

<…\SDK_2.2.1_FRDM-KW36\docs\wireless\Bluetooth\Bluetooth Low Energy Release Notes.pdf>

 

Could you please take a look at this application note showing how to add CAN or LIN functionality to a Bluetooth Low Energy example? It uses the Wireless UART example, which has the largest memory footprint of any of the BLE examples.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for reply.

Up till now we are looking at (.bin) file size which is not changing. But when we look at (.axf) file size, it is changed compared to Original example code.

Original Example Code (.axf) file size: 1362 KB

Modified Example Code (.axf) file size: 1323 KB

So, which file should we consider as Output file, which will go into flash?

We checked the Build log in IDE and found below changes:

For Original Example Code:

Original Code File Size.JPG

For Modified Example Code:

Modified Code File Size.JPG

Kindly also suggest how much Flash size will be used by code?

The document you suggested to look at is for RTOS application and we are using the baremetal example code. So, is there any difference in file size between that?

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

Please consider the size that MCUXpresso reports after building your project as the actual space in flash that will be used by your program.

 

For example:

 pastedImage_1.png

 

Here, 199.384 kB are being used, out of the available 494kB of the available PROGRAM_FLASH memory region. This results in a usage of only 39.42% of the available program flash.

 

The Release Notes document only shows the memory footprint of FreeRTOS example projects.

 

Please let me know if you have any further questions.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for your reply.

I understand that the size displayed by MCUXpresso IDE after building the project is the actual size of program code. But please let me know which file should we consider as Output file (.axf or .bin) that going into Flash?

Let me explain you more.

I use the  FRDM-KW36 EVM module for my project. I created the code and uploaded into the evm module. Then I give the EVM module to my colleague. Now, I update the code and want to share it with my colleague to whom I given the EVM module. I don't want to share whole project folder. So, which file should I give to him? Is it .axf file or .bin file?

  • The thing is, after changing and building the project code, flash size is going to decrease then why it is not affecting the .bin file?
  • What is the use of .bin file?
  • How it is generated?

Another point is we only want to make code which will use up to 250 KB of flash size. 

Thank you.

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

The binary files generated by MCUXpresso for the KW36Z (specifically, for BLE projects and examples) are always the full 510kB in size, as to overwrite the whole PROGRAM_FLASH memory region, even filling the unused space with a "0xFF" value.

This is done on purpose, so old code is not left behind in unused memory regions of the PROGRAM_FLASH.

 

If you want to share firmware without sharing the whole project, it's recommended that you share the generated .bin file, as it is an industry-standard way to share programmable firmware for these kinds of devices without providing source code. These files can be used with software like J-Link Commander to program other KW36Z devices.

 

The most straight-forward way to generate a binary file using MCUXpresso is by building a project, looking for your .axf file (Generally in the "Debug" folder of your project), right clicking and choosing the "Binary Utilities" option, and clicking "Create binary".

 

Please let me know if you have any other questions.

 

Best regards,

Sebastian

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for your replay and all your efforts.

We got your points and understand that the .bin file is the actual output file.

Up till now I removed the unwanted library files from the project and I reached up to 179 KB Flash size with OSA stack. One thing I want to ask, when we look at the build logs in MCUXpresso IDE after building the project, it shows that 16 KB memory is allocated and used in NVM region. Should I join that into Program Flash region? Because we want another Flash partition (FlexNVM) to be used as backup firmware.

Thank you.

0 Kudos

1,940 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Chintan,

 

We have some documentation that might be able to help you in changing the NVM region of the KW36Z's memory map.

 

 

Could you please take a look at them?

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

 

0 Kudos

1,940 Views
chintan
Contributor III

Hello Sebastian,

Thanks for your reply.

I have tried myself to accommodate the code in 256KB flash partition (P-Flash) and successfully done. The code is complied without any error and it works properly as original example code. I partition the code as per below:

Program Flash: 254KB

FreeScale_Prod_Data: 2KB

NVM_Region: 256KB

Thanks again for your all efforts.