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

Configuring 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.

Configuring custom_config.h

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

Table 9 Parameters in custom_config.h
Macro Description
SOC_GR5515 Define the SoC version number.
CHIP_TYPE

Select the chip type.

  • 0: GR5515IGND
  • 1: GR5515IENDU
  • 2: GR5515I0ND
  • 3: GR5515I0NDA
  • 4: GR5515RGBD
  • 5: GR5515GGBD
  • 6: GR5513BEND
  • 7: GR5513BENDU
ENCRYPT_ENABLE

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
PLATFORM_INIT_ENABLE

Enable/Disable platform initialization. If this macro is disabled, the SoC Bluetooth LE and sleep functions are disabled. Default value for the macro: 1

  • 0: Disable
  • 1: Enable
SYS_FAULT_TRACE_ENABLE

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

Enable/Disable the App Drivers module.

  • 0: Disable the App Drivers module.
  • 1: Enable the App Drivers module.
APP_LOG_ENABLE

Enable/Disable the APP LOG module.

  • 0: Disable the APP LOG module.
  • 1: Enable the APP LOG module.
APP_LOG_STORE_ENABLE

Enable/Disable the APP LOG STORE module.

  • 0: Disable the APP LOG STORE module.
  • 1: Enable the APP LOG STORE module.
APP_LOG_PORT

Set the output port of the APP LOG module.

  • 0: UART
  • 1: J-Link RTT
  • 2: ARM ITM
SK_GUI_ENABLE

Enable/Disable the GUI module on GR5515 SK Board.

  • 0: Disable the GUI module.
  • 1: Enable the GUI module.
DEBUG_MONITOR

Enable/Disable the Debug Monitor module.

  • 0: Disable the Debug Monitor module.
  • 1: Enable the Debug Monitor module.
DTM_TEST_ENABLE

Enable/Disable DTM Test.

  • 0: Disable DTM Test.
  • 1: Enable DTM Test.
DFU_ENABLE

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, and the start address shall not be located in a memory area in use (such as SCA or User App).
NVDS_NUM_SECTOR Number of Flash sectors for NVDS; range: 1–16
SYSTEM_STACK_SIZE

Size of Call Stack required by applications. You can set the value as needed. Please note that the value shall not be less than 6 KB. The default value is 16 KB.

After compilation of ble_app_example, Maximum Stack Usage is provided in Keil_5\Objects\ble_app_example.htm for reference.

SYSTEM_HEAP_SIZE

You can adjust the sizes of Heap for applications according to practical use of applications. The default is 4 KB.

ENABLE_BACKTRACE_FEA Enable/Disable stack backtrace functionality.
  • 0: Disable stack backtrace.
  • 1: Enable stack backtrace.
CHIP_VER* SoC version number
APP_CODE_LOAD_ADDR* Start address of the application storage area. This address shall be within the Flash address range.
APP_CODE_RUN_ADDR*

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

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: 32 MHz (PLL)

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

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 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*

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*

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

  • 0: Do not check.
  • 1: Check.
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 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 Maximum number of GATT Profiles/Services included in applications. Set the value on demand: A larger value means to occupy more RAM space.
CFG_SCAN_DUP_FILT_LIST_NUM Number of devices that can be filtered during scanning; max.: 50. You can set the value based on needs.
CFG_MAX_CONNECTIONS

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 Bluetooth LE Stack Heaps. The size of Bluetooth LE 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 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

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 Maximum Bluetooth LE scanning number supported by applications; max: 1
CFG_BT_BREDR

Support generating BT keys through the LE link or not.

  • 0: No
  • 1: Yes
CFG_MUL_LINK_WITH_SAME_DEV

Support multi-link functionality for a single device or not, typically used for Find My application.

  • 0: No
  • 1: Yes
CFG_CAR_KEY_SUPPORT

Support digital car key applications or not.

  • 0: No
  • 1: Yes
CFG_MAX_SYNCS Number of synchronized periodic advertising; used for reserving RAM for Bluetooth LE 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
SECURITY_CFG_VAL

Configure the algorithm security level.

  • 0: Level 1
  • 1: Level 2

*: Macros marked with an asterisk (*) in the table above are used to initialize the BUILD_IN_APP_INFO structure which is defined at an offset of 0x200 from the firmware address (APP_CODE_LOAD_ADDR). During firmware download, the structure information is stored in SCA. During system boot, the Bootloader reads the configuration information of the firmware from SCA as boot parameters.

Notes in 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

Configuring Memory Layout

Keil defines memory segments for the linker in .sct files. 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 ‘GRxx_Soc’ 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\platform\soc\linker\keil; 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\user\ -I .\..\Src\config\ --cpu Cortex-M4” in the flash_scatter_common.sct specifies an Include path, which is the path of 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.

Configuring After Build

After Build in Keil can specify a command line to run after a project is built. By default, the ble_app_template project is equipped with After Build command. You do not need to configure After Build manually for the ble_app_example project that is based on ble_app_template.

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 ‘GRxx_Soc’ dialog box. Select the User tab.
  2. From the options expanded from After Build/Rebuild, select Run #1, and type fromelf.exe --text -c --output Listings\@L.s Objects\@L.axf in the corresponding User Command field. This step helps you utilize Keil fromelf to generate a compiling file based on the selected .axf file.
  3. From the options expanded from After Build/Rebuild, select Run #2, and type fromelf.exe --bin --output Listings\@L.bin Objects\@L.axf in the corresponding User Command field. This step helps you utilize Keil fromelf to generate a .bin file based on the selected .axf file.
  4. Click OK to save the settings.
Figure 21 Configuration of After Build

Scan to follow

Open WeChat, use "Scan" to follow.