This document provides guidance to load a new software image in a KW35 device through OTAP (Over The Air Programming) bootloader for KW35. This article also provides the steps needed to download and install the SDK used in the tutorial.
MKW35A512xxx4 device.
The KW35 Flash is partitioned into:
The statements to comprehend how the OTAP Client software and his features works are:
The OTAP Client software is split into two parts, the OTAP bootloader and the OTAP client service. The OTAP bootloader verifies if there is a new image already available to reprogram the device. The OTAP client service software provides the Bluetooth LE custom services needed to communicate with the server that contains the new image file. Therefore, before to start the test, the device has been programmed twice, first with the OTAP bootloader then with the OTAP client service project. The mechanism used to have two different software in the same device is to store each one in different memory regions and this is implemented by the linker file. In the KW35 device, the bootloader application has reserved a 16KB slot of memory starting from the 0x0 address (0x0 to 0x3FFF) thus, the left memory of the first P-Flash memory bank is reserved, among other things, by the OTAP client service application.
To create a new image file for the client device, the developer needs to specify to the linker file that the code will be stored with an offset of 16KB since the first addresses are reserved for the bootloader.
At connection event, the server sends all the chunks of code to the client via Bluetooth LE. The client stores the code at the second P-Flash memory bank but is not able to run yet.
When the broadcast has finished, and all chunks were sent, the OTAP bootloader detects this situation and triggers a command to reprogram the device with the new application. Due the new application was built with an offset of 16KB, the OTAP bootloader program the device starting from the 0x3FFF address and the OTAP client service application is overwritten by the new image. Then the OTAP bootloader triggers the new application, starting the execution of the code.
Go to MCUXpresso web page.
Log in with your registered account.
Search for “MKW36A” device. Then click on the suggested processor and click on “Build MCUXpresso SDK”
The next page is displayed. Select “All toolchains” in the “Toolchain / IDE” combo box and provide the name to identify the package.
Click on “Add software component”, then deploy the combo box and click on “Select All” option. Save the changes.
Click on “Download SDK” button and accept the license agreement.
If MCUXpresso IDE is used, drag and drop the SDK zip folder in “Installed SDK’s” perspective to install the package.
This section provides the steps needed to test the OTAP software on the KW35.
Program the OTAP bootloader on the KW35.
1.1 Open the OTAP_bootloader project located at the following path:<SDK_download_root>\boards\virtual-board-kw35\wireless_examples\framework\bootloader_otap\bm\iar\bootloader_otap_bm.eww
1.2 Flash the project (Ctrl + D). Stop the debug session (Ctrl + Shift + D).
Program the OTAP client application on the KW35.
2.1 Open the OTAP client project located in the path below.
<SDK_download_root>\boards\frdmkw36\wireless_examples\bluetooth\otac_att\freertos\iar\otac_att_freertos.eww
2.2 Follow the steps 2 to 12 described in the “4.1. Changes Required in Project Options and Settings” section of the AN12252 “Migration Guide from MKW36Z512xxx4 to MKW35Z512xxx4” application note.
2.3 Open the app_preinclude.h file under the source directory in the workspace. Find the “gEepromType_d” definition and update the value to “gEepromDevice_InternalFlash_c” as shown below.
#define gEepromType_d gEepromDevice_InternalFlash_c
2.4 Save the MKW35Z512xxx4_connectivity.icf file located at:
<SDK_download_root>\middleware\wireless\framework_5.4.4\Common\devices\MKW35Z4\iar
Into the folder of the OTAP Client ATT project:
<SDK_download_root>\boards\frdmkw36\wireless_examples\bluetooth\otac_att\freertos\iar
2.5 Open the project options window (Alt+F7). In Linker/Config window click the icon next to linker path and select the linker configuration file “MKW35Z512xxx4_connectivity.icf”. Set the "gUseInternalStorageLink_d” flag to 1.
2.6 Click the OK button in the project options window to save the new configuration.
2.7 Flash the project (Ctrl + D). Stop the debug session (Ctrl + Shift + D).
This section provides the steps needed to test the OTAP software on the KW35.
1.1 Open MCUXpresso IDE. Click on “Import SDK example(s)” option in the “Quickstart Panel” view.
1.2 Click on virtual-board-kw35 SDK icon. 1.3 Deploy the wireless_examples\framework\bootloader_otap folders and select bm project. Click Finish button. 1.4 Select “Debug” option in the Quickstart Panel. Once the project is already loaded on the device, stop the debug session.
2. Program the OTAP client application on the KW35.
2.1 Open MCUXpresso IDE. Click on “Import SDK example(s)” option in the “Quickstart Panel” view.
2.2 Click twice on the frdmkw36 icon. 2.3 Type “otac_att” in the examples textbox and select the freertos project at wireless_examples\bluetooth\otac_att\freertos. Finally, click on Finish button.
2.4 Follow the steps 5 to 17 described in the “5.1. Changes Required in Project Options and Settings” section of the AN12252 “Migration Guide from MKW36Z512xxx4 to MKW35Z512xxx4” application note.
2.5. Open the app_preinclude.h file under the source directory in the workspace. Find the “gEepromType_d” definition and update the value to “gEepromDevice_InternalFlash_c” as shown below.
#define gEepromType_d gEepromDevice_InternalFlash_c
2.6 Save the MKW35Z512xxx4_connectivity.ld file located at:
<SDK_download_root>\middleware\wireless\framework_5.4.4\Common\devices\MKW35Z4\gcc
Into the source folder in the workspace.
2.7 Open the Project/Properties window. Next, go to the MCU Linker/Managed Linker Script perspective and edit the Linker Script name to “MKW35Z512xxx4_connectivity.ld”.
2.8 Go to MCU Linker/Miscellaneous view. Press the icon below, a new window will be deployed. Add the following definition in the “Other options” box: --defsym=gUseInternalStorageLink_d=1.
2.9 Click the “Apply and Close” button in the project options window to save the new configuration.
2.10 Select “Debug” option in the Quickstart Panel. Once the project is already loaded on the device, stop the debug session.
Open the IoT Toolbox App and select OTAP demo. Press “SCAN” to start scanning for a suitable advertiser.
Perform a falling edge on the PTB18 in the KW35 to start advertising.
Create a connection with the founded device.
Press “Open” and search the S-Record file.
Press “Upload” to start the transfer.
Once the transfer is complete, wait a few seconds until the bootloader has finished programming the new image. The new application will start automatically.
Open the connectivity project that you want to program using the OTAP bootloader from your SDK. This example will make use of the glucose sensor project.
<SDK_download_root>\boards\frdmkw36\wireless_examples\bluetooth\glucose_s\freertos\iar\glucose_s_freertos.ewwFollow the steps 2 to 12 described in the “4.1. Changes Required in Project Options and Settings” section of the AN12252 “Migration Guide from MKW36Z512xxx4 to MKW35Z512xxx4” application note.
Save the MKW35Z512xxx4_connectivity.icf file located at:
<SDK_download_root>\middleware\wireless\framework_5.4.4\Common\devices\MKW35Z4\iar
In the containing folder of your project.
<SDK_download_root>\boards\frdmkw36\wireless_examples\bluetooth\glucose_s\freertos\iar
Open the project options window (Alt+F7). In Linker/Config window click the icon next to linker path and select the linker configuration file MKW35Z512xxx4_connectivity.icf. Then, enable “gUseBootloaderLink_d” macro in the “Configuration file symbol definitions” textbox.
Go to the “Output Converter” window. Deselect the “Override default" checkbox, expand the “Output format” combo box and select Motorola S-records format. Click OK button.
Rebuild the project.
Search the S-Record file in the following path:
<SDK_download_root>\boards\frdmkw36\wireless_examples\bluetooth\glucose_s\freertos\iar\debug
Open the connectivity project that you want to program using the OTAP bootloader from MCUXpresso IDE This example will make use of the glucose sensor project
Save the MKW35Z512xxx4_connectivity.ld file located at:
<SDK_download_root>\middleware\wireless\framework_5.4.4\Common\devices\MKW35Z4\gcc
Into the source folder in the workspace.
Open the Project/Properties window. Next, go to the MCU Linker/Managed Linker Script perspective and edit the Linker Script name to “MKW35Z512xxx4_connectivity.ld”.
Go to MCU Linker/Miscellaneous view. Press the icon below, a new window will be deployed. Add the following definition in the “Other options” box: --defsym=gUseBootloaderLink_d=1. Click the “Apply and Close” button.
Build the project.
Deploy the “Binaries” icon in the workspace. Click the right mouse button on the “.axf” file. Select “Binary Utilities/Create S-Record” option. The S-Record file will be saved at “Debug” folder in the workspace with “.s19” extension.