1. Porting applications from SDK1 to SDK10

The scope of this document is to explain the steps needed for porting an application from:

  • SmartSnippets™ SDK1 running on DA1468x chipset, to

  • SmartSnippets™ SDK10 running on DA1469x chipset

The document is structured in two sections:

  • The first section highlights the hardware and software changes which need to be considered during porting

  • The second section provides a step by step guide for porting an example ble application (projects/dk_apps/demos/ble_adv)

NOTES:

  1. The example ble application is part of both SDK1 and SDK10 releases

  2. The starting point of the porting example is SDK 1.0.14.1081

1.1. Differences between the two SDK versions

1.1.1. Hardware block changes

The hardware block changes which need to be considered during porting are shown in Table 1 below:

Table 1 68x-69x Hardware changes

Hardware Block

DA1468x

DA1469x

Processor

M0 (single core)

M33, M0+, SNC (multi core)

XTAL Clock

16 / 32 MHz

32 MHz

BLE MAC

ROM

Configurable MAC

PDC

No

Yes

Fuel Gague - State of Charge

Yes

No

Timers

Timers 0, 1, 2 + Breath

Timers 0, 2, 3, 4 + RTC

Temperature Sensor

1

3

Input/Output ports

Port 0: 8 pins, Port 1: 8 pins, Port 2: 5 pins, Port 3: 8 pins, Port 4: 8 pins

Port 0: 32 pins, Port 1: 23 pins

Pad latching

Global

Per I/O

Keyboard Scanner

Yes

No

1.1.2. Software block changes

The software block changes which need to be considered during porting are shown in Table 2. More information on SDK10 software modules can be found in ([Ref_02]).

Table 2 68x-69x Software changes

Software Block

SDK1

SDK10

Adapters

Yes

A major change from the SDK1 to the SDK10 affecting a variety of applications is the refactoring of the peripheral adapters. Applications using peripheral devices over the interfaces I2C, UART, SPI and GPADC are largely affected. A careful reading of the relevant section about Adapters in the document DA1469x Software Platform Reference is recommended ([Ref_01])

Battery Adapter

Yes

No

Keyboard scanner adapter

Yes

No

Power Manager

Yes

API changes

NVMS parameters

All in one area block

Distinct blocks for platform and application parameters

1.1.3. SDK folder changes

The two SDK versions also differ in their folder structure. The most significant changes in the SDK10 folders are depicted in Table 3.

Table 3 Folder re-structuring

SDK1

SDK10

sdk/bsp/free_rtos

sdk/free_rtos

sdk/bsp/adapters

sdk/middleware/adapters

sdk/bsp/misc

[obsolete]

sdk/bsp/osal

sdk/middleware/osal

sdk/bsp/startup

sdk/bsp/startup/DA1469x

sdk/middleware/audio

[obsolete]

sdk/middleware/ble_net

[obsolete]

sdk/middleware/fw_upgrade

[obsolete]

sdk/middleware/ip_net

[obsolete]

sdk/middleware/security

[obsolete]

sdk/interfaces/ble

Introducing folders adapter, api, manager

sdk/interfaces/ble_clients

sdk/interfaces/ble/clients

sdk/interfaces/ble_ipsp

[obsolete]

sdk/interfaces/ble_services

sdk/interfaces/ble/services

sdk/interfaces/ble_stack (project)

sdk/interfaces/ble/stack (binaries)

sdk/interfaces/ftdf

[obsolete]

1.2. Example Porting - The ble_adv project

The porting steps fall into two categories (explained in detail in the following paragraphs):

  • Changes in project configuration files

  • Changes in project source code

The folder structure of the BLE Advertise application in SDK1 is shown below:

.
├── .cproject
├── .project
├── config
│   └── custom_config_qspi.h
├── main.c
└── makefile.targets

1.2.1. Project Properties - Configuration Changes

In the SmartSnippets™ IDE, various project properties need to be adapted in the porting procedure. The following changes or their corresponding variations are applicable to the various build configurations that are to be ported to SDK10. The titles of the chapters that follow refer to the menus in the SmartSnippets™ Project Properties (right-click on projects folder in the Project Explorer as shown in Figure 1).

_images/smartsnippets_project_properties.png

Figure 1 Select project properties

1.2.1.1. Resource/Linked Resources

Due to the re-structuring of the internal SDK folders, the project’s virtual folders may be invalid (Figure 2).

_images/smartsnippets_linked_resources_initial.png

Figure 2 Invalid locations in linked resources

Make sure that they are correctly linked again, using the Edit button on the right and changing the path accordingly. Necessary changes for the ble_adv example are:

  • FreeRTOS must be linked to SDKROOT/sdk/free_rtos instead of SDKROOT/sdk/bsp/free_rtos

  • adapters must be linked to SDKROOT/sdk/middleware/adapters instead of SDKROOT/sdk/bsp/adapters

  • osal must be linked to SDKROOT/sdk/middleware/osal instead of SDKROOT/sdk/bsp/osal

Folders that are no longer needed and can be deleted are:

  • misc

  • cpm

Some new virtual folders are also necessary:

  • middleware_config linked to SDKROOT/sdk/middleware/config

  • util linked to SDKROOT/sdk/bsp/util/

  • snc linked to SDKROOT/sdk/bsp/snc

  • sys_man linked to SDKROOT/sdk/bsp/system/sys_man

_images/smartsnippets_add_new_folder.png

Figure 3 Add new virtual folder

One way to add a new virtual folder is:

  1. Right click on the sdk virtual folder in the Project Explorer (Figure 3)

  2. Select New/Folder (Figure 3)

  3. Click Advanced and select Link to alternate location (Figure 4)

  4. Type the location and give a proper Folder name (Figure 4)

_images/smartsnippets_add_new_virtual_folder.png

Figure 4 Create sys_man virtual folder

1.2.1.2. Project References

In SDK10, the dependency on the ble_stack project does not exist as was in SDK1. The same functionality is provided by the ble_stack library, provided in the folder sdk/interfaces/ble/stack/binaries. Any cross-reference between ble_stack project and other application projects is no longer needed in the SDK10 and must be removed (Figure 5).

_images/smartsnippets_project_references.png

Figure 5 Remove project reference to ble_stack

1.2.1.3. C/C++ Build/Settings/Tool Settings

In the right column adjust the correct processor settings as shown in Figure 6:

ARM Family: cortexr-m33

Architecture: Toolchain Default

Instruction Set: Thumb (-mthumb) (No Thumb interworking)

Endianess: Toolchain Default

Float ABI: FP instructions (hard)

FPU Type: fpv5-sp-d16

Unaligned access: Toolchain Default

_images/smartsnippets_target_processor.png

Figure 6 Target processor settings

Additionally, assign the appropriate device value to the corresponding build target. For instance, add dg_configDEVICE=DEVICE_DA1469x to the DA1469x-00-Debug_QSPI target. This should be done under both Cross ARM GNU Assembler/Preprocessor and Cross ARM C Compiler/Preprocessor subentries (Figure 7).

_images/smartsnippets_config_device.png

Figure 7 Add dg_configDEVICE=DEVICE_DA1469x symbol to compiler preprocessor

1.2.1.4. C/C++ Build/Settings/Build Steps

Modify the command text box contents by adding the appropriate device and FPGA values. For example DEVICE=DEVICE_DA1469x USE_FPGA=0 (Figure 8). Add also the string MIDDLEWARE_CONFIG_DIR="${workspace_loc:/${ProjName}/sdk/middleware_config}".

_images/smartsnippets_build_steps.png

Figure 8 Update command text box in Pre-build steps

1.2.1.5. C/C++ General/Paths and Symbols/Includes

There are numerous path alignments for proper include-path resolving.

Delete the following path-entries, if found in the GNU C or the Assembly languages:

  • /ble_stack

  • /${ProjName}/sdk/ble/src/stack/modules/*

  • /${ProjName}/sdk/ble/src/stack/plf/*

  • /${ProjName}/sdk/ble/src/stack/ip/*

Modify the following path-entries for the GNU C language:

* ``/${ProjName}/sdk/ble/src/stack/config`` --> ``/${ProjName}/sdk/ble/stack/config``
* ``/${ProjName}/sdk/ble/include``          --> ``/${ProjName}/sdk/ble/stack/da14690/include``
* ``/${ProjName}/sdk/ble/include/adapter``  --> ``/${ProjName}/sdk/ble/adapter/include``
* ``/${ProjName}/sdk/ble/include/manager``  --> ``/${ProjName}/sdk/ble/manager/include``
* ``/${ProjName}/sdk/ble_services/include`` --> ``/${ProjName}/sdk/ble/services/include``
* ``/${ProjName}/sdk/cpm/include``          --> ``/${ProjName}/sdk/sys_man/include``

Add the following path-entries for the GNU C language. The Is a Workspace Path checkbox must be ticked:

  • /${ProjName}/config

  • /${ProjName}/sdk/util/crc

  • /${ProjName}/sdk/util/include

  • /${ProjName}/sdk/util/crc

  • /${ProjName}/sdk/ble/api/include

  • /${ProjName}/sdk/snc/include

  • /${ProjName}/sdk/snc/src

  • /${ProjName}/sdk/sys_man

  • /${ProjName}/sdk/FreeRTOS/portable/GCC/DA1469x

Under both, GNU C and Assembly languages, add:

/${ProjName}/sdk/middleware_config

Figure 9 shows the updated include paths.

_images/smartsnippets_path_includes.png

Figure 9 Update include paths

1.2.1.6. C/C++ General/Paths and Symbols/Library Paths

For proper lilbary usage add the following entry:

/${ProjName}/sdk/ldscripts

Make sure that the line regarding the binary libraries maps to the respective linked folder in the ble library:

/${ProjName}/sdk/ble/binaries/DA1469x-Release (for a release build configuration)

Also, remove the entry:

"${workspace_loc:/${ProjName}/misc}"

Figure 10 shows the updated Library Paths.

_images/smartsnippets_library_paths.png

Figure 10 Update Library Paths

1.2.1.7. C/C++ General/Paths and Symbols/Library

Make sure that BLE stack library is included as shown in Figure 11.

_images/smartsnippets_ble_stack_library.png

Figure 11 Include BLE stack library

1.2.2. Files alignment

Depending on the project, some makefiles and source code may need editing. The following sections describe the necessary changes for porting a project in SDK10, using as an example ble_adv project .

1.2.2.1. makefile.targets

Make sure the compilation command line looks like the one below:

%.ld : $(LDSCRIPT_PATH)/%.ld.h FORCE
     "$(CC)" -I "$(BSP_CONFIG_DIR)" -I "$(MIDDLEWARE_CONFIG_DIR)" $(PRE_BUILD_EXTRA_DEFS) -include "$(APP_CONFIG_H)" $(LD_DEFS) -Ddg_configDEVICE=$(DEVICE) -Ddg_configUSE_FPGA=$(USE_FPGA) -Ddg_configBLACK_ORCA_IC_REV=BLACK_ORCA_IC_REV_$(IC_REV) -Ddg_configBLACK_ORCA_IC_STEP=BLACK_ORCA_IC_STEP_$(IC_STEP) -E -P -c "$<" -o "$@"

Make sure the second line is indented with a TAB character.

1.2.2.2. custom_config_qspi.h (or any custom configuration file used)

Remove the following deprecated macros:

#define dg_configEXT_CRYSTAL_FREQ

If needed by the project, two preprocessor macros regarding the ble services and clients should be defined:

#define CONFIG_USE_BLE_SERVICES
#define CONFIG_USE_BLE_CLIENTS

For some projects, macro configTOTAL_HEAP_SIZE should be updated:

#define configTOTAL_HEAP_SIZE                   16828

Include the default middleware header at the end of all custom_config_*.h files:

#include "middleware_defaults.h"

1.2.2.3. main.c

Insert XTAL parameter in the system clock initialization:

cm_sys_clk_init(sysclk_XTAL32M);
cm_sys_clk_set(sysclk_XTAL32M);

Remove the following line from the main function:

cm_clk_init_low_level()

Remove the following line from the vApplicationTickHook function:

OS_POISON_AREA_CHECK( OS_POISON_ON_ERROR_HALT, result );

Change the following function calls (if found):

pm_stay_alive()           --> pm_sleep_mode_request(pm_mode_active)
pm_resume_sleep()         --> pm_sleep_mode_release(pm_mode_active)
pm_get_sleep_mode()       --> pm_sleep_mode_get()
pm_set_sleep_mode(arg)    --> pm_sleep_mode_set(arg)
ad_battery_raw_to_mvolt() --> ad_gpadc_conv_to_batt_mvolt()
ad_battery_*              --> ad_gpadc_*

For more information regarding API changes please refer to SmartSnippets™ DA1469x SDK auto-generated documentation ([Ref_02]).

1.2.2.4. NVPARAM alignment

Rename platform_nvparams.h file to app_nvparam.h and change all occurances of PLATFORM_NVPARAM_H_ to APP_NVPARAM_H_ in this file. Rename platform_nvparams_values.h to app_nvparams_values.h

At the top of the app_nvparam.h file add:

#include "platform_nvparam.h"

and then delete all the entries that are common with sdk/adapters/include/platform_nvparam.h (those are entries from ble_pltform area).

At the top of the app_nvparam_values.h file add:

#include "platform_nvparam_values.h"

and then delete all the entries that are common with sdk/adapters/include/platform_nvparam.h.

1.2.2.5. config/platform_devices.h

Here is a template for config/platform_devices.h file that needs to be added to the project.

#ifndef PLATFORM_DEVICES_H_
#define PLATFORM_DEVICES_H_

#include "ad_gpadc.h"

#ifdef __cplusplus
extern "C" {
#endif

#if (dg_configGPADC_ADAPTER == 1)

/*
 * Define sources connected to GPADC
 */

const ad_gpadc_controller_conf_t TEMP_SENSOR;
const ad_gpadc_controller_conf_t BATTERY_LEVEL;

#endif /* dg_configGPADC_ADAPTER */
#ifdef __cplusplus
}
#endif

#endif /* PLATFORM_DEVICES_H_ */

1.2.2.6. Source file platform_devices.c

Here is a template for platform_devices.c file that needs to be added to the project.

#include <stdio.h>
#include <stdbool.h>
#include "ad_gpadc.h"

#if (dg_configGPADC_ADAPTER == 1)

/*
 * Define sources connected to GPADC
 */

const ad_gpadc_driver_conf_t battery_level_driver = {
     .clock                  = HW_GPADC_CLOCK_INTERNAL,
     .input_mode             = HW_GPADC_INPUT_MODE_SINGLE_ENDED,
     .input                  = HW_GPADC_INPUT_SE_VBAT,
     .temp_sensor            = HW_GPADC_NO_TEMP_SENSOR,
     .sample_time            = 15,
     .chopping               = true,
     .oversampling           = HW_GPADC_OVERSAMPLING_4_SAMPLES,
     .input_attenuator       = HW_GPADC_INPUT_VOLTAGE_UP_TO_1V2,
};

const ad_gpadc_controller_conf_t BATTERY_LEVEL = {
     HW_GPADC_1,
     NULL,
     &battery_level_driver
};

#endif /* dg_configGPADC_ADAPTER */

2. References

Ref_01

UM-B-092 DA1469x Software Platform Reference, User manual, Dialog Semiconductor

Ref_02

SmartSnippets™ DA1469x SDK auto-generated documentation (Doxygen)