Introduction
This document guides to load a new software image in a KW41 device through Over The Air Programming bootloader. Also, are explained the details of how to set up the client software to change the storage method of the image.
Software Requirements
Hardware Requirements
OTAP Memory Management During the Update Process
The KW41 has a 512KB Program Flash with a flash address range from 0x0000_0000 to 0x0007_FFFF.
Preparing the Software to Test the OTAP Client for KW41Z Device Using IAR Embedded Workbench
OTAP Bootloader Project:
<SDK_2.2.0_FRDM-KW41Z_download_path>\boards\frdmkw41z\wireless_examples\framework\bootloader_otap\bm\iar\bootloader_otap_bm.eww
OTAP Bootloader pre-built binary:
<SDK_2.2.0_FRDM-KW41Z_download_path>\tools\wireless\binaries\bootloader_otap_frdmkw41z.bin
<SDK_2.2.0_FRDM-KW41Z_download_path>\boards\frdmkw41z\wireless_examples\bluetooth\otap_client_att\freertos\iar\otap_client_att_freertos.eww
Preparing the Software to Test the OTAP Client for KW41Z Device Using MCUXpresso IDE
OTAP Bootloader Project:
wireless_examples->framework->bootloader_otap->bm
OTAP Bootloader pre-built binary:
<SDK_2.2.0_FRDM-KW41Z_download_path>\tools\wireless\binaries\bootloader_otap_frdmkw41z.bin
Linker file at the SDK USB-KW41Z:
<SDK_2.2.0_USB-KW41Z_download_path>\boards\usbkw41z_kw41z\wireless_examples\bluetooth\otap_client_att\freertos\MKW41Z512xxx4_connectivity.ld
Creating an S-Record Image File for FRDM-KW41Z OTAP Client in IAR Embedded Workbench
Open the connectivity project that you want to program using the OTAP Bootloader from your SDK FRDM-KW41Z. This example will make use of the glucose sensor project, this is located at the following path.
<SDK_2.2.0_FRDM-KW41Z_download_path>\boards\frdmkw41z\wireless_examples\bluetooth\glucose_sensor\freertos\iar\glucose_sensor_freertos.eww
gUseBootloaderLink_d=1
Creating an S-Record Image File for FRDM-KW41Z OTAP Client in MCUXpresso IDE
wireless_examples->bluetooth->glucose_sensor->freertos
Linker file at the SDK FRDM-KW41Z:
<SDK_2.2.0_FRDM-KW41Z_download_path>\boards\frdmkw41z\wireless_examples\bluetooth\otap_client_att\freertos\MKW41Z512xxx4_connectivity.ld
Testing OTAP Client Demo Using IoT Toolbox App
Hi,
I'm porting the OTOP client example into my HRS modified program.
Compilation seems to passe now, but i have an error during Linking step.
Invoking: MCU Linker
arm-none-eabi-gcc -L"D:\OTS\Firmware\prototm\libs" -Xlinker -Map="OTS_v1.map" -Xlinker --gc-sections -Xlinker -print-memory-usage -mcpu=cortex-m0 -mthumb -T MKW41Z512xxx4_connectivity.ld -L ../source -o "OTS_v1.axf" ./utilities/fsl_debug_console.o ./startup/startup_MKW41Z4.o ./source/common/gatt_db/gatt_database.o ./source/common/ApplMain.o ./source/common/ble_conn_manager.o ./source/common/ble_controller_task.o ./source/common/ble_host_tasks.o ./source/common/ble_init.o ./source/app_config.o ./source/global.o ./source/heart_rate_sensor.o ./source/i2cGPIO.o ./source/mlx90621.o ./source/mlx91804.o ./source/mtb.o ./source/semihost_hardfault.o ./freertos/croutine.o ./freertos/event_groups.o ./freertos/fsl_tickless_lptmr.o ./freertos/fsl_tickless_systick.o ./freertos/heap_4.o ./freertos/list.o ./freertos/port.o ./freertos/queue.o ./freertos/tasks.o ./freertos/timers.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_ant_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_ble_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_common_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p3_h_0p5_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p32_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p5_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_0p7_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p5_h_1p0_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_gfsk_bt_0p7_h_0p5_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_mode_datarate_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_msk_config.o ./framework/XCVR/MKW41Z4/cfgs_kw4x_3x_2x/fsl_xcvr_zgbe_config.o ./framework/XCVR/MKW41Z4/dbg_ram_capture.o ./framework/XCVR/MKW41Z4/fsl_xcvr.o ./framework/XCVR/MKW41Z4/fsl_xcvr_trim.o ./framework/XCVR/MKW41Z4/ifr_radio.o ./framework/TimersManager/Source/TMR_Adapter.o ./framework/TimersManager/Source/TimersManager.o ./framework/SerialManager/Source/UART_Adapter/UART_Adapter.o ./framework/SerialManager/Source/SPI_Adapter/SPI_Adapter.o ./framework/SerialManager/Source/I2C_Adapter/I2C_Adapter.o ./framework/SerialManager/Source/SerialManager.o ./framework/SecLib/SecLib.o ./framework/Reset/Reset.o ./framework/RNG/Source/RNG.o ./framework/Panic/Source/Panic.o ./framework/OtaSupport/Source/OtaSupport.o ./framework/OSAbstraction/Source/fsl_os_abstraction_free_rtos.o ./framework/NVM/Source/NV_Flash.o ./framework/NVM/Source/NV_FsciCommands.o ./framework/ModuleInfo/ModuleInfo.o ./framework/Messaging/Source/Messaging.o ./framework/MemManager/Source/MemManager.o ./framework/MWSCoexistence/Source/MWS.o ./framework/LowPower/Source/MKW41Z/PWR.o ./framework/LowPower/Source/MKW41Z/PWRLib.o ./framework/LowPower/Source/MKW41Z/PWR_BLE.o ./framework/Lists/GenericList.o ./framework/LED/Source/LED.o ./framework/Keyboard/Source/Keyboard.o ./framework/GPIO/GPIO_Adapter.o ./framework/FunctionLib/FunctionLib.o ./framework/Flash/Internal/Flash_Adapter.o ./framework/Flash/External/Source/Eeprom_AT26DF081A.o ./framework/Flash/External/Source/Eeprom_AT45DB021E.o ./framework/Flash/External/Source/Eeprom_AT45DB041E.o ./framework/Flash/External/Source/Eeprom_AT45DB161E.o ./framework/Flash/External/Source/Eeprom_InternalFlash.o ./framework/DCDC/Source/DCDC.o ./drivers/fsl_adc16.o ./drivers/fsl_clock.o ./drivers/fsl_common.o ./drivers/fsl_dspi.o ./drivers/fsl_dspi_freertos.o ./drivers/fsl_flash.o ./drivers/fsl_gpio.o ./drivers/fsl_i2c.o ./drivers/fsl_i2c_freertos.o ./drivers/fsl_llwu.o ./drivers/fsl_lptmr.o ./drivers/fsl_lpuart.o ./drivers/fsl_lpuart_freertos.o ./drivers/fsl_ltc.o ./drivers/fsl_pmc.o ./drivers/fsl_rtc.o ./drivers/fsl_smc.o ./drivers/fsl_tpm.o ./drivers/fsl_trng.o ./board/board.o ./board/clock_config.o ./board/gpio_pins.o ./board/peripherals.o ./board/pin_mux.o ./bluetooth/profiles/tpms/tpms_service.o ./bluetooth/profiles/otap/otap_service.o ./bluetooth/profiles/ircam/ircam_service.o ./bluetooth/profiles/heart_rate/heart_rate_service.o ./bluetooth/profiles/device_info/device_info_service.o ./bluetooth/profiles/battery/battery_service.o ./bluetooth/host/config/ble_globals.o ./bluetooth/hci_transport/source/hcit_serial_interface.o ./CMSIS/system_MKW41Z4.o -lm -lc -lgcc -lnosys -l_ble_kw41z_controller -l_ble_4-2_host_peripheral_cm0p -l_crypto_m0
Memory region Used Size Region Size %age Used
Bootloader_region: 0 GB 16383 B 0.00%
TEXT_region1: 192 B 192 B 100.00%
BootFlags_region: 4 B 7 B 57.14%
TEXT_region2: 206644 B 239416 B 86.31%
InternalStorage: 0 GB 258047 B 0.00%
NVM_region: 0 GB 8191 B 0.00%
DATA_region: 33304 B 128 KB 25.41%
c:/nxp/mcuxpressoide_11.0.0_2516/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.0.0.201905131304/tools/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe: section .dummy VMA [1ffffffb,20000002] overlaps section .stack VMA [1ffffe18,20000217]
collect2.exe: error: ld returned 1 exit status
PRODUCT_INFO_region: 0 GB 2047 B 0.00%
make: *** [makefile:75: OTS_v1.axf] Error 1
"make -r -j12 all" terminated with exit code 2. Build might be incomplete.17:13:22 Build Failed. 2 errors, 13 warnings. (took 8s.618ms)
I followed the tutorial by using the .ld files from SDK USB-KW41Z.
My programe was a bit too big : 105% of the 512/2 -16 Ko of bootloader. So i had to enable the compilation optimisation option "for size". I don' t think it can have an impact but i give this input in case of ....
What is this dummy partition it point for please ?
Is there a workaround to solve the issue please ?
I removed the dummy section and it build and link too. But when i run in Debug mode the program can not start and doesn' go till the Hardware first init breakpoint.
dummy __dummy_start :
{
. += 8;
} =0x90909090
I laso notice that inb your tutorial, gEepromType_d sould be in app_preinclude.h header file but for me it is in board.h in sdk.
I tried to check to change ld file in otap client example by the one in usb sdk and change gEepromType_d for internal storage, there is also error at linking step with bootlader section this time.
What are the step the properly migrate source code from otap client into hrs example for example please? i did by colmparing the two projects and incorporing line by line from otap client to hrs. It build but there is probleme with linking step. I regret that it is the own step missing for my project to be complete.
Thanks for support, i'm a bit stuck here :smileyhappy:
Hello florian.lebrun59@gmail.com,
Could you please confirm which version of SDK do you have? You can verify it in the installed SDKs perspective in MCUXpresso IDE (or simply you can go to https://mcuxpresso.nxp.com/en/dashboard and check for updates).
We recommend to download and install the newest SDK package (SDK 2.2.1) to discard some issues related to version compatibility. My suspect is that you have older software due DATA_region linker section does not match with the new release that splits this section into two parts: DATA1_region and DATA2_region. Did you modify the linker file to create this section?.
We are already working on release an application note explaining the details of OTAP integration on the HRS demo for FRDM-KW36. I will inform you in a few weeks when we planned to release the document.
Best regards.
Hi nxf46726,
Thanks for your help.
Sdk version is at the moment 2.2.0
Thanks for writting the tutorial.
1. Do you have an idea if it will be done? for this month or next one may be ? Just to organize my self and see if i can progress anyway.
What i did was to merge OTAP example into HRS : file missing, add the Timer callback and pieces of code here and there . It build but not linked with USB ld file
2. Do you advise to start from hrs and import otap code into it or start from otap nd move hrs into it ?
I have compared otap client demo code from sdk 2.2.0 and 2.2.1. I see some correction on complete transfert flag etc so yes , it will be better to restart from sdk 2.2.1 it seems.
3. Why should we use the USB ld file and not the OTAP client for internal flash memory ota ?
I really look forword your nice tutorial to do this properly.
Thank you so much
Hello florian.lebrun59@gmail.com,
1. The application note will be released around half of the next month.
2. The best way to integrate OTAP is first basing on your application and then include the OTAP service on it. In other words, using the HRS as a starting point and then integrate the OTAP into it. This is done in this way because if in the future you need to integrate OTAP on another application, for example, the Glucose Sensor, the steps required are similar (probably, the same steps).
3. The linker file decides how the code must be stored on the device, also, it has the ability to reserve slots of memory for other purposes, in this case, we need to reserve a section for internal storage. The USB-KW41 board does not have an external flash, instead, it uses the internal storage method as default, so, the USB-KW41 linker already contains the proper linker memory sections for internal storage enablement. We recommend to use it because is the easiest and fastest way to get the example working (which is the purpose of this document), another way, the programmer would edit and customize the linker file to reserve the memory slot needed.
Regards.
Ok 100% clear,
I will then update all my tools and put OTA into HRS, then if all works fine, integrated my code into it.
GO back to 0 :smileysad: lol.
Thanks a lot i hope i will succeed in it, worth case in one month i will be able to compare with your method.
Thanks a lot Edgar for your precious help.