• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 GOODIX.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  ****************************************************************************************
18  *
19  * @file scatter_config.h
20  *
21  * @brief Common scatter file definition file.
22  *
23  *
24  ****************************************************************************************
25  */
26 
27 #ifndef SCATTER_CONFIG_H
28 #define SCATTER_CONFIG_H
29 
30 #include "custom_config.h"
31 
32 /*****************************************************************
33  * if CSTACK_HEAP_SIZE is not defined in custom_config.h,
34  * keep default setting to 32KB
35  */
36 #ifndef CSTACK_HEAP_SIZE
37 #define CSTACK_HEAP_SIZE     0x8000
38 #endif
39 
40 #define FLASH_START_ADDR         0x01000000
41 #define FLASH_SIZE               0x00800000
42 
43 /* size of ROM reserved RAM in retention cell */
44 #ifndef ROM_RTN_RAM_SIZE
45 #define ROM_RTN_RAM_SIZE        0x4020
46 #endif
47 
48 #define RAM_ALIAS
49 
50 /*****************************************************************
51  * Warning: User App developer never change the six macros below
52  */
53 #ifdef RAM_ALIAS
54 #define RAM_START_ADDR          0x00800000
55 #else
56 #define RAM_START_ADDR          0x30000000
57 #endif
58 
59 #if (CHIP_TYPE == 0)
60 #define RAM_SIZE            0x00040000
61 #else
62 #define RAM_SIZE            0x00020000
63 #endif
64 
65 #define RAM_END_ADDR            (RAM_START_ADDR + RAM_SIZE)
66 
67 
68 #define FERP_SIZE               0x8000     // 32K
69 #define CRITICAL_CODE_MAX_SIZE  0x10000    // maximum size of critical code reserved
70 
71 #if (APP_CODE_RUN_ADDR == APP_CODE_LOAD_ADDR && \
72         APP_CODE_RUN_ADDR >= FLASH_START_ADDR && \
73         APP_CODE_RUN_ADDR < FLASH_START_ADDR + FLASH_SIZE)
74 #define XIP_MODE
75 #endif
76 /****************************************************************/
77 
78 /* ************************************************************************
79  * developer must define CFG_MAX_CONNECTIONS in custom_config.h .
80  * Max value for GR551X: 10 which must be same with CFG_CON
81  * in ROM's configs.opt
82  */
83 #ifndef CFG_MAX_CONNECTIONS
84 #error "CFG_MAX_CONNECTIONS is not defined in app's custom_config.h ."
85 #endif
86 
87 #if (CFG_MAX_CONNECTIONS <= 10)
88 #define USER_MAX_CONNECTIONS CFG_MAX_CONNECTIONS
89 #else
90 #define USER_MAX_CONNECTIONS (1)
91 #endif
92 
93 #ifndef CFG_MAX_ADVS
94 #error "CFG_MAX_ADVS is not defined in app's custom_config.h ."
95 #endif
96 
97 #if (CFG_MAX_ADVS <= 5)
98 #define USER_MAX_ADVS CFG_MAX_ADVS
99 #else
100 #define USER_MAX_ADVS (1)
101 #endif
102 
103 #ifndef CFG_MAX_PER_ADVS
104 #error "CFG_MAX_PER_ADVS is not defined in app's custom_config.h ."
105 #endif
106 
107 #if (CFG_MAX_PER_ADVS <= 5)
108 #define USER_MAX_PER_ADVS CFG_MAX_PER_ADVS
109 #else
110 #define USER_MAX_PER_ADVS (0)
111 #endif
112 
113 #if ((USER_MAX_ADVS+USER_MAX_PER_ADVS) > 5)
114 #error "The number of BLE Legacy/Extended/Periodic Advertising exceeds the limit."
115 #endif
116 
117 #ifndef CFG_MAX_SCAN
118 #error "CFG_MAX_SCAN is not defined in app's custom_config.h ."
119 #endif
120 
121 #if (CFG_MAX_SCAN <= 1)
122 #define USER_MAX_SCAN CFG_MAX_SCAN
123 #else
124 #define USER_MAX_SCAN (1)
125 #endif
126 
127 #ifndef CFG_MAX_SYNCS
128 #error "CFG_MAX_SYNCS is not defined in app's custom_config.h ."
129 #endif
130 
131 #if (CFG_MAX_SYNCS <= 5)
132 #define USER_MAX_SYNCS CFG_MAX_SYNCS
133 #else
134 #define USER_MAX_SYNCS (0)
135 #endif
136 
137 #if ((USER_MAX_CONNECTIONS+USER_MAX_ADVS+2*USER_MAX_PER_ADVS+USER_MAX_SCAN+USER_MAX_SYNCS) > 12)
138 #error "The number of BLE Activities exceeds the limit."
139 #endif
140 
141 #ifndef CFG_MAX_BOND_DEVS
142 #error "CFG_MAX_BOND_DEVS is not defined in app's custom_config.h ."
143 #endif
144 
145 #if (CFG_MAX_BOND_DEVS <= 10)
146 #define USER_MAX_BOND_DEVS CFG_MAX_BOND_DEVS
147 #else
148 #define USER_MAX_BOND_DEVS (1)
149 #endif
150 
151 #ifndef CFG_MAX_PRFS
152 #error "CFG_MAX_PRFS is not defined in app's custom_config.h ."
153 #endif
154 
155 #if (CFG_MAX_PRFS <= 64)
156 #define USER_MAX_PRFS CFG_MAX_PRFS
157 #else
158 #define USER_MAX_PRFS (1)
159 #endif
160 
161 /* The macro is used to compute size of the heap block in bytes. */
162 #define MEM_HEAP_HEADER                     (12 / sizeof(uint32_t))
163 #define MEM_CALC_HEAP_LEN(len)              ((((len) + (sizeof(uint32_t) - 1)) / sizeof(uint32_t)) + MEM_HEAP_HEADER)
164 #define MEM_CALC_HEAP_LEN_IN_BYTES(len)     (MEM_CALC_HEAP_LEN(len) * sizeof(uint32_t))
165 
166 #define ENV_HEAP_SIZE       MEM_CALC_HEAP_LEN_IN_BYTES(292 * USER_MAX_CONNECTIONS + \
167                                                        426 * (USER_MAX_CONNECTIONS + USER_MAX_ADVS + \
168                                                        2 * USER_MAX_PER_ADVS+USER_MAX_SCAN+USER_MAX_SYNCS) + \
169                                                        600)
170 /* The size of heap for ATT database depends on the number of attributes in
171  * profiles. The value can be tuned based on supported profiles. */
172 #if (CFG_MESH_SUPPORT == 1)
173 #include "mesh_stack_config.h"
174 #define ATT_DB_HEAP_SIZE    MEM_CALC_HEAP_LEN_IN_BYTES(1000 + MESH_HEAP_SIZE_ADD)
175 #else
176 #define ATT_DB_HEAP_SIZE    MEM_CALC_HEAP_LEN_IN_BYTES(1024)
177 #endif
178 
179 #define KE_MSG_HEAP_SIZE    MEM_CALC_HEAP_LEN_IN_BYTES(1650 * (USER_MAX_SCAN+USER_MAX_SYNCS) + \
180                                                        112 *(USER_MAX_CONNECTIONS + USER_MAX_ADVS + \
181                                                        2*USER_MAX_PER_ADVS) + 408 *(USER_MAX_CONNECTIONS + \
182                                                        USER_MAX_ADVS + 2 * USER_MAX_PER_ADVS + \
183                                                        USER_MAX_SCAN + USER_MAX_SYNCS)+ 3072)
184 /* The size of non-retention heap is customized. This heap will used by BLE
185  * stack only when other three heaps are full. */
186 #define NON_RET_HEAP_SIZE   MEM_CALC_HEAP_LEN_IN_BYTES(328 * 2)
187 
188 #define PRF_BUF_SIZE    (92*USER_MAX_PRFS + 4)
189 #define BOND_BUF_SIZE   (8*USER_MAX_BOND_DEVS + 4)
190 #define CONN_BUF_SIZE   (372*USER_MAX_CONNECTIONS + 4)
191 
192 
193 /**************************************************************************/
194 /* sections on retention RAM cells */
195 #ifdef CFG_FERP
196 #define STACK_END_ADDR         (RAM_END_ADDR-FERP_SIZE)
197 #else
198 #define STACK_END_ADDR         (RAM_END_ADDR)
199 #endif
200 
201 #ifndef GR5515_E
202 #define USE_TINY_RAM_SPACE
203 #endif
204 
205 #define TINY_RAM_SPACE_START    (RAM_START_ADDR + 0x35CC) /* DONT MODIFY ME !!! */
206 #define TINY_RAM_SPACE_SIZE     (0x750)                   /* DONT MODIFY ME !!! */
207 
208 #define FPB_SECTION_START       0x30004000
209 #define FPB_SECTION_SIZE        0x20
210 
211 #define UNUSED_SECTION_SIZE     0x64
212 
213 // Code size of Application
214 #ifndef APP_MAX_CODE_SIZE
215 #define APP_MAX_CODE_SIZE       0x00800000
216 #endif
217 
218 // RAM size of Application
219 #ifndef APP_RAM_SIZE
220 #define APP_RAM_SIZE            0x00030000
221 #endif
222 
223 #endif // SCATTER_CONFIG_H
224