CN / EN
Doc Feedback
Thanks for your interest, welcome to contact us.
Thanks for your feedback

Configure a Project

You should configure corresponding project options according to product characteristics, including NVDS, code running mode, memory layout, After Build and other configuration items.

Configure custom_config.h

The custom_config.h is used to configure parameters of application projects. A custom_config.h template is provided in SDK_Folder\build\config\. The custom_config.h of each application example project is in Src\config under project directory.

Table 9 Parameters in the custom_config.h
Macro Description
CHIP_TYPE

Select the chip type.

0: GR5515

1: GR5513

ENCRYPT_ENABLE

It is used to enable/disable firmware encryption. Default: 0

0: Disable firmware encryption; support removing related encryption code to save RAM space.

1: Enable firmware encryption.

EXT_EXFLASH_ENABLE

Use external Flash or not.

0: No

1: Yes

SYS_FAULT_TRACE_ENABLE

It is used to enable/disable Callstack Trace Info printing. If printing is enabled, the Callstack Trace Info is printed through serial ports when a HardFault occurs.

0: Disable Callstack Trace Info printing.

1: Enable Callstack Trace Info printing.

APP_DRIVER_USE_ENABLE

It is used to enable/disable the App Drivers module.

0: Disable the App Drivers module.

1: Enable the App Drivers module.

APP_LOG_ENABLE

It is used to enable/disable the APP LOG module.

0: Disable the APP LOG module.

1: Enable the APP LOG module.

APP_LOG_STORE_ENABLE

It is used to enable/disable the APP LOG STORE module.

0: Disable the APP LOG STORE module.

1: Enable the APP LOG STORE module.

APP_LOG_PORT

It is used to set the output port of the APP LOG module.

0: UART

1: J-Link RTT

2: ARM ITM

SK_GUI_ENABLE

It is used to enable/disable the GUI module on GR5515 Starter Kit Board.

0: Disable the GUI module.

1: Enable the GUI module.

DEBUG_MONITOR

It is used to enable/disable the Debug Monitor module.

0: Disable the Debug Monitor module.

1: Enable the Debug Monitor module.

DTM_TEST_ENABLE

It is used to enable/disable DTM Test.

0: Disable DTM Test.

1: Enable DTM Test.

DFU_ENABLE

It is used to enable/disable DFU.

0: Disable DFU.

1: Enable DFU.

FLASH_PROTECT_PRIORITY

During flash write or erase, applications can block the interrupts with priority level lower than or equal to a set value.

When FLASH_PROTECT_PRIORITY is set to N, interrupt requests with a priority level not higher than N are suspended. After erase is completed, flash responds to the suspended interrupt requests. By default, flash does not respond to any interrupt request during erase. Developers can set a value on demand.

NVDS_START_ADDR Start address of NVDS. By default, this macro is defined in cutom_config.h. However, the defined initial value only applies to the scenario where the applied NVDS contains only one sector. If more than one sector is needed, users shall calculate the start address (4 KB-aligned required) according to the applied sector number.
NVDS_NUM_SECTOR It represents the number of flash sectors for NVDS.
CSTACK_HEAP_SIZE

You can adjust the sizes of Call Stack and Heap for applications according to practical usage of applications. The value shall not be less than 6 KB. The default is 16 KB.

After compilation of an example project, a Maximum Stack Usage is provided in Keil_5\Objects\<project_name>.htm for reference.

ENABLE_BACKTRACE_FEA Enable/Disable stack backtrace functionality.

0: Disable stack backtrace.

1: Enable stack backtrace.

APP_CODE_LOAD_ADDR* It represents the start address of the application storage area. This address shall be within the flash address range.
APP_CODE_RUN_ADDR*

It represents the start address of the application running space.

If the value is the same as APP_CODE_LOAD_ADDR, applications run in XIP Mode.

If the value is within the RAM address range, applications run in Mirror Mode.

SYSTEM_CLOCK*

It represents the system clock frequency. Optional values are provided as follows:

  • 0: 64 MHz

  • 1: 48 MHz

  • 2: 16 MHz (XO)

  • 3: 24 MHz

  • 4: 16 MHz

  • 5: 32MHz (PLL)

CFG_LF_ACCURARY_PPM It represents the Bluetooth LE low frequency sleep clock accuracy. The value shall range from 1 to 500 (unit: ppm).
CFG_LPCLK_INTERNAL_EN

It is used to enable/disable the OSC clock inside an SoC as the Bluetooth LE low-frequency sleep clock. If the OSC clock is enabled, CFG_LF_ACCURARY_PPM will be set to 500 automatically.

0: Disable.

1: Enable.

CFG_CRYSTAL_DELAY It is used to set the delay time of chips after RTC is enabled in PMU or parameters like RTC GM are modified. It shall be configured based on the stabilization time after starting oscillating obtained in practical crystal oscillator tests. Value range: 100–500 (unit: ms); default: 100 ms.
BOOT_LONG_TIME*

It is used to set necessary 1-second delay (during SoC boot before implementing the second half Bootloader).

0: No delay.

1: Delay for 1 second.

BOOT_CHECK_IMAGE

It determines whether to check the image during cold boot in XIP mode.

0: Do not check.

1: Check.

VERSION* It represents the version number of application firmware; length: 2 bytes; it is stored in hexadecimal format.
EXFLASH_WAKEUP_DELAY During warm boot, set the delay time for waking up Flash and reading the chip ID. Value range: 0–10; unit: 5 μs. Setting the value to 0 indicates no delay. Each time the value increases by 1, the delay time increases by 5 μs.
CFG_MAX_BOND_DEVS It represents the maximum number of bonded devices supported by applications. You should set the value on demand. A larger value means more RAM space to be occupied.
CFG_MAX_PRFS It represents the maximum number of GATT Profiles/Services included in applications. Set the value on demand: A larger value means to occupy more RAM space.
CFG_MAX_CONNECTIONS

It represents the maximum number of connected devices supported by applications, and the number shall not be greater than 10. You can set the value based on needs.

A larger value means more RAM space to be occupied by BLE Stack Heaps. The size of BLE Stack Heaps is defined by the following four macros in flash_scatter_config.h, which cannot be changed by developers:

  • ENV_HEAP_SIZE

  • ATT_DB_HEAP_SIZE

  • KE_MSG_HEAP_SIZE

  • NON_RET_HEAP_SIZE

CFG_MAX_ADVS The maximum number of Bluetooth LE legacy advertising and extended advertising supported by applications
CFG_MAX_ADV_DATA_LEN_SUPPORT

Support legacy advertising with data length at 31 bytes or not.

0: No

1: Yes

CFG_MAX_PER_ADVS

The maximum number of Bluetooth LE periodic advertising supported by applications

Note:

The sum of configured legacy/extended advertising value (CFG_MAX_LEG_EXT_ADVS) and the configured periodic advertising value (CFG_MAX_PER_ADVS) shall not exceed 5.

CFG_MAX_SCAN The maximum Bluetooth LE scanning number supported by applications; max: 1
CFG_MAX_SYNCS Number of synchronized periodic advertising; used for reserving RAM for BLE Protocol Stack. Developers can set the value according to the number of synchronized periodic advertising in use. Max: 5
CFG_MESH_SUPPORT

Support Mesh or not.

0: No

1: Yes

CFG_LCP_SUPPORT

Support the LCP module or not.

0: No

1: Yes

APP_DRV_I2C/SPI/UART_DMA_ENABLE

Enable/Disable DMA mode of the I2C/SPI/UART APP Driver module.

0: Disable

1: Enable

APP_DRV_I2C/SPI/UART_IT_ENABLE

Enable/Disable interrupt mode of the I2C/SPI/UART APP Driver module.

0: Disable

1: Enable

* The ble_tools.exe in the SDK toolchain reads the macro value to generate an SCA image file. The Bootloader reads the value from SCA and uses it as a boot parameter.

Notes in the custom_config.h comply with Configuration Wizard Annotations of Keil. Therefore, you can use the graphic Keil Configuration Wizard to configure project parameters of applications. It is highly recommended to use the Wizard to prevent inputting invalid parameter values.

Figure 19 Configuration Wizard for custom_config.h

Configure Memory Layout

Keil defines memory segments for the linker in .sct files. The GR551x SDK provides an example flash_scatter_common.sct for application developers. The macros used by this .sct file are defined in the flash_scatter_config.h.

Note:

In Keil, __attribute__(( section("name"))) can be used to place a function or a variable at a separate memory segment, and the “name” depends on your choice. A scatter (.sct) file specifies the location for a named segment. For example, place Zero-Initialized (ZI) data of applications at the segment named “__attribute__((section(".bss.app")))”.

You can follow the steps below to configure the memory layout:

  1. Click (Options for Target) on the Keil toolbar and open the Options for Target ‘GR551x_SK’ dialog box. Select the Linker tab.
  2. On the Scatter File bar, click ... to browse and select the flash_scatter_common.sct file in SDK_Folder\toolchain\gr551x\source\arm; or copy the scatter (.sct) file and its .h file to the ble_app_example project directory and then select the scatter file.
    Note:

    “#! armcc -E -I ..\Src\config\ --cpu Cortex-M4” in the flash_scatter_common.sct specifies an Include path, which is the path of the custom_config.h of an application project. A wrong path results in a linker error.

  3. Click Edit... to open the .sct file, and modify corresponding code based on product memory layout.
    Figure 20 Configuration of scatter file
  4. Click OK to save the settings.

Configure After Build

After Build in Keil can specify an executable program or batch file to run after a project is built. By default, the ble_app_template project adds the after_build.bat file to After Build. You do not need to configure After Build manually for the ble_app_example project based on ble_app_template. For more information about functions of after_build.bat provided in the GR551x SDK, see “Generate Firmware”.

If you build a project, follow the steps below to configure After Build:

  1. Click (Options for Target) on the Keil toolbar and open the Options for Target ‘GR551x_SK’ dialog box. Select the User tab.
  2. From the options expanded from After Build/Rebuild, check Run #1, and then click to browse and select the after_build.bat file in SDK_Folder\build\scripts; or copy the after_build.bat file in SDK_Folder\build\scripts to the ble_app_example project directory and select the file.
    Note:

    Some relative paths are provided in the after_build.bat file, for example, the path of the SDK tools directory. If the batch file is no longer in SDK_Folder\build\scripts, modify these relative paths to avoid any After Build error.

  3. Click OK to save the settings.
Figure 21 Configuration of After Build

Scan to follow

Open WeChat, use "Scan" to follow.