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.
Macro | Description |
---|---|
SOC_GR5515 | Define the SoC version number. |
CHIP_TYPE | Select the chip type.
|
ENCRYPT_ENABLE | Enable/Disable firmware encryption. Default: 0
|
EXT_EXFLASH_ENABLE | Use external Flash or not.
|
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
|
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.
|
APP_DRIVER_USE_ENABLE | Enable/Disable the App Drivers module.
|
APP_LOG_ENABLE | Enable/Disable the APP LOG module.
|
APP_LOG_STORE_ENABLE | Enable/Disable the APP LOG STORE module.
|
APP_LOG_PORT | Set the output port of the APP LOG module.
|
SK_GUI_ENABLE | Enable/Disable the GUI module on GR5515 SK Board.
|
DEBUG_MONITOR | Enable/Disable the Debug Monitor module.
|
DTM_TEST_ENABLE | Enable/Disable DTM Test.
|
DFU_ENABLE | Enable/Disable 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.
|
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
|
SYSTEM_CLOCK | System clock frequency. Optional values are provided as follows:
|
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.
|
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).
|
BOOT_CHECK_IMAGE* | Determine whether to check the image during cold boot in XIP mode.
|
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:
|
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.
|
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.
|
CFG_MUL_LINK_WITH_SAME_DEV | Support multi-link functionality for a single device or not, typically used for Find My application.
|
CFG_CAR_KEY_SUPPORT | Support digital car key applications or not.
|
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.
|
CFG_LCP_SUPPORT | Support the LCP module or not.
|
SECURITY_CFG_VAL | Configure the algorithm security level.
|
*: 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.
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.
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:
- Click (Options for Target) on the Keil toolbar and open the Options for Target ‘GRxx_Soc’ dialog box. Select the Linker tab.
- 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.
- Click Edit... to open the .sct file, and modify corresponding code based on product memory layout.
- 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:
- Click (Options for Target) on the Keil toolbar and open the Options for Target ‘GRxx_Soc’ dialog box. Select the User tab.
- 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.
- 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.
- Click OK to save the settings.